[Zope] Python/Zope API
Kapil Thangavelu
kvthan@wm.edu
Mon, 31 Jul 2000 08:10:48 -0700
"Alexandre A. Rodioukov" wrote:
>
> Kapil Thangavelu <kvthan@wm.edu> writes:
>
> > > 2. Are there ways to improve it? For example I would love to know how
> > > you can check if you can actually render an object. (For example
> > > you can not render Control_Panel).
> >
> > To render your python product objects in Zope like
> > <dtml-var yourObject>
> > you just define a method __str__
>
> I probably wasn't clear enough describing the issue :) I don't want to
> render Product, i want to make Zope to render some object from ZODB
> from python... i.e. to obtain rendered HTML code of some dtml
> document/method from external python method for filtering/doing some
> magic :) purposes.
Yikes, its __call__ that gets rendered not __str__.
About your question... you still want to call __call__ :)
ala dtml_code_to_be_rendered() from within python. if you're accessing
any other zope elements that are not native to it(likely) you will need
to pass in the proper namespace and methods. Something along the lines
dtcbr(client, namespace, request, response, *). you can safely leave
most of these blank. the keys ones in this context are probably
namespace and client.
i played around with this and got rendering simple pages but nothing
with other zope objects.
take a look at the source for more inspiration.
Zope/lib/python/OFS/DTMLDocument.py
and HTML class.
Hope that helps
Kapil