Creation of objects inside folder like products
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.
On Tue, 29 Jan 2002, Tille, Andreas wrote: [I have an idea how just to work around this problem but I do not know how ti implement this. Sorry for quoting myself.]
<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>
By the way: was this explanation clear anough to make me understood? I wonder if it would be possible after adding the TinyTable object to move it into the new MyFolder: ob.manage_addTinyTable(id='temp_link_list', title='List of Links for '+ob.id, columns=column_names) and now move the new TinyTable object named 'temp_link_list' from the Folder it is created in to the new MyFolder object. But this would be a really dirty hack and by the way I do not know how to find the Folder in which the instances of MyFolder reside. Please feel free to ask for further information to detect the problem. I just did not want to overflood the list with unneeded crap. Thanks Andreas.
participants (1)
-
Tille, Andreas