[Zope] Create subfolder at product creation

Wolfgang Strobl ws@mystrobl.de
Thu, 4 Jul 2002 06:38:21 +0200


On 3 Jul 2002, at 20:14, Dieter Maurer wrote:
> It probably looks somehow like this:
> 
>    def addMyProduct(self,id):
>      myInstance= MyProduct()
>      myInstance._setId(id)
>      self._setObject(id,myInstance)
>      # you add here
>      myInstance= getattr(self,id) # to acquisition wrap it
>      childFolder= Folder()
>      childFolder._setId('some_nice_id')
>      myInstance._setObject('some_nice_id',childFolder)
>      # here continues your previous code.

What is the purpose of myInstance._setId(id)? Is it necessary? In 
SimpleItem, it doesn't anything but self.__name__=id.

Most products don't use _setId, the Developers Guide doesn't 
even mention it, but just contains the IMHO somewhat cryptic 
sentence about OFS.SimpleItem:

  id or __name__ 

  All Item instances must have an id string attribute 
   which uniquely identifies the instance within it's
   container. As an alternative you may use 
   __name__ instead of id. 

Now _setObject in ObjectManager already adds a string attribute 
named "id". So in fact _setId seems redundant and should be 
eleminated from the API.

Ugly.

-- 
Wolfgang Strobl