[Zope] Re: creating ZClasses with external method

Brian Lloyd Brian@digicool.com
Tue, 13 Jul 1999 12:44:20 -0400


> On Tue, 13 Jul 1999 09:53:00 -0400,
> Brian Lloyd <Brian@digicool.com> said:
> 
>  <snip>
> Brian>   # Create the new instance
> Brian>   newob=self.Control_Panel.Products.Foo.foo(id)
> 
> Brian> It would be better in this case (to avoid hard coding
> Brian> product names and locations) to use 'self' in its initial
> Brian> context (the factory), and defer setting self to this()
> Brian> until after you are done using attributes of the Product/
> Brian> Factory:
> 
> Brian>        # Create the new instance. Here, self is still
> Brian>        # the Factory, which can acquire the ZClass that
> Brian>        # we want to instantiate (foo) from the Product.
> Brian>        newob=self.foo(id)
>  <snip>
> 
> Makes sense, but when I try newob=self.foo(id), I get an 
> AttributeError
> on 'foo'. (I'm working on an external method which is totally outside
> the ZClass's Product, it just has to create a ZClass as a 
> side effect).

Gotcha - then yes, you do need to use the Control_Panel.Products.xxx
way, since the external is outside of a product.


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