[Zope] Re: creating ZClasses with external method
Alex Rice
alrice@swcp.com
Tue, 13 Jul 1999 10:07:25 -0600 (MDT)
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).
Brian> The gory details of how this stuff works can be found in
Brian> the App package in Zope (Product, Factory, FactoryDispatcher,
Brian> etc.) Hopefully this explanation helps a bit - let me know
Brian> if it did more harm than good, and maybe I can get Jim to
Brian> explain it better... :^)
Yes, this does help out. I shall take a look at the App package.
Thanks,
Alex Rice | alrice@swcp.com | http://www.swcp.com/~alrice
Current Location: N. Rio Grande Bioregion, Southwestern USA