Hi, I'm pretty new to Zope technology. My question is pretty simple. I want to use my product which uses dtml in pylone so I want to rewrite all DTML stuff to ZPT. I found good webresource about it but not all ise clear for me, here is my problem: // 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? 2. In folowing scripts I use <dtml-call "REQUEST.get('img_url')"> or something like this, how should I use it now in ZPT? That's all. Good webpage about dtml2zpt conversion can be found at: http://www.zope.org/Members/peterbe/DTML2ZPT Maciej Lopacinski <hamster@mat.uni.torun.pl> UMK::WMiI::Informatyka
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
Maciej Lopacinski wrote at 2004-5-25 12:55 +0200:
... <dtml-call "REQUEST.set('img_url', images.absolute_url())"> <dtml-call "REQUEST.set('image_db_url', image_db.absolute_url())"> <dtml-call session_init> ... Questions: 1. How should it look in ZPT?
In ZPT, you do not have a large implicit namespace but only a small one with a few predefined variables and whatever variables you defined. Often you use "here.images" or "request/file" where in DTML you just used "images" and "file".
2. In folowing scripts I use <dtml-call "REQUEST.get('img_url')"> or something like this, how should I use it now in ZPT?
"request.get(...)" -- Dieter
participants (3)
-
Chris Withers -
Dieter Maurer -
Maciej Lopacinski