[Zope] DTML2ZPT
Chris Withers
chris at simplistix.co.uk
Tue May 25 12:58:52 EDT 2004
Maciej Lopacinski wrote:
> // dtml
> <dtml-call "RESPONSE.setHeader('Content-Type', 'text/html;
> charset=utf-8')">
> <dtml-call "REQUEST.set('img_url', images.absolute_url())">
> <dtml-call "REQUEST.set('image_db_url', image_db.absolute_url())">
> <dtml-call session_init>
>
> // end
> first line is pretty easy to change
> in second and third images amd image_db are local fs instances
> session_init is DTML Method,
>
> Questions:
> 1. How should it look in ZPT?
You shouldn't, the above should become a "Script (Python)":
r = context.REQUEST
r.setHeader('Content-Type', 'text/html;charset=utf-8')
r.set('img_url',context.images.absolute_url())
r.set('image_db_url', context.image_db.absolute_url())
context.session_init(context,REQUEST)
...now, I'd like to see the code for the session_init method since I'm pretty
damn sure you don't need to be putting anything into the REQUEST bar the
setHeader...
> 2. In folowing scripts I use <dtml-call "REQUEST.get('img_url')"> or
> something like this, how should I use it now in ZPT?
Eeep... hmm, well, as a start, you can get at it like:
<img href="" tal:attributes="href string:${request/img_url}/your_image_name.gif">
That said, I think I see what you're doing now, and you can probably, instead of
your lump of dtml above do:
<html tal:define="dummy python:request.RESPONSE.setHeader('Content-Type',
'text/html;charset=utf-8');
img_url here/images/absolute_url;
image_db_url here/image_db/absolute_url;
dummy here/session_init;">
<!-- whatever you want in here -->
</html>
cheers,
Chris
--
Simplistix - Content Management, Zope & Python Consulting
- http://www.simplistix.co.uk
More information about the Zope
mailing list