object property which has name defined in variable
Dear all, It is unbelievable, but I does not know how to show title property from object defined in variable like this example: <dtml-let picture="'z4_03_2.jpg'"> <dtml-var "_['picture'].title"> </dtml-let> It returns <built-in method title of string object at 02EB8730> but <dtml-var "_['z4_03_2.jpg'].title"> returns real title from object named z4_03_2.jpg. I am very sorry for this basic question. Many thanks and Best Regards, J. Lukesh
Jaroslav Lukesh wrote:
It is unbelievable, but I does not know how to show title property from object defined in variable like this example:
<dtml-let picture="'z4_03_2.jpg'"> <dtml-var "_['picture'].title"> </dtml-let>
It returns <built-in method title of string object at 02EB8730>
but <dtml-var "_['z4_03_2.jpg'].title"> returns real title from object named z4_03_2.jpg.
Watch your syntax! In example 1 you assign a string to a variable 'picture' and then ask for the title of the variable named 'picture' (a string), which obviously doesn't work. Drop the single quotes and you'll assign an instance rather than a string. --jcc -- "My point and period will be throughly wrought, Or well or ill, as this day's battle's fought."
Jaroslav Lukesh wrote at 2003-11-17 20:05 +0100:
It is unbelievable, but I does not know how to show title property from object defined in variable like this example:
<dtml-let picture="'z4_03_2.jpg'"> <dtml-var "_['picture'].title">
<dtml-var expr="_.getitem(picture).title"> Reading the "Name Lookup" section in <http://www.dieter.handshake.de/pyprojects/zope/book/chap3.html> make help you with similar questions. -- Dieter
participants (3)
-
Dieter Maurer -
J. Cameron Cooper -
Jaroslav Lukesh