Re: [Zope] Python/Zope API

2000-07-31 Thread Kapil Thangavelu

"Alexandre A. Rodioukov" wrote:
> 
> Kapil Thangavelu <[EMAIL PROTECTED]> 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
> > 
> > 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

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )




Re: [Zope] Python/Zope API

2000-07-31 Thread Kapil Thangavelu

> 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

you just define a method __str__

take a look at python code for the base ZClass Renderable

probably the easiest thing to do in your python product

install renderable

in your python file 

import Renderable

and add Renderable as base class.

if you want have the display html in python you can do an extended
python string ''' '''

and define a method render that returns it

or use the HTMLFile and Globals (ala most Zope Products) and do it as an
html file

Cheers

Kapil

"Alexandre A. Rodioukov" wrote:
> 
> Hello folks.
> 
> I want to be able to render Zope objects from my python external
> method/product. Idea is to use it to render parent object. Here is
> code I came up so far with:
> 
> def view(self, REQUEST):
> if self.meta_type == 'Folder':
> doc = self.aq_base.index_html(self, self.REQUEST)
> else:
> doc = self.aq_base(self, self.REQUEST)
> return doc
> 
> It does return rendered parent object, but I have some questions and
> probably request for improvement ideas :)
> 
> 1. The whole thing becomes broken with SiteAccess. Complains about
>premissions/PhysicalRoot (AFAIR)
> 
> 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).
> 
> Possible use for it (to make the whole idea a bit clearer)
> 
> /index_html (some stuff in it)
> /view (above code in external method)
> 
> /index_html/view returns rendered index_html doing some magic with
> HTML/whatever is in it (for example encrypts it with public key, strips
> down carriage returns/tabs/spaces etc...) In other words acts as a
> filter.
> 
> Thanks for any advice,
> 
> Regards, Simuran.
> 
> ___
> Zope maillist  -  [EMAIL PROTECTED]
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists -
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )

___
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )