Brad Allen wrote:

At 11:48 AM +0100 12/1/05, Johan Carlsson wrote:

The ZAPI interface gives you several ways to traverse object
from a context:
For instance getParent, (getParents,) getRoot, traverse, (traverseName)

On my first reading of your posting, I missed "getRoot".
That sounds promising. If I can get the root of the ZODB
then I can use traversal to get to any other object in
the ZODB.

However, getRoot takes an argument. The example in
Philikon's book uses a Location(). I don't think this gets
me the root of the ZODB, does it?

Without checking I think getRoot only does an "inverse travers"
similare to what acquisition would have done in Zope 2.

It takes a object (that should support the ILocation, which
defines the __parent__ attribute, without it you wouldn't be
able to climb back up :-)

E.g. what you most likely would pass is the context (which most
likely will be the object your accessing (through a request of some kind).

As I have mentioned before, in the normal case your probalby
are writing a BrowserView class or an adapter (that will
have a context object) and it will be very likely this
content object is some kind of Content Type object, e.g.
something that probably exists in the ZODB.
(A lot of probabilities :-)

There is another way to get to object though,
through the registry and in most cases you would look
up a Utility. Now utilities will not necessary be a
a ZODB object, but if they are  local utility they are :-)

One of the hardest things to learn about Zope 3 is that
there always is a BrowserView class even if you never
code it in Python. Because it's hidden in the ZCML,
such as the EditView.

Personally I'm trying to avoid high-level ZCML statements,
or at least alway implement a BrowserView, it make think
much clearer in my mine, more explicit :-)


Johan Carlsson          Tel: + 46 8 31 24 94
Colliberty              Mob: + 46 70 558 25 24
Torsgatan 72            Email: [EMAIL PROTECTED]
Zope3-users mailing list

Reply via email to