2016-06-02 15 views
0

enter code here dir (sttachments)는 다음 값을 부여합니다.Redmine Python Rest API의 첨부 파일

[u'author', u'content_type', u'content_url', u'created_on', u'description', u'filename', u'filesize', u'id', u'thumbnail_url'] 

첨부 파일의 container_id를 읽을 수 없기 때문에 첨부 파일을 문제가있는지도에 매핑 할 수 없습니다. 첨부 파일의 container_id 방법 문제

from redmine import Redmine 
    conn_red = Redmine('http://localhost:3000', username='admin', password='admin') 
    issue = conn_red.issue.all() 
    attachment = {} 
    att_list = [] 
    for id in issue: 
     for att in id.attachments: 
      attachment['file_name'] = att.content_url 
      attachment['created_date'] = att.created_on 
      att_list.append((0, 0, attachment)) 
      print "issue",id.id,"attachments",att.id,"att_list",att_list 

위의 코드와 함께 첨부 파일을 매핑하는 방법을 보는 방법

다음과 같은 결과를 제공

issue 7 attachments 5 att_list [(0, 0, {'file_name': u'http://localhost:3000/attachments/download/5/3BasicSkills_Eng.pdf', 'created_date': datetime.datetime(2016, 6, 2, 8, 43, 51)})] 
issue 6 attachments 5 att_list [(0, 0, {'file_name': u'http://localhost:3000/attachments/download/5/3BasicSkills_Eng.pdf', 'created_date': datetime.datetime(2016, 6, 2, 8, 43, 51)}), (0, 0, {'file_name': u'http://localhost:3000/attachments/download/5/3BasicSkills_Eng.pdf', 'created_date': datetime.datetime(2016, 6, 2, 8, 43, 51)})] 
issue 5 attachments 5 att_list [(0, 0, {'file_name': u'http://localhost:3000/attachments/download/5/3BasicSkills_Eng.pdf', 'created_date': datetime.datetime(2016, 6, 2, 8, 43, 51)}), (0, 0, {'file_name': u'http://localhost:3000/attachments/download/5/3BasicSkills_Eng.pdf', 'created_date': datetime.datetime(2016, 6, 2, 8, 43, 51)}), (0, 0, {'file_name': u'http://localhost:3000/attachments/download/5/3BasicSkills_Eng.pdf', 'created_date': datetime.datetime(2016, 6, 2, 8, 43, 51)})] 
issue 4 attachments 5 att_list [(0, 0, {'file_name': u'http://localhost:3000/attachments/download/5/3BasicSkills_Eng.pdf', 'created_date': datetime.datetime(2016, 6, 2, 8, 43, 51)}), (0, 0, {'file_name': u'http://localhost:3000/attachments/download/5/3BasicSkills_Eng.pdf', 'created_date': datetime.datetime(2016, 6, 2, 8, 43, 51)}), (0, 0, {'file_name': u'http://localhost:3000/attachments/download/5/3BasicSkills_Eng.pdf', 'created_date': datetime.datetime(2016, 6, 2, 8, 43, 51)}), (0, 0, {'file_name': u'http://localhost:3000/attachments/download/5/3BasicSkills_Eng.pdf', 'created_date': datetime.datetime(2016, 6, 2, 8, 43, 51)})] 
issue 3 attachments 5 att_list [(0, 0, {'file_name': u'http://localhost:3000/attachments/download/5/3BasicSkills_Eng.pdf', 'created_date': datetime.datetime(2016, 6, 2, 8, 43, 51)}), (0, 0, {'file_name': u'http://localhost:3000/attachments/download/5/3BasicSkills_Eng.pdf', 'created_date': datetime.datetime(2016, 6, 2, 8, 43, 51)}), (0, 0, {'file_name': u'http://localhost:3000/attachments/download/5/3BasicSkills_Eng.pdf', 'created_date': datetime.datetime(2016, 6, 2, 8, 43, 51)}), (0, 0, {'file_name': u'http://localhost:3000/attachments/download/5/3BasicSkills_Eng.pdf', 'created_date': datetime.datetime(2016, 6, 2, 8, 43, 51)}), (0, 0, {'file_name': u'http://localhost:3000/attachments/download/5/3BasicSkills_Eng.pdf', 'created_date': datetime.datetime(2016, 6, 2, 8, 43, 51)})] 
issue 2 attachments 3 att_list [(0, 0, {'file_name': u'http://localhost:3000/attachments/download/3/page.png', 'created_date': datetime.datetime(2016, 5, 30, 8, 15, 42)}), (0, 0, {'file_name': u'http://localhost:3000/attachments/download/3/page.png', 'created_date': datetime.datetime(2016, 5, 30, 8, 15, 42)}), (0, 0, {'file_name': u'http://localhost:3000/attachments/download/3/page.png', 'created_date': datetime.datetime(2016, 5, 30, 8, 15, 42)}), (0, 0, {'file_name': u'http://localhost:3000/attachments/download/3/page.png', 'created_date': datetime.datetime(2016, 5, 30, 8, 15, 42)}), (0, 0, {'file_name': u'http://localhost:3000/attachments/download/3/page.png', 'created_date': datetime.datetime(2016, 5, 30, 8, 15, 42)}), (0, 0, {'file_name': u'http://localhost:3000/attachments/download/3/page.png', 'created_date': datetime.datetime(2016, 5, 30, 8, 15, 42)})] 
issue 1 attachments 4 att_list [(0, 0, {'file_name': u'http://localhost:3000/attachments/download/4/page.png', 'created_date': datetime.datetime(2016, 5, 30, 8, 16, 40)}), (0, 0, {'file_name': u'http://localhost:3000/attachments/download/4/page.png', 'created_date': datetime.datetime(2016, 5, 30, 8, 16, 40)}), (0, 0, {'file_name': u'http://localhost:3000/attachments/download/4/page.png', 'created_date': datetime.datetime(2016, 5, 30, 8, 16, 40)}), (0, 0, {'file_name': u'http://localhost:3000/attachments/download/4/page.png', 'created_date': datetime.datetime(2016, 5, 30, 8, 16, 40)}), (0, 0, {'file_name': u'http://localhost:3000/attachments/download/4/page.png', 'created_date': datetime.datetime(2016, 5, 30, 8, 16, 40)}), (0, 0, {'file_name': u'http://localhost:3000/attachments/download/4/page.png', 'created_date': datetime.datetime(2016, 5, 30, 8, 16, 40)}), (0, 0, {'file_name': u'http://localhost:3000/attachments/download/4/page.png', 'created_date': datetime.datetime(2016, 5, 30, 8, 16, 40)})] 

