[Zope] Getting the correct domain at add time.

Dieter Maurer dieter at handshake.de
Tue Nov 25 15:57:34 EST 2003


Terry Hancock wrote at 2003-11-25 09:59 -0600:
 > ...
 > However,
 > absolute_url() seems not to work as I would expect it to
 > ...
 > in my product code:

 > def manage_addTopic(self, id, title='', REQUEST=None):
 > ...
 >     self._setObject(id, ob)
 >     ob=self._getOb(id)
 >     ob.topic_domain = urlparse.urlparse(ob.absolute_url())[1]
 > ...

 > I think the problem may only occur when this manage_addTopic
 > is called from another manage_addFoo function, but I'm not
 > positive about that.

Almost surely, you are right with this. See below.
 >   File /usr/local/narya/z2.5.1/lib/python/OFS/Traversable.py, line 36, in absolute_url
 >     (Object: Narya)
 > AttributeError: get

This means, "absolute_url" is unable to acquire "REQUEST".
This happens when the "acquisition chain" is not complete.

Note, that newly constructed objects are not yet acquisition wrapped.
The get (usually) wrapped by:

    container._setObject(id, newObject)
    newObject = container._getOb(id) # now wrapped

-- 
Dieter



More information about the Zope mailing list