[Zope-dev] RequestContainer ?

Steve Alexander steve@cat-box.net
Fri, 15 Sep 2000 11:13:05 +0100


There's a RequestContainer instance at the top of the acquisition list,
as accessed through aq_parent or through aq_inner.aq_parent.

Previously, with recursive acquisition hacks, you could tell that you
were at the end of the trail because aq_parent returned None.
Unfortunately, RequestContainer doesn't seem to be acquisition-wrapped,
and doesn't support the aq_* attributes.

Here's an external method suggested by Evan Simpson in August, which
doesn't work because of having the RequestContainer at the end of the
trail.

----
def aq_containment(ob):
    context = []
    while ob is not None:
        context.append(ob.aq_base)
        ob = ob.aq_inner.aq_parent
    ob = context.pop()
    while context:
        ob = context.pop().__of__(ob)
    return ob
----

What is the recommended, forwards-compatible way of knowing when to stop
recursively looking through acquisition wrappers?

--
Steve Alexander
Software Engineer
Cat-Box limited
http://www.cat-box.net