[Zope] Problem calling manage_addZClass from DTML
Tres Seaver
tseaver@palladion.com
Tue, 02 May 2000 22:13:56 -0500
Sean McGrath <sean@digitome.com> wrote:
> I am getting a NameError exception calling manage_addZClass
> from DTML:
>
> Error Type: NameError
> Error Value: manage_addZClass
>
> My DTML looks like this:-
> <dtml-call "manage_addZClass(REQUEST['ObjectName'])">
>
> I am using Zope 2.1.6 on NT.
Unless you are attempting somthing like the "local products" hack discussed here
back in February (Products declared/scoped within "normal" Zope folders, rather
than the "magic" Control_Panel/Products folder), I can't think of any reason
you'd want to call "manage_addZClass" -- that method is designed to create the
actual class object for a ZClass, and should normally only happen inside
Control_Panel/Products. Instances of a given ZClass are created via the factory
methods defined within the ZClass product.
Guessing that you have defined a ZClass (lets say, "Guiness", defined within a
Product called "HarpBrewery"), and want to instantiate it into a folder
("SeansMug"). The "factory methods" for the Guiness class are called
Guiness_addForm (HTML form, collects the "constructor parameters") and
Guiness_add (DTML method, extracts ctor parms from the REQUEST and creates the
object. In this case, you could do the following within a DTML method bound to
SeansMug (this assumes that the REQUEST object has previously been populated
with appropriate values)::
<dtml-with "manage_addProduct[ 'HarpBrewery' ]"><!-- note square braces! -->
<dtml-call "Guiness.createInObjectManager( REQUEST[ 'ObjectName' ]
, REQUEST )">
</dtml-with>
Hope that helps!
Tres.
--
=========================================================
Tres Seaver tseaver@digicool.com tseaver@palladion.com