This seems to be sort of a newbie question: imagine an URL of: www.domainname.com/something?print=yes inside of the 'something' method, I have this: <dtml-if print=yes> <dtml-var print_html_header> <dtml-else> <dtml-var standard_html_header> </dtml-if> what am I missing?
Hello Stephan,
<dtml-if print=yes>...
You need an expression and "==" not "=": <dtml-if "print=yes"> or <dtml-if "REQUEST.form['print']=yes"> "=" is an assignment Greetings Sven -- Sven Rudolph, Programmierer GermanMedicalServices.de GmbH Unter den Eichen 5, 65195 Wiesbaden Tel.: 06 11 / 97 46 25 2
Arrgghh, I mean: <dtml-if "print==yes"> or <dtml-if "REQUEST.form['print']==yes"> Greetings Sven -- Sven Rudolph, Programmierer GermanMedicalServices.de GmbH Unter den Eichen 5, 65195 Wiesbaden Tel.: 06 11 / 97 46 25 2
<dtml-if "print==yes">
Document Template Parse Error Expression (Python) Syntax error: invalid syntax , for tag <dtml-if "print==yes">, on line 51 of standard_html_header
or <dtml-if "REQUEST.form['print']==yes">
<H2>Site Error</H2> <P>An error was encountered while publishing this resource. </P> <P><STRONG>KeyError</STRONG></P> Sorry, a site error occurred.<p> <!-- Traceback (innermost last): File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 150, in publish_module File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 114, in publish File /usr/local/zope/lib/python/Zope/__init__.py, line 159, in zpublisher_exception_hook (Object: www) File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 98, in publish File /usr/local/zope/lib/python/ZPublisher/mapply.py, line 88, in mapply (Object: index_html) File /usr/local/zope/lib/python/ZPublisher/Publish.py, line 39, in call_object (Object: index_html) File /usr/local/zope/lib/python/OFS/DTMLMethod.py, line 127, in __call__ (Object: index_html) File /usr/local/zope/lib/python/DocumentTemplate/DT_String.py, line 473, in __call__ (Object: index_html) File /usr/local/zope/lib/python/OFS/DTMLMethod.py, line 120, in __call__ (Object: standard_html_header) File /usr/local/zope/lib/python/DocumentTemplate/DT_String.py, line 473, in __call__ (Object: standard_html_header) File /usr/local/zope/lib/python/DocumentTemplate/DT_Util.py, line 159, in eval (Object: REQUEST.form['print']==yes) (Info: REQUEST) File <string>, line 2, in f File /usr/local/zope/lib/python/AccessControl/DTML.py, line 32, in guarded_getitem (Object: index_html) File /usr/local/zope/lib/python/AccessControl/ZopeGuards.py, line 90, in guarded_getitem KeyError: print -->
What works for me, instead of
<dtml-if "print==yes">
or
<dtml-if "REQUEST.form['print']==yes">
is: <dtml-unless "REQUEST.QUERY_STRING=='print'"> When I send an URL with: www.site.com/someobject?print this works fine. I can now exclude browser-related html for printversions
this is still not failsafe in case you ever decide to do other things with query strings. this is failsafe and will always work:: <dtml-if "REQUEST.get('print', '')"> show print view <dtml-else> show normal view </dtml-if> jens On Monday, Sep 30, 2002, at 05:24 US/Eastern, Stephan Goeldi wrote:
What works for me, instead of
<dtml-if "print==yes">
or
<dtml-if "REQUEST.form['print']==yes">
is:
<dtml-unless "REQUEST.QUERY_STRING=='print'">
When I send an URL with: www.site.com/someobject?print
this works fine. I can now exclude browser-related html for printversions
_______________________________________________ Zope maillist - Zope@zope.org 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 )
Jens Vagelpohl wrote:
this is still not failsafe in case you ever decide to do other things with query strings. this is failsafe and will always work::
<dtml-if "REQUEST.get('print', '')"> show print view <dtml-else> show normal view </dtml-if>
Unfortunately, this won't work with Stephan's exact example ;-)
When I send an URL with: www.site.com/someobject?print
...this will always be false in you example. The problem (I'd argue it's a bug, search the archives from about a year and a half ago for more discussion) is that whatever bit of whatever archane publishing thing (I think it's Medusa in this case) turns the query string into the REQUEST.form mapping ignores any query variables that don't have values (as in the example Stephan provided ;-) I'd love to see whatever is causing this bug to cause: www.site.com/someobject?print ...to be mapped into REQUEST as: REQUEST.form['print']=None What do others think? In the meantime, the only way Stephan will get this to work is to butcher QUERY_STRING manually (dodgy, as Jens points out) or use ?print=1 instead. cheers, Chris
On Tue, Oct 01, 2002 at 03:16:43PM +0100, Chris Withers wrote:
Jens Vagelpohl wrote:
[non-valued bits of query string disappearing mysteriously]
www.site.com/someobject?print ...to be mapped into REQUEST as: REQUEST.form['print']=None
What do others think?
Makes a lot of sense (but see below).
In the meantime, the only way Stephan will get this to work is to butcher QUERY_STRING manually (dodgy, as Jens points out) or use ?print=1 instead.
Or even ?render='print' (seems more close to the actual meaning and brings about more flexibility -- maybe `print' *was* a value after all (and not a name) but was too shy to tell ;-) (Excuse me, it's just too early in the morning |-) Cheers -- tomas
participants (5)
-
Chris Withers -
Jens Vagelpohl -
Stephan Goeldi -
Sven Rudolph -
tomas@fabula.de