[Zope] Product initilization, acquisition and instance refere nces

Dylan Reinhardt zope at dylanreinhardt.com
Thu Sep 11 15:41:47 EDT 2003


On Thu, 2003-09-11 at 06:31, Jean-Francois.Doyon at CCRS.NRCan.gc.ca wrote:
> The problem is that outside of zope "connection" is an instance of another
> class ("Connection") ... _getfeatureinfo() which is called by edit which is
> called by __init__ needs that instance in order to do some work. But I can't
> get that instance because getattr doesn't find it !! (Even though it is
> there, in the same folder, available to be acquired)

Without seeing the code that breaks or being able to play with it... 

The first thing I'd try is using restrictedTraverse() instead of
getattr().  That may just do the trick.

Another easy thing I would try is using this same process to extract an
attribute of a built-in object.  If that fails in the same way, we at
least know we're troubleshooting the correct object.

Then it gets more difficult.  Some things are tough to do during product
initialization.  I'm a bit fuzzy on the details so I won't try to
explain.  It's also possible that you're using getattr in a way that
Acquisition context has been lost... maybe this is a case where the
magic __of__() method needs to be used to provide a Acquisition wrapper.

If those ideas don't work, are you getting any tracebacks?  When an item
isn't found, what happens?

HTH,

Dylan





More information about the Zope mailing list