Ticket #7246 (closed Bug: fixed)
TypeError from plone.locking.lockable.lock_info for anonymous content creation
| Reported by: | raphael | Owned by: | raphael |
|---|---|---|---|
| Priority: | major | Milestone: | 3.0.4 |
| Component: | Infrastructure | Keywords: | |
| Cc: |
Description
When allowing anonymous content contributions (like adding a ticket in Poi) plone.locking.lockable.lock_info bombs with a TypeError because in line 103
'creator' : lock.getCreator()[1],
fails if the creator is the anonymous user.
What seems to fix it is to just skip the subscription in that case, aka something like:
try:
creator = lock.getCreator()[1]
except TypeError:
creator = lock.getCreator()
Could someone please confirm before I commit this?
Thanks,
Raphael
Change History
comment:2 Changed 4 years ago by maurits
Right, or I just set it to fixed myself in that same response. Duh. :)
comment:4 Changed 4 years ago by limi
- Status changed from closed to reopened
- Resolution fixed deleted
Maurits, please backport to 3.0 branch. :)
comment:5 Changed 4 years ago by maurits
- Status changed from reopened to closed
- Resolution set to fixed
This is a fix for plone.locking, which has no Plone 3 branch. :)
comment:7 Changed 4 years ago by sirgarr
- Status changed from closed to reopened
- Resolution fixed deleted
Two concerns about this fix --
(1) I don't think it is good to use the string "anonymous," which like you said a user could pick for their login name, unless you explicitly ban that elsewhere. Instead, we could just change locking.pt to read:
This item was locked <span tal:condition="lock_details/fullname">by <span i18n:name="author" tal:content="lock_details/fullname" /></span>
(2) The code isn't internationalized to allow a developer to translate the string "anonymous".
comment:8 Changed 4 years ago by sirgarr
Although actually that HTML (for info.pt, not locking.pt -- I wrote it incorrectly) I suggested isn't internationalized properly.
Another solution: set creator to None; but in locking.py, replace the line "fullname = creator" with "fullname = creator or _(u'anonymous', 'anonymous_label')". That way there's no possibility for name clashes.
comment:10 Changed 4 years ago by maurits
- Status changed from reopened to closed
- Resolution set to fixed
comment:11 Changed 4 years ago by sirgarr
Thanks! =)

I see that too when trying it with Poi. When I try your fix it leads me to a different error, where fullname is not defined. Easily fixed in r18038. Oh, and improved in r18039 and r18042. :-)
I first wondered if anonymous locking is perhaps not wanted and should be disabled. But locking can of course only happen when an anonymous user has edit rights. That is usually not the case. But there are exceptions like adding a PoiIssue/Response or a comment or editing a wiki page. So anonymous locking probably does make sense.
I changed your fix slightly and am so bold as to commit it, together with a test.
Two notes to that:
I changed the info.pt (which has the html snippets for telling the user that the page is locked) so it only has a link to the author page if the author is not anonymous. See r18043.
After I submit this response I will commit the actual fix, which should automatically mark this issue as fixed I think.