collective / Products.PloneKeywordManager

Change, merge and delete keywords (AKA tags or subjects) in Plone.
https://pypi.org/project/Products.PloneKeywordManager/
4 stars 8 forks source link

UnboundLocalError on rename #66

Closed jensens closed 2 years ago

jensens commented 2 years ago

On rename I got a

Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 167, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 376, in publish_module
  Module ZPublisher.WSGIPublisher, line 271, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 68, in call_object
  Module Products.PloneKeywordManager.browser.prefs_keywords_view, line 52, in __call__
  Module Products.PloneKeywordManager.browser.prefs_keywords_view, line 115, in changeKeywords
  Module Products.PloneKeywordManager.tool, line 97, in change
UnboundLocalError: local variable 'obj' referenced before assignment

(Using 4.0.0. release)

flipmcf commented 2 years ago

Very likely related to #70

'obj' is technically local to the loop iterating all objects returned from the query. It's defined inside the iterator. Referencing 'obj' outside of that loop is not correct, and if the iterator guard is false at entry, you never enter the loop and define 'obj'.

Issue #70 and PR #71 very likely will remove this edge-case error.

flipmcf commented 2 years ago

I'm going to go out on a limb and close this. Please feel free to re-open if #71 didn't resolve this.

If you can find how you triggered tool.py to call 'change' with a query that finds zero objects, that would be useful to look at and may uncover another bug.