[Zope-dev] Computed Attributes (was: [Zope-dev] How do I create a folder with subfolders, docs etc?)

Dieter Maurer dieter@handshake.de
Fri, 12 Jan 2001 22:02:18 +0100 (CET)


Espen Sorbye Frederiksen writes:
 > I have truble with the permissions (get the message: "Authorization
 > failed. Retry?") when I do the following:
 > 
 > <dtml-call expr="existingFolder.manage_addFolder(folder_id)">
 > <dtml-call expr="existingFolder._[folder_id].manage_addFolder('subFolder')">
An FAQ! Anwser found via a search in the searchable list archive
(though it would be a bit difficult).

Anwser:

  An attribute name must never start with "_".
  Though, it has not been your intend, "_" is
  used as an attribute name in "existingFolder._".

  What you should use instead is:

       _.getattr(existingFolder,folder_id).manage_addFolder('subFolder')


  Keep in mind for the future, that the right
  operand of "." is always a name and never an expression!
  When you want to use an expression, you will
  use "getattr" instead.



Dieter