[Zope] Creating a ZClass instance via an external method (resolved)

Small Business Services toolkit at magma.ca
Tue Jun 8 14:50:21 EDT 2004


From: "Small Business Services" <toolkit at magma.ca>
> I am trying to create a ZClass instance via an external method.
>
> I have created a 'non-CatalogAware' ZClass called 'WebSites'.  I can
create,
> via the ZMI, an instance of the ZClass with no problem. However, when I
try
> to create an instance via an external method I get an error.
>
> Here is the external method:
>
> def mytest(self):
>        recid = "100"
>        newobj =
>
self.WebSitesChildData.manage_addProduct['SWV2'].WebSites.createInObjectMana
> ger(self, recid, REQUEST)
>        return newobj
>
> where SWV2 is the product name; WebSitesChildData is the folder where I
want
> the ZClass instance to be created; and 'recid' is the id I want to give
the
> ZClass instance.
>
> The error I get is:
>
> Traceback (innermost last):
>   Module ZPublisher.Publish, line 98, in publish
>   Module ZPublisher.mapply, line 88, in mapply
>   Module ZPublisher.Publish, line 39, in call_object
>   Module Products.ExternalMethod.ExternalMethod, line 224, in __call__
>    - __traceback_info__: ((<Folder instance at 843e830>,), {}, None)
>   Module /apps/zope/Extensions/jhtmp.py, line 15, in jhtmp
>   Module ZClasses.ZClass, line 449, in createInObjectManager
>   Module ZPublisher.mapply, line 77, in mapply
> AttributeError: get

The following modification to the external method fixed the problem (I don't
know why it fixed it, it just did):

REQUEST = self.REQUEST
REQUEST.set('id', recid)
newobj =
self.WebSitesChildData.manage_addProduct['SWV2'].WebSites.createInObjectMana
ger(REQUEST['id'], REQUEST)








More information about the Zope mailing list