create folder within folder-object via DTML
Hi all! I want to automatically create some instances of default objects whenever creating a specific folder-object within the zope-management interface. This is what I do within the constructor of a folderish object: <dtml-with "termin.createInObjectManager(REQUEST['id'], REQUEST)"> <dtml-call "manage_addFile('invitation', '', 'Einladung')"> // (works) <dtml-call "manage_addFile('protokoll', '','Protokoll')"> // (works) <dtml-call "REQUEST.set('id', 'material')"> <dtml-call "REQUEST.set('public_view', '1')"> <dtml-call "REQUEST.set('public_upload', '0')"> <dtml-call "REQUEST.set('owner_delete', '1')"> <dtml-call "REQUEST.set('store_in_db', '1')"> <dtml-call "MaterialFolder_add(_.None, _, NoRedir=1)"> The last one works, too, BUT the folder is NOT created within the folderish "termin" (unlike the "add_files"). This is what I want: termin (folder) | invitation (file) | protokoll (file) | material (folder) And this is waht I get: termin (folder) | invitation (file) | protokoll (file) material (folder) How is this? Thanks for any help! Regards, Ingo ------------------------------------------
I have a feeling that the problem is the way the manage_addProduct machinery works. Perhaps you can try this: <dtml-with "manage_addProduct['YourProduct']"> <dtml-call "MaterialFolder_add(_.None, _, NoRedir=1)"> </dtml-with> In place of just the call to MaterialFolder_add. This is untested, and it's just a hunch. Kevin ----- Original Message ----- From: "Ingo Assenmacher" <ingo.assenmacher@post.rwth-aachen.de> To: <zope@zope.org> Sent: Saturday, February 12, 2000 10:34 AM Subject: [Zope] create folder within folder-object via DTML
I want to automatically create some instances of default objects whenever creating a specific folder-object within the zope-management interface. This is what I do within the constructor of a folderish object:
<dtml-with "termin.createInObjectManager(REQUEST['id'], REQUEST)">
<dtml-call "manage_addFile('invitation', '', 'Einladung')"> // (works) <dtml-call "manage_addFile('protokoll', '','Protokoll')"> // (works)
<dtml-call "REQUEST.set('id', 'material')"> <dtml-call "REQUEST.set('public_view', '1')"> <dtml-call "REQUEST.set('public_upload', '0')"> <dtml-call "REQUEST.set('owner_delete', '1')"> <dtml-call "REQUEST.set('store_in_db', '1')"> <dtml-call "MaterialFolder_add(_.None, _, NoRedir=1)">
The last one works, too, BUT the folder is NOT created within the folderish "termin" (unlike the "add_files").
This is what I want:
termin (folder) | invitation (file) | protokoll (file) | material (folder)
And this is waht I get:
termin (folder) | invitation (file) | protokoll (file) material (folder)
Hi Kevin. Thanks in advance for your help. So, this is what I do right now: <dtml-with "manage_addProduct['SENEKAProduct']"> <dtml-call "MaterialFolder_add(_.None, _, NoRedir=1)"> </dtml-with> (SENEKAProduct is actually the same Product as the one where MaterialFolder is in). This is what I get: Zope Error Zope has encountered an error while publishing this resource. Error Type: AttributeError Error Value: _u Traceback (innermost last): File /opt/Zope-2.1.2-linux2-x86/lib/python/ZPublisher/Publish.py, line 214, in publish_module File /opt/Zope-2.1.2-linux2-x86/lib/python/ZPublisher/Publish.py, line 179, in publish File /opt/Zope-2.1.2-linux2-x86/lib/python/Zope/__init__.py, line 202, in zpublisher_exception_hook (Object: RoleManager) File /opt/Zope-2.1.2-linux2-x86/lib/python/ZPublisher/Publish.py, line 165, in publish File /opt/Zope-2.1.2-linux2-x86/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: termin_add) File /opt/Zope-2.1.2-linux2-x86/lib/python/ZPublisher/Publish.py, line 102, in call_object (Object: termin_add) File /opt/Zope-2.1.2-linux2-x86/lib/python/OFS/DTMLMethod.py, line 145, in __call__ (Object: termin_add) File /opt/Zope-2.1.2-linux2-x86/lib/python/DocumentTemplate/DT_String.py, line 502, in __call__ (Object: termin_add) File /opt/Zope-2.1.2-linux2-x86/lib/python/DocumentTemplate/DT_With.py, line 148, in render (Object: termin.createInObjectManager(REQUEST['id'], REQUEST)) File /opt/Zope-2.1.2-linux2-x86/lib/python/DocumentTemplate/DT_With.py, line 148, in render (Object: manage_addProduct['SENEKAProduct']) File /opt/Zope-2.1.2-linux2-x86/lib/python/DocumentTemplate/DT_Util.py, line 335, in eval (Object: MaterialFolder_add(_.None, _, NoRedir=1)) (Info: MaterialFolder_add) File <string>, line 0, in ? File /opt/Zope-2.1.2-linux2-x86/lib/python/OFS/DTMLMethod.py, line 141, in __call__ (Object: MaterialFolder_add) File /opt/Zope-2.1.2-linux2-x86/lib/python/DocumentTemplate/DT_String.py, line 502, in __call__ (Object: MaterialFolder_add) File /opt/Zope-2.1.2-linux2-x86/lib/python/App/FactoryDispatcher.py, line 126, in DestinationURL AttributeError: (see above) I think that the Factory has problems determining the actual URL where to put the object. But how can I fix that? I have encountered that failure in other contexts, too. Am 12-Feb-00 schrieb Kevin Dangoor:
I have a feeling that the problem is the way the manage_addProduct machinery works. Perhaps you can try this:
<dtml-with "manage_addProduct['YourProduct']"> <dtml-call "MaterialFolder_add(_.None, _, NoRedir=1)"> </dtml-with>
In place of just the call to MaterialFolder_add.
Regards, Ingo ------------------------------------------
----- Original Message ----- From: "Ingo Assenmacher" <ingo.assenmacher@post.rwth-aachen.de> To: "Kevin Dangoor" <kid@kendermedia.com> Cc: <zope@zope.org> Sent: Sunday, February 13, 2000 9:38 AM Subject: Re: [Zope] create folder within folder-object via DTML
File /opt/Zope-2.1.2-linux2-x86/lib/python/App/FactoryDispatcher.py, line 126, in DestinationURL AttributeError: (see above)
I think that the Factory has problems determining the actual URL where to put the object. But how can I fix that? I have encountered that failure in other contexts, too.
This looks like your MaterialFolder_add method doesn't have the check at the end for the NoRedir flag. When you set NoRedir=1, the DestinationURL variable doesn't get touched... This HowTo has the relevant code: http://www.zope.org/Members/tazzzzz/addZClasses Hope that does it for you! Kevin
Hi Kevin! Thank you VERY much, that was it! Now I can finally move on to more important issues, thanks again! Regards, Ingo. Am 13-Feb-00 schrieb Kevin Dangoor:
This looks like your MaterialFolder_add method doesn't have the check at the end for the NoRedir flag. When you set NoRedir=1, the DestinationURL variable doesn't get touched...
This HowTo has the relevant code: http://www.zope.org/Members/tazzzzz/addZClasses
Regards, Ingo ------------------------------------------
participants (2)
-
Ingo Assenmacher -
Kevin Dangoor