WHY doc.manage_changeProperties(listProperty=1) works but doc.manage_changeProperties({'listProperty':1}) doesn't ? I was using Zope 2.4 B1 on win32: import sys sys.path.insert(0,'zope') sys.path.insert(0,'zope/lib/python') import ZServer import Zope from AccessControl.SecurityManagement import newSecurityManager app = Zope.app() uf=app.acl_users user = uf.getUser('root').__of__(uf) newSecurityManager(None,user) doc=app['doc'] doc.manage_changeProperties({'listProperty':1}) I can not use manage_changeProperties(propertyname=val) because I got the property name from another variable, I intend to use manage_changeProperty({var:val}) for the actual call. Trace is below :
doc.manage_editProperties({'listProperty':1}) Traceback (most recent call last): File "<stdin>", line 1, in ? File "C:\PROGRA~1\zope\lib\python\OFS\PropertyManager.py", line 339, in manage _editProperties manage_tabs_message=message) File "C:\PROGRA~1\zope\lib\python\Shared\DC\Scripts\Bindings.py", line 324, in __call__ return self._bindAndExec(args, kw, None) File "C:\PROGRA~1\zope\lib\python\Shared\DC\Scripts\Bindings.py", line 354, in _bindAndExec return self._exec(bound_data, args, kw) File "C:\PROGRA~1\zope\lib\python\App\special_dtml.py", line 241, in _exec try: result = render_blocks(self._v_blocks, ns) File "C:\PROGRA~1\zope\lib\python\DocumentTemplate\pDocumentTemplate.py", line 261, in render_blocks if type(section) is StringType: section=md[section] File "C:\PROGRA~1\zope\lib\python\DocumentTemplate\pDocumentTemplate.py", line 217, in __getitem__ return v.__render_with_namespace__(self) File "C:\PROGRA~1\zope\lib\python\Shared\DC\Scripts\Bindings.py", line 338, in __render_with_namespace__ return self._bindAndExec((), namevals, namespace) File "C:\PROGRA~1\zope\lib\python\Shared\DC\Scripts\Bindings.py", line 354, in _bindAndExec return self._exec(bound_data, args, kw) File "C:\PROGRA~1\zope\lib\python\App\special_dtml.py", line 241, in _exec try: result = render_blocks(self._v_blocks, ns) File "C:\PROGRA~1\zope\lib\python\DocumentTemplate\pDocumentTemplate.py", line 297, in render_blocks section=section(md) File "C:\PROGRA~1\zope\lib\python\DocumentTemplate\DT_Let.py", line 147, in re nder else: d[name]=expr(md) File "C:\PROGRA~1\zope\lib\python\DocumentTemplate\DT_Util.py", line 228, in e val return eval(code, d) File "<string>", line 0, in ? AttributeError: 'None' object has no attribute 'get'
__________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/
kent sin writes:
WHY
doc.manage_changeProperties(listProperty=1)
works but
doc.manage_changeProperties({'listProperty':1})
doesn't ? Because it expects its first (optional) positional argument to be a "Request" object.
You may try to emulate what you want with: REQUEST.other.update({'listProperty':1})"> doc.manage_changeProperties(REQUEST) Dieter
dieter, Thanks for the information. How can I construct a fake REQUEST from the python? Or are there any module in zope I can get? Rgs, Kent Sin --- Dieter Maurer <dieter@handshake.de> wrote:
kent sin writes:
WHY
doc.manage_changeProperties(listProperty=1)
works but
doc.manage_changeProperties({'listProperty':1})
doesn't ? Because it expects its first (optional) positional argument to be a "Request" object.
You may try to emulate what you want with:
REQUEST.other.update({'listProperty':1})"> doc.manage_changeProperties(REQUEST)
Dieter
__________________________________________________ Do You Yahoo!? Get personalized email addresses from Yahoo! Mail http://personal.mail.yahoo.com/
kent sin writes:
How can I construct a fake REQUEST from the python? Or are there any module in zope I can get? "REQUEST" can be acquired... Thus, if you can get hold of any Zope site building object, say "o", you get "REQUEST" as "o.REQUEST".
In a Python script, "container" or "context" will do. In an external method, "self" may do. Dieter
participants (2)
-
Dieter Maurer -
kent sin