[Zope] Adding ZClass Instances via DTML

Nico Grubert nico@beehive.de
Thu, 10 Feb 2000 17:41:25 +0100


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