[Zope] How can I render structured-text from PythonMethods?
Evan Simpson
evan@4-am.com
Mon, 13 Dec 1999 13:12:22 -0600
Pavlos Christoforou wrote:
> I have not used PythonMethods yet but I assume they are like External
> Methods.
Not really. Since they're intended to be as safe as DTML, they aren't
allowed to import.
> On Mon, 13 Dec 1999 itamars@ibm.net wrote:
> > I want to be able to run structured_text and newline_to_br and
> > html_quoute - all the formatting options available in DTML - using
> > PythonMethods. Something like:
> >
> > a = structured_text(self.body)
> >
> > is there any way to do this?
Yes, in version 0.1.7 (just put up) you can access all of the special
dtml-var formats through a builtin dictionary called (surprise!)
special_formats. This allows you to do the following (tested code):
return special_formats['structured-text']('*Hi* _there_')
It's verbose, but if you need to apply one multiple times you can do this:
hq = special_formats['html-quote']
txt1 = hq(txt1)
txt2 = hq(txt2)
#etc
Cheers,
Evan @ 4-am