Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iterating over trackers for a custom field raises exception #78

Closed
necrolyte2 opened this issue Feb 17, 2015 · 8 comments
Closed

Iterating over trackers for a custom field raises exception #78

necrolyte2 opened this issue Feb 17, 2015 · 8 comments
Assignees
Labels
bug

Comments

@necrolyte2
Copy link

@necrolyte2 necrolyte2 commented Feb 17, 2015

>>> c = list(redmine.custom_field.all())
>>> c[0]
<redmine.resources.CustomField #34 "Encounter Date">
>>> c[0].trackers
<redmine.resultsets.ResourceSet object with Tracker resources>
>>> print list(c[0].trackers)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/tyghe/Projects/redmine_sample_management/env/lib/python2.7/site-packages/redmine/resultsets.py", line 107, in __len__
    return sum(1 for _ in self)
  File "/home/tyghe/Projects/redmine_sample_management/env/lib/python2.7/site-packages/redmine/resultsets.py", line 107, in <genexpr>
    return sum(1 for _ in self)
  File "/home/tyghe/Projects/redmine_sample_management/env/lib/python2.7/site-packages/redmine/resultsets.py", line 103, in <genexpr>
    return (self.manager.to_resource(resource) for resource in self.resources)
  File "/home/tyghe/Projects/redmine_sample_management/env/lib/python2.7/site-packages/redmine/managers.py", line 105, in to_resource
    return self.resource_class(self, resource)
  File "/home/tyghe/Projects/redmine_sample_management/env/lib/python2.7/site-packages/redmine/resources.py", line 125, in __init__
    self._attributes.update(attributes)
ValueError: dictionary update sequence element #0 has length 1; 2 is required

Here is the json from /custom_fields.json

{"custom_fields":[{"id":34,"name":"Encounter Date","customized_type":"issue","field_format":"date","regexp":"","visible":true,"trackers":{"tracker":{"id":19,"name":"Respiratory Questionaire"}},"roles":{}}

Redmine: 2.4.5-stable

@maxtepkeev maxtepkeev added the question label Feb 17, 2015
@maxtepkeev maxtepkeev self-assigned this Feb 17, 2015
@maxtepkeev
Copy link
Owner

@maxtepkeev maxtepkeev commented Feb 17, 2015

Hi!

Works fine here:

>>> list(redmine.custom_field.all()[6].trackers) 
[<redmine.resources.Tracker #4 "Bug">,
 <redmine.resources.Tracker #5 "Task">,
 <redmine.resources.Tracker #6 "Support">,
 <redmine.resources.Tracker #7 "User story">]

The JSON output from /custom_fields.json that you attached is incomplete, are you sure you've copy pasted it correctly ?

@necrolyte2
Copy link
Author

@necrolyte2 necrolyte2 commented Feb 17, 2015

I've only pasted the relevant part. I didn't include the ending

]}
@maxtepkeev
Copy link
Owner

@maxtepkeev maxtepkeev commented Feb 17, 2015

Ah, I see, I can confirm the error with your output. It's strange that my Redmine gives me different output to yours. I'll have to investigate this and return to you with results ASAP.

@necrolyte2
Copy link
Author

@necrolyte2 necrolyte2 commented Feb 17, 2015

Sounds good. Seems like it is likely a redmine version difference then.
Just let me know what you need on this end to help

@maxtepkeev
Copy link
Owner

@maxtepkeev maxtepkeev commented Feb 17, 2015

I believe I've found the answer.

It is a bug in Redmine that was fixed in 2.5.2, that is why our outputs differ (I'm on 2.6.0).

I can fix this on the python-redmine side so that it worked with Redmine versions <2.5.2 but I believe that you'll want to upgrade your Redmine installation if you need to get all trackers instead of only one.

@necrolyte2
Copy link
Author

@necrolyte2 necrolyte2 commented Feb 17, 2015

Ahh yes, ok

I'll have to upgrade then. Probably time to do that anyways

maxtepkeev added a commit that referenced this issue Feb 17, 2015
@maxtepkeev maxtepkeev added bug and removed question labels Feb 17, 2015
@maxtepkeev
Copy link
Owner

@maxtepkeev maxtepkeev commented Feb 17, 2015

Fixed in 489b46a. Thanks for the report.

@maxtepkeev maxtepkeev closed this Feb 17, 2015
@necrolyte2
Copy link
Author

@necrolyte2 necrolyte2 commented Feb 17, 2015

Works great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.