[Zope] Adding a document using a form
Mats Myrberg
mats@bigbig.to
Mon, 29 Nov 1999 09:32:09 -0800
Hi,
I am a complete Zope newbie so have some patience with me. Mike suggested a
way to Lalo to move the code that creates the DTML Document into a DTML
Method. I tried this method but I get the below error and stack trace. It
seems that the call to self._setObject is failing. What is self in this
case? BTW the add form is living in a folder called Products in the root
folder. My code for the DTML Method is:
<dtml-call "Products.manage_addProduct['OFSP'].addDTMLDocument(id, title)">
It does not seem to matter whether I prepend the Products object on the call
string or not.
Hopefully I will be able to contribute to the list as I come up to speed.
-Mats
Error Type: AttributeError
Error Value: 'string' object has no attribute '_setObject'
Traceback (innermost last):
File C:\Program Files\ZopeSite1\lib\python\ZPublisher\Publish.py, line
214, in publish_module
File C:\Program Files\ZopeSite1\lib\python\ZPublisher\Publish.py, line
179, in publish
File C:\Program Files\ZopeSite1\lib\python\Zope\__init__.py, line 201, in
zpublisher_exception_hook
(Object: ElementWithAttributes)
File C:\Program Files\ZopeSite1\lib\python\ZPublisher\Publish.py, line
165, in publish
File C:\Program Files\ZopeSite1\lib\python\ZPublisher\mapply.py, line 160,
in mapply
(Object: secureAddMethod)
File C:\Program Files\ZopeSite1\lib\python\ZPublisher\Publish.py, line
102, in call_object
(Object: secureAddMethod)
File C:\Program Files\ZopeSite1\lib\python\OFS\DTMLMethod.py, line 145, in
__call__
(Object: secureAddMethod)
File C:\Program Files\ZopeSite1\lib\python\DocumentTemplate\DT_String.py,
line 502, in __call__
(Object: secureAddMethod)
File C:\Program Files\ZopeSite1\lib\python\DocumentTemplate\DT_Util.py,
line 321, in eval
(Object: Products.manage_addProduct['OFSP'].addDTMLDocument(id, title))
File <string>, line 0, in ?
File C:\Program Files\ZopeSite1\lib\python\OFS\DTMLDocument.py, line 201,
in addDTMLDocument
AttributeError: (see above)
>
> Umm, here's something to try. Remove the special permissions from the
> form page, and set the form's action to a DTML Method that you create.
Give
> _that_ new method proxy roles to create pages. Do your request validation
> there, too. From within the new page, use a DTML tag like...
>
> <dtml-call "manage_addProduct['OFSP'].addDTMLDocument(id, title)">
>
> I _think_ manage_addProduct is a mapping type and needs to be used in
> that manner, but you might have to experiment. At any rate, this will
> create the document, and since there is no REQUEST being passed to
> addDTMLDocument it won't redirect the browser. Then you can redirect them
> yourself, or display whatever message or form you might like from this
page
> itself.
>
> Mike.
>