Re: [Zope] Could Someone Clean This DTML Up?
| OdesÃlatel: Martin Gebert <Murphy@members.netsolution-net.de> | > <dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE')"> | > <dtml-in expr="context.objectsInTheFolder"> | > <dtml-if expr="&dtml-id==&dtml-lang"> | > <dtml-let approved="&dtml-lang"> | > <dtml-else> | > <dtml-let approved="en-us"> | > </dtml-if> | > </dtml-in> | > </dtml-let> | | First of all, terminate all &dtml entities by a semicolon. | | Second, dtml-let needs a closing tag. This tag can't be outside of the | DTML hierarchy the opening tag is in, which means that if you define a | variable inside of a dtml-if, you have to close it inside, too, and the | value is lost for further use. Shortly: this won't work, try another way. | | Third, IMHO it doesn't make sense to extract values from variables | inside a Python expression per DTML entities, try "id == lang" in line | 3, and correct line 4 accordingly (your DTML namespace will be correctly | looked up inside the expressions, you don't need the &dtml-...; part). | | Point four: would it be possible that this could be better done in a script? DTML: <dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE')"> <dtml-in expr="context.objectsInTheFolder"> <dtml-if expr="&dtml-id==&dtml-lang"> <dtml-call "REQUEST.set('approved', ['lang'])"> <dtml-else> <dtml-call "REQUEST.set('approved', 'en-us')"> </dtml-if> </dtml-in> </dtml-let> Regards JL.
At 02:28 PM 1/6/2003 +0000, you wrote:
<dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE')"> <dtml-in expr="context.objectsInTheFolder"> <dtml-if expr="&dtml-id==&dtml-lang"> <dtml-call "REQUEST.set('approved', ['lang'])"> <dtml-else> <dtml-call "REQUEST.set('approved', 'en-us')"> </dtml-if> </dtml-in> </dtml-let>
There were a couple of seeming syntax errors in here that made the compiler hiccup, specifically double-quoting in line #3, but the real reason I'm writing back is I know darn well that *objectsInTheFolder* isn't how you call objects in the current container. How do I do that? TIA, beno <dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE')"> <dtml-in expr="context.objectsInTheFolder"> <dtml-if expr="'&dtml-id;'=='&dtml-lang;'"> <dtml-call "REQUEST.set('approved', ['lang'])"> <dtml-else> <dtml-call "REQUEST.set('approved', 'en-us')"> </dtml-if> </dtml-in> </dtml-let>
<dtml-in objectValues> will loop you the the objects in the current container beno wrote:
At 02:28 PM 1/6/2003 +0000, you wrote:
<dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE')"> <dtml-in expr="context.objectsInTheFolder"> <dtml-if expr="&dtml-id==&dtml-lang"> <dtml-call "REQUEST.set('approved', ['lang'])"> <dtml-else> <dtml-call "REQUEST.set('approved', 'en-us')"> </dtml-if> </dtml-in> </dtml-let>
There were a couple of seeming syntax errors in here that made the compiler hiccup, specifically double-quoting in line #3, but the real reason I'm writing back is I know darn well that *objectsInTheFolder* isn't how you call objects in the current container. How do I do that? TIA, beno
<dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE')"> <dtml-in expr="context.objectsInTheFolder"> <dtml-if expr="'&dtml-id;'=='&dtml-lang;'"> <dtml-call "REQUEST.set('approved', ['lang'])"> <dtml-else> <dtml-call "REQUEST.set('approved', 'en-us')"> </dtml-if> </dtml-in> </dtml-let>
_______________________________________________ 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 )
At 07:06 PM 1/6/2003 +0000, you wrote:
<dtml-in objectValues> will loop you the the objects in the current container
By way of trouble-shooting, I threw in a couple of <dtml-var> tags to print stuff to screen. *lang* prints: *id* doesn't. Therefore, the loop isn't functioning. There must be a problem with the calling variable *objectValues*. I've tried all sorts of ways around this to no avail. Further suggestions? TIA, beno <dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE')"> <dtml-var lang> <dtml-in objectValues> <dtml-var id> <dtml-if expr="'&dtml-id;'=='&dtml-lang;'"> <dtml-call "REQUEST.set('approved', ['lang'])"> <dtml-var approved> <dtml-else> <dtml-call "REQUEST.set('approved', 'en')"> <dtml-var approved> </dtml-if> </dtml-in> </dtml-let>
beno wrote:
At 02:28 PM 1/6/2003 +0000, you wrote:
<dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE')"> <dtml-in expr="context.objectsInTheFolder"> <dtml-if expr="&dtml-id==&dtml-lang"> <dtml-call "REQUEST.set('approved', ['lang'])"> <dtml-else> <dtml-call "REQUEST.set('approved', 'en-us')"> </dtml-if> </dtml-in> </dtml-let>
There were a couple of seeming syntax errors in here that made the compiler hiccup, specifically double-quoting in line #3, but the real reason I'm writing back is I know darn well that *objectsInTheFolder* isn't how you call objects in the current container. How do I do that? TIA, beno <dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE')"> <dtml-in expr="context.objectsInTheFolder"> <dtml-if expr="'&dtml-id;'=='&dtml-lang;'"> <dtml-call "REQUEST.set('approved', ['lang'])"> <dtml-else> <dtml-call "REQUEST.set('approved', 'en-us')"> </dtml-if> </dtml-in> </dtml-let>
_______________________________________________ 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 )
beno wrote:
At 02:28 PM 1/6/2003 +0000, you wrote:
There were a couple of seeming syntax errors in here that made the compiler hiccup, specifically double-quoting in line #3, but the real reason I'm writing back is I know darn well that *objectsInTheFolder* isn't how you call objects in the current container. How do I do that? TIA, beno
<dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE')"> <dtml-in expr="context.objectsInTheFolder"> <dtml-if expr="'&dtml-id;'=='&dtml-lang;'"> <dtml-call "REQUEST.set('approved', ['lang'])"> <dtml-else> <dtml-call "REQUEST.set('approved', 'en-us')"> </dtml-if> </dtml-in> </dtml-let>
Hi, you should change
<dtml-in expr="context.objectsInTheFolder">
to: <dtml-in objectValues> and
<dtml-if expr="'&dtml-id;'=='&dtml-lang;'">
to: <dtml-if expr="getId()==lang"> You cannot nest dtml in dtml. And: Read THE ZOPE-BOOK!!! -mj
At 02:28 PM 1/6/2003 +0000, you wrote:
| OdesÃlatel: Martin Gebert <Murphy@members.netsolution-net.de> | > <dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE')"> | > <dtml-in expr="context.objectsInTheFolder"> | > <dtml-if expr="&dtml-id==&dtml-lang"> | > <dtml-let approved="&dtml-lang"> | > <dtml-else> | > <dtml-let approved="en-us"> | > </dtml-if> | > </dtml-in> | > </dtml-let> | | First of all, terminate all &dtml entities by a semicolon. | | Second, dtml-let needs a closing tag. This tag can't be outside of the | DTML hierarchy the opening tag is in, which means that if you define a | variable inside of a dtml-if, you have to close it inside, too, and the | value is lost for further use. Shortly: this won't work, try another way. | | Third, IMHO it doesn't make sense to extract values from variables | inside a Python expression per DTML entities, try "id == lang" in line | 3, and correct line 4 accordingly (your DTML namespace will be correctly | looked up inside the expressions, you don't need the &dtml-...; part). | | Point four: would it be possible that this could be better done in a script?
DTML:
<dtml-let lang="REQUEST.get('HTTP_ACCEPT_LANGUAGE')"> <dtml-in expr="context.objectsInTheFolder"> <dtml-if expr="&dtml-id==&dtml-lang"> <dtml-call "REQUEST.set('approved', ['lang'])"> <dtml-else> <dtml-call "REQUEST.set('approved', 'en-us')"> </dtml-if> </dtml-in> </dtml-let>
Well, not quite. Lines 2 & 3: <dtml-in expr="context.objectValues"> <dtml-if expr="&dtml-objectValue;==&dtml-lang;"> Thanks, though! beno
participants (4)
-
Ben Avery -
beno -
Jaroslav Lukesh -
Maik Jablonski