[Zope-dev] more __call__ ...

Chris Withers chrisw@nipltd.com
Tue, 26 Sep 2000 16:55:18 +0100


Jim Fulton wrote:
> > So, if I give my product a class attribute of isDocTemp=1, what
> > signature should I give my product's __call__ method so it picks up the
> > DTML namespace?
> 
>   def __call__(self, ignored, md): ...

Right, now if I call other DTML methods from my __call__ method, can I
just call them with:

self.nav_header(self, ignored, md)?

In any case, what is self in __call__(self, ...) and what should it be
in nav_header(self, ...)?

> > expecting it to print the id of myDocument. Is this me misunderstanding
> > what the 'client' is,
> 
> Yes.

Fair enough... I think what I meant was whatever the object that
<dtml-var "this()"> would return if that occurend in the
standard_html_header method.

> > In either case, what do I need to go to get hold of what would be
> > PARENTS[0-1], if you see what I mean?
> 
> I don't see what you mean.

http://a.site/folder/object/myobject

myobject contains <dtml-var standard_html_header>
standard_html_header contains <dtml-var mynavigator>

__call__ is a method of the Navigator product, of which mynavigator is
an instance.

Anyway, in that __call__, self.REQUEST.PARENTS =
[zope-app,folder,object] (roughly)

By PARENTS[0-1], I meant the myobject object, itself.

Hurm, I'm finding this hard to explain clearly, let me know if I'm
getting closer :-S

> I think that if you say:
> 
>   <dtml-var expr="foo.bar">
> 
> that foo's namespace should take precedence over
> the DTML namespace,

Okay, I see what you mean now :-)

> > render?
> 
> Well, a number of people have suggested that there should
> be a separate render (ie call as subtemlpate) interface.
> Maybe that's what what you meant.    

Nope... DT_Var.py line 258:
	def render(self, md):
...is what I think the people who mentioned it to me were talking about.

>   http://site.com/foo/bar
> 
>   <dtml-var expr="foo.bar">
> in http://site.com/zoo/splat.
> 
> In the former case, foo's namespace is
> at the top of the stack and, in the second case,
> it's not on the stack.

Okay, that clears it up :-)

> > PS: What I'm actually looking for out of all of this is the
> > getPhysicalPath() of the final object that was traversed through the
> > URL.
> > e.g: If the URL was http://www.nipltd.com/folder/somethingelse/myobject,
> > I'm looking for something like:
> > [<Application Instance at 0x000000> (Zope) , <Folder Instance at
> > 0x000000> (folder) , <DTMLDocument Instance at 0x000000> (myobject)]
> 
> getPhysicalPath returns a list of strings, not objects.

d'Oh!

> > If there's an easier way to get this from within the __call__ method of
> > a python product, someone PLEASE tell me! ;-)
> 
> aq_chain(x, 1)[-1:] should give this to you, I believe, or
> be very close. :)

Won't that just return x? (hmm... does aq_chain return
[child,...,parent] or [parent,...,child]?)

I think the hard part fo the problem I'm trying to solve is finding out
what x is from within the __call__ method.

Any help muchly appreciated, sorry this is takign such a long time to
sort out in my head... ;-)

cheers,

Chris