2016-05-31 116 views
0

残りのAPIを使用して、私はRedmineをPython Scriptに接続し、ODOOのデータを取り込みます。Python Redmine APIのヌル値を読む

問題のRedmine assigned_to値は空です。つまり、これらの値を読み取っている間はNULLです。

Traceback (most recent call last): 
    File "/home/vignesh/PycharmProjects/vignesh/vigred.py", line 23, in <module> 
    redmine_asssigned_to = id.assigned_to 
    File "/usr/local/lib/python2.7/dist-packages/python_redmine-1.5.1-py2.7.egg/redmine/resources.py", line 424, in __getattr__ 
    return super(Issue, self).__getattr__(item) 
    File "/usr/local/lib/python2.7/dist-packages/python_redmine-1.5.1-py2.7.egg/redmine/resources.py", line 193, in __getattr__ 
    return self._action_if_attribute_absent() 
    File "/usr/local/lib/python2.7/dist-packages/python_redmine-1.5.1-py2.7.egg/redmine/resources.py", line 294, in _action_if_attribute_absent 
    raise ResourceAttrError 
redmine.exceptions.ResourceAttrError: Resource doesn't have the requested attribute 

答えて

2

短い答え:代わりにid.assigned_toの使用getattr(id, 'assigned_to', None)

長い答え:存在しない属性にアクセスしようとすると、Python-RedmineがResourceAttrErrorを発生させます。ここで問題となるのは、assigned_toがRedmineに設定されているかどうかによってリソースオブジェクトに存在するかどうか、またPython-Redmineは内部の属性をハードコードしない、つまりRedmineから動的に取得するということですあなたはこの問題を抱えています。

+0

ありがとうございます –