[Zope] Accessing Documents/Methods/Properties from within External Methods.
Daryl Tester
dt@picknowl.com.au
Sun, 16 Apr 2000 01:26:51 +0930
G'day,
I have a fair bit of processing going on inside of a DTML Method,
so I've decided to migrate the index_html to an External Method.
I would like to leave a fair bit of the document generation to
DTML Documents and Methods, because, what the hey, it does that
best, but I've struck some lack of knowledge in the interfaces
between Zope (ZPublisher?) and Python (mostly due to cluelessness
on my part, but I just don't grok "Using document templates with
ZPublisher" in the DTML guide). I'll dissect my problems in
piecemeal fashion:
def index_html(self, REQUEST, RESPONSE):
"'Ere we go, 'ere we go ..."
res = [] # Just so you know what res.append() is up to.
Since I don't get a chance to pass these parameters in explicitly
(eg if called by "http:/foo.com/bar/"), can I assume the underlying
Zope machinery will _always_ fill these in for me?
doc = self.getattr('standard_html_header') # Easy enough
res.append(doc(self, REQUEST))
Can of worms time. I feel uneasy with the parameters to
standard_html_header, as with the examples from DTML it is usually
called with (_.None, _), so I've tried (None, self) as parameters
as well. Both work. Which is the correct parameter order when
calling a DTML Method/Document? Are python's self (as passed in)
and DTML's "_" interchangeable? Certainly, self on its own as a
parameter doesn't work, and causes an authentication challange, of
all things (which usually fails).
Finally, getattr won't always return a callable object (say, in the
case of 'title_or_id'), but I won't know that in advance. Is there
an attribute I can test for that determines when to call it, and
when to just str() it (and are there conditions that fall outside
of these two that I've listed)?
Be gentle with me. :-)
Regards,
Daryl Tester