두 번째 목록은 동일한 데이터를 반복한다.

EDIT 여기에 첨부 테이블의 스크린 샷을 첨부하여 ONE

I를, 여기 container_id는 예를 들어

, 문제 번호와 관련된, 그래서 첨부 파일이있는 문제에 따라 목록을 준비하려는된다 1 번 문제 예 : container_id 1은 ID 1과 4라는 두 개의 첨부 파일이 있으므로 목록 [(0,0, {filename : 'vignesh.png'}) (0,0, {filename : '페이지)을 준비해야합니다. png '})], 문제 번호 1에는 목록으로 만들어야하는 두 가지 문제가 있습니다.

+0

당신이 "문제에 첨부 파일을지도"무엇을 의미합니까? ''id.attachments''는 어디서 오는 것입니까? 전체 코드를 게시하십시오. –

+0

나는 전체 코드를 게시합니다 : - Mr Tepkeev –

+0

고마워,하지만 난 여전히 문제가 보이지 않는다. 무엇을 성취하려고하는지 설명해 주시겠습니까? "첨부 파일의 container_id를 읽는 방법과 문제가있는 첨부 파일을 매핑하는 방법"이란 무엇을 의미합니까? –

답변

1

내가 알기로는이 문제는 반복되는 데이터이지만 Python-Redmine 또는 Redmine의 REST API와는 아무런 관련이 없습니다. 당신의 att_list = []이 모듈 수준에 정의되어 있기 때문에 당신이, 예컨대 : 예상대로 다음 모든 작업을해야 첫번째 for() 루프 내에서 정의 할 경우 문제가 발생

from redmine import Redmine 
conn_red = Redmine('http://localhost:3000', username='admin', password='admin') 
issues = conn_red.issue.all() 
for issue in issues: 
    att_list = [] 
    for att in issue.attachments: 
     attachment = { 
      'file_name': att.content_url, 
      'created_date': att.created_on 
     } 
     att_list.append((0, 0, attachment)) 

    print "issue",issue.id, "att_list", att_list 
+0

감사합니다. 코드가 엉망입니다. –