[Zope] add properties to file via DTML

Dieter Maurer dieter@handshake.de
Wed, 19 Jun 2002 20:21:53 +0200


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