[Zope] (no subject)

Karl Anderson karl@digicool.com
14 Jul 2000 14:40:12 -0700


"Leichtman, David J" <code@ou.edu> writes:

> I've previously been a Perl programmer. I did a lot of stuff where I would
> have multiple links with different options.
> Ex.
> 
> <a href="/path/script.pl/1234">1234</a><br>
> <a href="/path/script.pl/2345">2345</a><br>
> 
> Then, in script.pl, I would pick up the extra info on the other side from
> $PATH_INFO.
> 
> The problem in Zope is that there is no "end" to the address. Serving from
> Apache, it knows that the .pl extension is the end of the path. If there's a
> '/' and more after it, it will push it to PATH_INFO. So how do you do this
> in Zope? Because it's object names instead of paths in the request, how do
> you send optional, additional info through the request as above?

You've answered your own question.  There is no end in the middle of
the path.  The publisher picks off each part of the URL from the top
down, and at each step, it asks that object if it can provide the next
one.  Look at traverse() in lib/python/ZPublisher/BaseRequest.py, or
step through the publishing process - see
<http://www.zope.org/Members/michel/HowTos/TheDebuggerIsYourFriend>.

At each step, the publisher checks to see if the parent has the child
as an attribute, and if so, continues with the object at that
attribute as the parent (so long as other conditions are met, like
permissions).

You can see this in python products:

class Foo:
 "a python product"
 ...
 index_html = HTMLFile("someDTMLFile", globals())
 index2_html = "<HEAD><BODY>..."
 index3_html = aFunction(mood, phaseOfMoon)

Since getattr(path.to.foo, "index_html") reaches that html file,
ZPublisher.Zope("/path/to/foo/index_html") publishes that file.
index_html could be a (badly named) method instead, which has other
attributes.  It could decide what to publish or how to allow
the publisher to traverse the path programmatically.

You don't need extra rules that look for foo.pl in the URL (what a
kluge - enforce a perl script to sit there until URLs are no more!).
For your example, script.pl could have two subobjects or other
attributes, 1234 and 2345, and the default index_html.  Or script.pl
could be a ZClass with those three as DTML methods or other
subobjects.

__bobo_traverse__ is another attribute that the object may have to
drive the publishing process, but I haven't needed to understand why
it's useful yet :)

-- 
Karl Anderson                          karl@digicool.com