[Zope] Re: [Zope-dev] creating one ZClass instance in the con structor of another

Brian Lloyd Brian@digicool.com
Fri, 23 Jul 1999 10:57:00 -0400


> Hi,
> 
> In some recent messages, there were people talking
> about creating objects from within External Methods.
> In there, after the createInObjectManager call, they
> call a _setObject method (or something like that).
> Unfortunately, we can't do that from DTML because it
> starts with _.

createInObjectManager is not used in conjunction with _setObject -
createInObjectManager is intended to be used from a DTML method
and encapsulates:
  o basic instantiation of the object, with the given id
  o doing a _setObject on the target ObjectManager with
    the new instance.


> Maybe there is some piece missing that is need to
> create these objects wherever you wish via DTML?
> 
> Not to confuse the issue, but I've got a slightly
> different situation and a slightly different problem
> (but no luck, either :)
> 
> I have two ZClasses: KMArticleStore and KMArticle.
> There is a method within KMArticleStore that I would
> like to use to create new KMArticles.
> 
> I've tried a few variations to get this to work. Brian
> (Lloyd)'s suggestion
> <dtml-call
> "Control_Panel.Products.Kendermedia.KMArticle_add(REQUEST)">
> 
> Yields a NameError (KMArticle), here:
> Object: KMArticle.createInObjectManager(REQUEST['id'],
> REQUEST)

Eew - this sounds like it comes from the complexity of the
acquisition that is going on.

> 
> I did, at one point, manage to get the article added
> to the Products part of the control panel :)

that's not good :(

> (I think by calling
> Control_Panel.Products.Kendermedia.KMArticle.createInObjectManager
> directly)
> 
> Kevin

Can you post the actual scripting that you're using? It's hard
for me to narrow down what's going on without context...

Brian Lloyd        brian@digicool.com
Software Engineer  540.371.6909              
Digital Creations  http://www.digicool.com