- Referring to URL pieces within Z Publisher/DTML
I'm using Z Publisher to publish an object and using DocumentTemplate to render the results. Things were working fine until I tried to build a URL in the output. My template currently contains <form action="<!--#var URL0-->" method=GET> but I'm getting a KeyError: Traceback (innermost last): blah, blah, blah File /usr/local/lib/automatrix/python/showcal.py, line 184, in __call__ File /home/dolphin/skip/src/Zope-1.9.0b3-src/lib/python/DocumentTemplate/DT_String.py, line 514, in __call__ (Object: <string>) KeyError: URL0 The document template is defined as a class variable, template, and called as return self.template(month=month, year=year, cal=cal, hint=hint, REQUEST=REQUEST) I've tried replacing <!--#var URL0--> with several different alternatives <!--#var SERVER_NAME--> <!--#var REQUEST['SERVER_NAME']--> <!--#var expr="REQUEST['URL0']"--> but none worked. What is available to me within a simple Z Publisher environment? For now I'm explicitly passing in a value, however the DTML documentation suggests (http://www.digicool.com/site/Principia/DTML.html/DTML.html#41409) that URL0 and several other variables should be available. Is this true only within Zope? Skip Montanaro | Mojam: "Uniting the World of Music" http://www.mojam.com/ skip@calendar.com | Musi-Cal: http://concerts.calendar.com/ 518-372-5583
On Sat, 19 Dec 1998 skip@calendar.com wrote:
return self.template(month=month, year=year, cal=cal, hint=hint, REQUEST=REQUEST)
I'm not sure if it's not something like return self.template(REQUEST,month=mont,year=year,cal=cal, hint=hint) you want.
I've tried replacing <!--#var URL0--> with several different alternatives
I'd guess that perhaps: <!--#with REQUEST mapping--> <!--#var URL0 url_quote--> <!--#/with--> should work. Andreas -- Win95: n., A huge annoying boot virus that causes random spontaneous system crashes, usually just before saving a massive project. Easily cured by UNIX. See also MS-DOS, IBM-DOS, DR-DOS, Win 3.x, Win98.
On Sat, 19 Dec 1998 skip@calendar.com wrote:
return self.template(month=month, year=year, cal=cal, hint=hint, REQUEST=REQUEST)
I'm not sure if it's not something like return self.template(REQUEST,month=mont,year=year,cal=cal, hint=hint) you want.
I've tried replacing <!--#var URL0--> with several different alternatives
I'd guess that perhaps: <!--#with REQUEST mapping--> <!--#var URL0 url_quote--> <!--#/with-->
should work. You don't need the <!--#with REQUEST mapping-->
return self.template(REQUEST,month=mont,year=year,cal=cal,hint=hint) where you can reference REQUEST attributes directly in your template: <!--#var URL0--> Pavlos
Me: return self.template(month=month, year=year, cal=cal, hint=hint, REQUEST=REQUEST) Andreas: return self.template(REQUEST,month=mont,year=year,cal=cal, hint=hint) Thanks, I'll give it a try, however, I don't understand what the difference in the function calls is. Why should it matter that REQUEST is the first argument (and called without using keyword syntax), given that I've explicitly named the formal parameter to which I want the REQUEST object bound? Skip
On Sat, 19 Dec 1998 skip@calendar.com wrote:
Me: return self.template(month=month, year=year, cal=cal, hint=hint, REQUEST=REQUEST)
Andreas:
return self.template(REQUEST,month=mont,year=year,cal=cal, hint=hint)
Thanks, I'll give it a try, however, I don't understand what the difference in the function calls is. Why should it matter that REQUEST is the first argument (and called without using keyword syntax), given that I've explicitly named the formal parameter to which I want the REQUEST object bound?
The first argument is used as a mapping argument. Curiosly, if you have: x=HTMLFile("abc",x,y=y)(X,Y=Y) Then x and X are treated differently: x can only be a mapping. X may be a mapping or object, as it also queried with getattr(). At least that's what I've experienced. Andreas -- Win95: n., A huge annoying boot virus that causes random spontaneous system crashes, usually just before saving a massive project. Easily cured by UNIX. See also MS-DOS, IBM-DOS, DR-DOS, Win 3.x, Win98.
participants (3)
-
Andreas Kostyrka -
Pavlos Christoforou -
skip@calendar.com