I have a zclass which defines articles with a 'location' field. (ie. location = 'Portal.Publications.Review'). My problem is that the articles are located in a certain area but need to show in the 'location' specified. I don't understand why this code works: <dtml-with "Portal.Publications.Review"> <p>This is the <dtml-var document_id> Document in the <dtml-var title_and_id> Folder.</p> </dtml-with> While this code does not work: <dtml-with "_['location']"> <p>This is the <dtml-var document_id> Document in the <dtml-var title_and_id> Folder.</p> </dtml-with> Any ideas? ===== --------------------------- Adrian Esteban Madrid Benson Institute, Webmaster Brigham Young University --------------------------- adrian_esteban@madrid.com =========================== __________________________________________________ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/
Adrian, Adrian Madrid <aemadrid@yahoo.com> wrote:
<dtml-with "Portal.Publications.Review"> <p>This is the <dtml-var document_id> Document in the <dtml-var title_and_id> Folder.</p> </dtml-with>
<dtml-with "_['location']"> <p>This is the <dtml-var document_id> Document in the <dtml-var title_and_id> Folder.</p> </dtml-with>
All, please correct me if I'm writing bullshit ;-) <dtml-with "_['location']"> gives you the string "Portal.Publications.Review", while <dtml-with "Portal.Publications.Review"> gives you the actual resolved object. So, what might do the trick could be <dtml-with "_.getitem('location')"> It might be helpful to remember that using double quotes really means expr="". That is why your first example gives you the object that resolves to the name, while the second will resolve the expresion and give you the string contained in 'location'. Cheers, Ben -- Ben Peter - Feldstrasse 8 - 35091 Coelbe Ben.Peter@t-online.de ph: (+49) 6421 983520
Adrian, I did write bullshit. Ben.Peter@t-online.de (Ben Peter) wrote:
<dtml-with "_['location']"> gives you the string "Portal.Publications.Review", while
<dtml-with "Portal.Publications.Review"> gives you the actual resolved object.
This is still true, but:
<dtml-with "_.getitem('location')">
wont't give you more than the string "Portal.Publications.Review" either. So, what you want is: <dtml-with "_.getitem(_.getitem('location'))"> The inner _.getitem('location') will yield the string "Portal.Publications.Review". The outer _.getitem will then give you the actual object. Sorry for the confusion. Cheers, Ben -- Ben Peter - Feldstrasse 8 - 35091 Coelbe Ben.Peter@t-online.de ph: (+49) 6421 983520
Ben Peter wrote:
Adrian,
Adrian Madrid <aemadrid@yahoo.com> wrote:
<dtml-with "Portal.Publications.Review"> <p>This is the <dtml-var document_id> Document in the <dtml-var title_and_id> Folder.</p> </dtml-with>
<dtml-with "_['location']"> <p>This is the <dtml-var document_id> Document in the <dtml-var title_and_id> Folder.</p> </dtml-with>
All, please correct me if I'm writing bullshit ;-)
<dtml-with "_['location']"> gives you the string "Portal.Publications.Review", while
<dtml-with "Portal.Publications.Review"> gives you the actual resolved object.
So, what might do the trick could be
<dtml-with "_.getitem('location')">
It might be helpful to remember that using double quotes really means expr="". That is why your first example gives you the object that resolves to the name, while the second will resolve the expresion and give you the string contained in 'location'.
Cheers, Ben
You are correct that _.getitem() should work. The main difference is that _[] calls the object (if it is callable) and getitem() just returns the object as is. -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
Hi, this is a common understanding problem. To get a feeling whats bad, try to start the python interpreter and type in the following: class dummy: def __getitem__(self,key): return(getattr(self,key)) # two newlines here a=dummy() b=dummy() c=dummy() b.c=c a.b=b you now can access c thru a and b like this: a.b.c or a['b']['c'] but you cannot use a['b.c'] to access c, since the objects names are 'b' and 'c' and not 'b.c' HTH Tino Wildenhain --On Donnerstag, 19. April 2001 17:39 -0700 Adrian Madrid <aemadrid@yahoo.com> wrote:
I have a zclass which defines articles with a 'location' field. (ie. location = 'Portal.Publications.Review'). My problem is that the articles are located in a certain area but need to show in the 'location' specified. I don't understand why this code works:
<dtml-with "Portal.Publications.Review"> <p>This is the <dtml-var document_id> Document in the <dtml-var title_and_id> Folder.</p> </dtml-with>
While this code does not work:
<dtml-with "_['location']"> <p>This is the <dtml-var document_id> Document in the <dtml-var title_and_id> Folder.</p> </dtml-with>
Any ideas?
===== --------------------------- Adrian Esteban Madrid Benson Institute, Webmaster Brigham Young University --------------------------- adrian_esteban@madrid.com ===========================
__________________________________________________ Do You Yahoo!? Yahoo! Auctions - buy the things you want at great prices http://auctions.yahoo.com/
_______________________________________________ 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 )
Adrian Madrid wrote:
I have a zclass which defines articles with a 'location' field. (ie. location = 'Portal.Publications.Review'). My problem is that the articles are located in a certain area but need to show in the 'location' specified. I don't understand why this code works:
<dtml-with "Portal.Publications.Review"> <p>This is the <dtml-var document_id> Document in the <dtml-var title_and_id> Folder.</p> </dtml-with>
While this code does not work:
<dtml-with "_['location']"> <p>This is the <dtml-var document_id> Document in the <dtml-var title_and_id> Folder.</p> </dtml-with>
Any ideas?
Portal.Publications.Review is being passed as an expression in your first example, not a string. You cannot pass expressions in string variables in DTML. To resolve objects given a path use: <dtml-with expr="REQUEST.resolve_url('/Portal/Publication/Review')"> You could also pass a variable here as in: <dtml-with expr="REQUEST.resolve_url(location)"> hth, -- | Casey Duncan | Kaivo, Inc. | cduncan@kaivo.com `------------------>
Casey, In the API Reference in the Zope Book, resolve_url() in the REQUEST class is not documented. Is this information available somewhere else, and should a request in the book's sourceforge trackers be made to have this included? Ben Casey Duncan <cduncan@kaivo.com> wrote:
variables in DTML. To resolve objects given a path use:
<dtml-with expr="REQUEST.resolve_url('/Portal/Publication/Review')">
You could also pass a variable here as in:
<dtml-with expr="REQUEST.resolve_url(location)">
Cheers, Ben -- Ben Peter - Feldstrasse 8 - 35091 Coelbe Ben.Peter@t-online.de ph: (+49) 6421 983520
participants (4)
-
Adrian Madrid -
Ben.Peter@t-online.de -
Casey Duncan -
Tino Wildenhain