[Zope] Creation of objects inside folder like products

Tille, Andreas TilleA@rki.de
Tue, 29 Jan 2002 11:23:53 +0100 (CET)


Hello,

I'm busy writing some folder like product with special features.
The last thing I wanted to add is a TinyTable which is created when
the the FolderProduct is created.  Here is some stripped down code:


MyFolder.py:


link_list='''<dtml-comment>
      ...
</dtml-comment>'''

column_names='Link Frame Text'


##  ........

    if createSelection:
        if not checkPermission('Add Documents, Images, and Files', ob):
            raise 'Unauthorized', (
                  'You are not authorized to add DTML Documents.'
                  )
        ob.manage_addMyDocument(id=ob.id+'_sel.htm', title=ob.id+' left navigation frame',
                                 author=ob.author,
                                 content=frame_sel)
#        ob.manage_addMyDocument(id='link_list', title='List of Links for '+ob.id,
#                                 content=link_list)
        ob.manage_addTinyTable(id='link_list',  title='List of Links for '+ob.id,
			       columns=column_names)


There are two lines commented out from the previous version when I just
tried to solve the problem with a DTMLDocument like object.  The creation
worked perfectly.  Now I wanted to add a TinyTable instead of the
DTMLDocument like product.  Unfortunately this TinyTable will not be
created inside MyFolder but inside the nearest (real) Folder object.
For instance

     <Folder 1>
         -----------> <MyFolder 1>
         -----------> <TinyTable link_list>

If I try to create <MyFolder 2> inside <MyFolder 1> I get:

     <Folder 1>
         -----------> <MyFolder 1>
                           ------------------> <MyFolder 2>
         -----------> <TinyTable link_list>

provided that I removed <TinyTable link_list> before or just moved
<TinyTable link_list> from the first try just inside <MyFolder 1>.
That means MyFolder could perfectly contain <TinyTable link_list>.
It ist just not created inside the MyFolder object.

The same is true for TinyTablePlus.  Quoting from the source
of TinyTable[Plus]:

   def addItem(self, id, title='', columns='', REQUEST=None):
       """Add a TinyTablePlus to a folder

       The argument 'self' will be bound to a folder.

       The arguments, 'id' and 'title' are minimal, and most applications
       will have additional needed arguments.
       """
       self._setObject(id, TinyTablePlus(id, title, columns))
       if REQUEST is not None: return self.manage_main(self,REQUEST)

Does this mean that the addItem Method just searches the object tree
down to the next (real) folder object?

What do I have to do that TinyTable accepts MyFolder as object to be
addable to?

Kind regards

         Andreas.

PS: I hope I did not stripped down my code to much to hide the real
    problem.