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

contact.tag_list is always splitted into single chars #81

Closed
loechel opened this Issue Feb 19, 2015 · 3 comments

Comments

2 participants
@loechel
Contributor

loechel commented Feb 19, 2015

if I do a:
contact.tag_list = ['newtag1','newtag2']
contact.save()
in redmine it got splitted into single chars.

the redmin log shows following during update:
Processing by ContactsController#update as JSON
Parameters: {"contact"=>{"tag_list"=>"n,e,w,t,a,g,1,n,e,w,t,a,g,2"}, "key"=>"", "id"=>"1"}
Current user: user
Rendered text template (0.0ms)

if I do a separate log statement showing Contact._changes:
log.info('Changes: %s', pformat(contact._changes))
INFO: Changes: {'tag_list': 'newtag1,newtag2'}
So it seems that it is handled either directly on set or multiple times on save()

@loechel

This comment has been minimized.

Contributor

loechel commented Feb 19, 2015

If you wrap tag_list in another list, following Error occurs:
python_redmine-1.0.2-py2.7.egg/redmine/resources.py", line 912, in translate_params
params['tag_list'] = ','.join(params['tag_list'])
TypeError: sequence item 0: expected string, list found

So if params['tag_list'] is a list of strings it should join the strings
if params['tag_list'] is a string it should do nothing

The problem is that it seems that translate_params get tag_list as a string and not as list
','.join('string') will be splitted into 's,t,r,i,n,g'

Maybe a type check on each param would solve that clearly and may also make the writting of code using python-redmine more flexible.

@maxtepkeev maxtepkeev reopened this Feb 19, 2015

@maxtepkeev maxtepkeev added the bug label Feb 19, 2015

@maxtepkeev maxtepkeev self-assigned this Feb 19, 2015

@maxtepkeev

This comment has been minimized.

Owner

maxtepkeev commented Feb 19, 2015

Thanks for the fix, unfortunately there's a little bit more to be done to fix this completely. Also you can't do this: raise ResourceAttrError('Wrong type to update tag_list provided') because ResourceAttrError doesn't expect any arguments.

I'll add the remaining code which will fix this completely tomorrow. Thanks for the report and the fix.

maxtepkeev added a commit that referenced this issue Feb 20, 2015

@maxtepkeev

This comment has been minimized.

Owner

maxtepkeev commented Feb 20, 2015

Completely fixed in f6613da.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment