[Zope-dev] Adding products dynamically
Mats Myrberg
mats@bigbig.to
Tue, 14 Dec 1999 09:06:46 -0800
> > <dtml-with "manage_addFolder(formxx_id, formxx_title)">
> > <dtml-call "manage_addBoring(formxx_id)">
> > <dtml-call "RESPONSE.redirect(formxx_id)">
> > </dtml-with>
> >
> > However, Zope has a hard time finding the manage_addBoring
> method. I can
> > add a Boring product "manually" while in Zope management
> interface. What
> do
> > I have to do to add manage_addBoring to the global namespace (just like
> > manage_addFolder etc).
>
> I think for manage_addBoring to be global, you'd probably have to stick in
> in lib/python somewhere (not in Products). However, you don't
> need to go to
> that extreme. This is untested, but I think it would work:
>
> <dtml-with "manage_addFolder(formxx_id, formxx_title)">
> <dtml-with "manage_addProduct['Boring']">
> <dtml-call "manage_addBoring(formxx_id)">
> <dtml-call "RESPONSE.redirect(formxx_id)">
> </dtml-with>
> </dtml-with>
>
> If you do a view source (a browser view source, not a DTML view source) on
> the Zope management interface, you can see it doing things like this.
>
Unfortunately, Kevin's suggested method does not work either. I am not sure
what manage_addProduct does (being new to Zope). Does it add the product to
Zope so that instances of it can be created? In this case, this has already
happened (in this case) when Zope starts up. I guess I should clarify that
I want to add an instance of a product, not add the product itself since it
is added automatically when Zope fires up. Regardless, I get the same error
message with Kevin's code as with my original code:
Error Type: NameError
Error Value: manage_addBoring
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_With.py,
line 148, in render
(Object: manage_addFolder(formxx_id, formxx_title))
File C:\Program Files\ZopeSite1\lib\python\DocumentTemplate\DT_With.py,
line 148, in render
(Object: manage_addProduct['Boring'])
File C:\Program Files\ZopeSite1\lib\python\DocumentTemplate\DT_Util.py,
line 321, in eval
(Object: manage_addBoring(formxx_id))
File <string>, line 0, in ?
NameError: (see above)
TIA,
-Mats