hi guys I try to add properties to a file via dtml, without success! I get a "Authorization required" message. The security settings are set to "Manage properties - Anonymous, Manager, Owner". here the code I use to add the properties: <dtml-call "REQUEST.set('content_dir', 'news')"> <dtml-call "REQUEST.set('content_id', 'testdocument')"> <dtml-call "REQUEST.set('tA_worker', 'simon')"> <dtml-call "_[content_dir]._[content_id].manage_addProperty('author', tA_worker, 'string')"> here the traceback after pressing "cancel" when the "Authorization required" appears: File /var/data/zope/lib/python/ZPublisher/Publish.py, line 222, in publish_module File /var/data/zope/lib/python/ZPublisher/Publish.py, line 187, in publish File /var/data/zope/lib/python/ZPublisher/Publish.py, line 171, in publish File /var/data/zope/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: addAction) File /var/data/zope/lib/python/ZPublisher/Publish.py, line 112, in call_object (Object: addAction) File /var/data/zope/lib/python/OFS/DTMLMethod.py, line 189, in __call__ (Object: addAction) File /var/data/zope/lib/python/DocumentTemplate/DT_String.py, line 538, in __call__ (Object: addAction) File /var/data/zope/lib/python/DocumentTemplate/DT_With.py, line 146, in render (Object: new_intranet) File /var/data/zope/lib/python/DocumentTemplate/DT_With.py, line 146, in render (Object: _[upload_dir]) File /var/data/zope/lib/python/DocumentTemplate/DT_Util.py, line 334, in eval (Object: _[content_dir]._[content_id].manage_addProperty('author', worker, 'string')) (Info: content_id) File <string>, line 0, in ? File /var/data/zope/lib/python/DocumentTemplate/DT_Util.py, line 142, in careful_getattr Unauthorized: _ can anyone help me? regards ./simon
Simon Brun writes:
I try to add properties to a file via dtml, without success! I get a "Authorization required" message. The security settings are set to "Manage properties - Anonymous, Manager, Owner".
here the code I use to add the properties: <dtml-call "REQUEST.set('content_dir', 'news')"> <dtml-call "REQUEST.set('content_id', 'testdocument')"> <dtml-call "REQUEST.set('tA_worker', 'simon')"> <dtml-call "_[content_dir]._[content_id].manage_addProperty('author', tA_worker, ^ You see this "_"?
In fact, it as a syntax error but the DTML expression parser is a bit lossy and raises instead an "Unauthorized" exception as it sees an attribute starting with "_" (which always is private). Try: <dtml-call "_[content_dir][content_id].manage_addProperty(...)"> When accessing objects, its usually better to use "_.getitem(...)" rather than "_[...]". There is no difference for folders, but callable objects will show drastic differences. Read <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> for details. Dieter
participants (2)
-
Dieter Maurer -
Simon Brun