Basic hassle with manage_changeProperties
Hi all I've encountered a very simple problem with manage_changeProperties as defined in Zope-2.6.1-src/lib/python/OFS/PropertyManager.py The signature is: def manage_changeProperties(self, REQUEST=None, **kw): and the docstring promises: Change object properties by passing either a mapping object of name:value pairs {'foo':6} or passing name=value parameters However, if you call something.manage_changeProperties({a:b}), then REQUEST will be {a:b} and the final check in manage_changeProperties will be true, and manage_propertiesForm will be returned: if REQUEST: message="Saved changes." return self.manage_propertiesForm(self,REQUEST, manage_tabs_message=message) Now, manage_propertiesForm expects REQUEST to be a proper REQUEST object and fails with a KeyError on URL1, when it is a simple dictionary. manage_changeProperties as defined in Zope-2.6.1-src/lib/python/OFS/PropertySheets.py doesn't suffer this problem, since it returns MessageDialog, which doesn't expect anything beyond the keyword parameters it's passed. Either Zope-2.6.1-src/lib/python/OFS/PropertyManager.py should be taught to distinguish between {a:b} and REQUEST, or the docstring should be changed to: Change object properties by passing either the REQUEST, or passing name=value parameters Should I file an issue for this? Regards, -- Jean Jordaan http://www.upfrontsystems.co.za
In article <3E941E76.70705@upfrontsystems.co.za> you write:
def manage_changeProperties(self, REQUEST=None, **kw):
and the docstring promises:
Change object properties by passing either a mapping object of name:value pairs {'foo':6} or passing name=value parameters
However, if you call something.manage_changeProperties({a:b}), then REQUEST will be {a:b} and the final check in manage_changeProperties will be true, and manage_propertiesForm will be returned:
[...]
Either Zope-2.6.1-src/lib/python/OFS/PropertyManager.py should be taught to distinguish between {a:b} and REQUEST, or the docstring should be changed to:
Change object properties by passing either the REQUEST, or passing name=value parameters
Should I file an issue for this?
Yes please. That's mainly a documentation issue. It's always possible to call something.manage_changeProperties(**{a:b}) in any case. Florent -- Florent Guillaume, Nuxeo (Paris, France) +33 1 40 33 79 87 http://nuxeo.com mailto:fg@nuxeo.com
Yes please. That's mainly a documentation issue. It's always possible to call something.manage_changeProperties(**{a:b}) in any case.
It is mainly a documentation issue, yes, but it would definately be ugly if manage_changeProperties in Zope-2.6.1-src/lib/python/OFS/PropertyManager.py behaved differently from the one in Zope-2.6.1-src/lib/python/OFS/PropertySheets.py So either both have to get the more restrictive docstring, or (preferably) both should cope with a plain dict as parameter. -- Jean Jordaan http://www.upfrontsystems.co.za
Jean Jordaan wrote:
Yes please. That's mainly a documentation issue. It's always possible to call something.manage_changeProperties(**{a:b}) in any case.
It is mainly a documentation issue, yes, but it would definately be ugly if manage_changeProperties in Zope-2.6.1-src/lib/python/OFS/PropertyManager.py behaved differently from the one in Zope-2.6.1-src/lib/python/OFS/PropertySheets.py
So either both have to get the more restrictive docstring, or (preferably) both should cope with a plain dict as parameter.
Ok. Please file a collector issue so that this doesn't get lost. Florent -- Florent Guillaume, Nuxeo (Paris, France) +33 1 40 33 79 87 http://nuxeo.com mailto:fg@nuxeo.com
Please file a collector issue so that this doesn't get lost.
http://collector.zope.org/Zope/878 with simplistic patch attached .. basically: - if REQUEST: + if REQUEST and type(REQUEST) != type({}): Dunno if that's *too* simplistic :] -- Jean Jordaan http://www.upfrontsystems.co.za
participants (2)
-
Florent Guillaume -
Jean Jordaan