Adding ZClass Instances via DTML
hello, I try to add a new instance of a simple zclass "BuchClass" via dtml. I use a dtml-method "view_html" containing some code like this: <FORM ACTION="add_html" METHOD=post enctype="multipart/form-data"> <td>ID: <input type=text name=newID></td> <input type=submit value="Add"> </form> This dtml-method calls another dtml-method "add_dtml" which looks like this: <dtml-call "REQUEST.set('id','<dtml-var newID>')"> <dtml-with "manage_addProduct['BuchProduct']"> <dtml-call "BuchClass_add(_.None,_, NoRedir=1)"> </dtml-with> Calling up "add_dtml" which gets the variable "newID" will bring me this error: The id contains characters illegal in URLs. ****************************************************************** The id contains characters illegal in URLs. Traceback (innermost last): File /usr/local/ZopePark/Zope-2.0.1-src/lib/python/ZPublisher/Publish.py, line 214, in publish_module File /usr/local/ZopePark/Zope-2.0.1-src/lib/python/ZPublisher/Publish.py, line 179, in publish File /usr/local/ZopePark/Zope-2.0.1-src/lib/python/Zope/__init__.py, line 201, in zpublisher_exception_hook (Object: ElementWithAttributes) File /usr/local/ZopePark/Zope-2.0.1-src/lib/python/ZPublisher/Publish.py, line 165, in publish File /usr/local/ZopePark/Zope-2.0.1-src/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: add_html) File /usr/local/ZopePark/Zope-2.0.1-src/lib/python/ZPublisher/Publish.py, line 102, in call_object (Object: add_html) File /usr/local/ZopePark/Zope-2.0.1-src/lib/python/OFS/DTMLMethod.py, line 145, in __call__ (Object: add_html) File /usr/local/ZopePark/Zope-2.0.1-src/lib/python/DocumentTemplate/DT_String.py, line 502, in __call__ (Object: add_html) File /usr/local/ZopePark/Zope-2.0.1-src/lib/python/DocumentTemplate/DT_With.py, line 148, in render (Object: manage_addProduct['BuchProduct']) File /usr/local/ZopePark/Zope-2.0.1-src/lib/python/DocumentTemplate/DT_Util.py, line 321, in eval (Object: BuchClass_add(_.None,_, NoRedir=1)) File <string>, line 0, in ? File /usr/local/ZopePark/Zope-2.0.1-src/lib/python/OFS/DTMLMethod.py, line 141, in __call__ (Object: BuchClass_add) File /usr/local/ZopePark/Zope-2.0.1-src/lib/python/DocumentTemplate/DT_String.py, line 502, in __call__ (Object: BuchClass_add) File /usr/local/ZopePark/Zope-2.0.1-src/lib/python/DocumentTemplate/DT_With.py, line 133, in render (Object: BuchClass.createInObjectManager(REQUEST['id'], REQUEST)) File /usr/local/ZopePark/Zope-2.0.1-src/lib/python/DocumentTemplate/DT_Util.py, line 321, in eval (Object: BuchClass.createInObjectManager(REQUEST['id'], REQUEST)) File <string>, line 0, in ? File /usr/local/ZopePark/Zope-2.0.1-src/lib/python/ZClasses/ZClass.py, line 431, in createInObjectManager (Object: BuchClass) File /usr/local/ZopePark/Zope-2.0.1-src/lib/python/OFS/ObjectManager.py, line 225, in _setObject (Object: ElementWithAttributes) File /usr/local/ZopePark/Zope-2.0.1-src/lib/python/OFS/ObjectManager.py, line 201, in _checkId (Object: ElementWithAttributes) Bad Request: (see above) ************************************************************************************************ Replacing '<dtml-var newID>' with for example 'mynewObject' will add a new zclass instance. Should I make some changes in the constructor-method which contain this codde?: <!--#with "BuchClass.createInObjectManager(REQUEST['id'], REQUEST)"--> <!--#call "propertysheets.buchinfo.manage_editProperties( REQUEST)"--> <!--#/with--> <dtml-comment> <dtml-call "REQUEST.set('id','newObId')"> <dtml-if NoRedir> <dtml-else> <!--#if DestinationURL--> <!--#call "RESPONSE.redirect( DestinationURL+'/manage_workspace')"--> <!--#else--> <!--#call "RESPONSE.redirect( URL2+'/manage_workspace')"--> <!--#/if--> <!--#/if--> thank you nico
----- Original Message ----- From: "Nico Grubert" <nico@beehive.de> To: <zope@zope.org> Sent: Thursday, February 10, 2000 11:41 AM Subject: [Zope] Adding ZClass Instances via DTML
This dtml-method calls another dtml-method "add_dtml" which looks like this:
<dtml-call "REQUEST.set('id','<dtml-var newID>')"> <dtml-with "manage_addProduct['BuchProduct']"> <dtml-call "BuchClass_add(_.None,_, NoRedir=1)"> </dtml-with>
DTML tags don't work inside of other DTML tags. When you do <dtml-call "REQUEST...etc">, the stuff in quotes is actually a python expression. Which means, that if you want to use the newID variable, all you do is just put newID in there, like: <dtml-call "REQUEST.set('id', newID)"> I think the rest of it looks good. Kevin
participants (2)
-
Kevin Dangoor -
Nico Grubert