How to insert variable from expression?
Hi all, I have file#(DTML Document), that have image with same name, but with extension for image type. file1 file1.gif file2 file3 file3.gif So what Can I do insert image with that composite filename? And if missing, insert nothing. <dtml-in.....(DTML Document)...> ....... <dtml-var expr="_['id'] + '.gif'" missing> ??? </dtml-in> It insert filename.gif only,no picture. render(_['id'] + '.gif') does not work, wrong syntax? I was read "Basic COncepts" (aka book3) chapter 4.2.1 (Computed Object access), example 3.5 and _[prefix + 'suffix'] does not work :( Many thanks Jaroslav Lukesh
Perhaps <dtml-var "_.getattr(id+'.gif')">? On Fri, 12 Jul 2002, Jaroslav Lukesh wrote:
Hi all,
I have file#(DTML Document), that have image with same name, but with extension for image type.
file1 file1.gif file2 file3 file3.gif
So what Can I do insert image with that composite filename? And if missing, insert nothing.
<dtml-in.....(DTML Document)...> ....... <dtml-var expr="_['id'] + '.gif'" missing> ??? </dtml-in>
It insert filename.gif only,no picture. render(_['id'] + '.gif') does not work, wrong syntax?
I was read "Basic COncepts" (aka book3) chapter 4.2.1 (Computed Object access), example 3.5 and _[prefix + 'suffix'] does not work :(
Many thanks
Jaroslav Lukesh
_______________________________________________ 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 )
Sorry, I am an idiot. getattr takes 2 arguments, and id() is a method. Try something like <dtml-var "_.getattr(this().aq_parent, id() + '.gif')"> This does work, I've tested it. David On Fri, 12 Jul 2002, DA Loeffler wrote:
Perhaps <dtml-var "_.getattr(id+'.gif')">?
On Fri, 12 Jul 2002, Jaroslav Lukesh wrote:
Hi all,
I have file#(DTML Document), that have image with same name, but with extension for image type.
file1 file1.gif file2 file3 file3.gif
So what Can I do insert image with that composite filename? And if missing, insert nothing.
<dtml-in.....(DTML Document)...> ....... <dtml-var expr="_['id'] + '.gif'" missing> ??? </dtml-in>
It insert filename.gif only,no picture. render(_['id'] + '.gif') does not work, wrong syntax?
I was read "Basic COncepts" (aka book3) chapter 4.2.1 (Computed Object access), example 3.5 and _[prefix + 'suffix'] does not work :(
Many thanks
Jaroslav Lukesh
_______________________________________________ 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 )
_______________________________________________ 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 )
Sorry to spam the list with three consecutive messages. As I said, I am an idiot. Anyway, the _logical_ way to do this, without using getattr() which is excessive: <dtml-var expr="_[id()+'.gif']" missing> This is the _[prefix + '.suffix'] approach, but using the fact that id() is a method and must be properly called - in an expr="" attribute, just id will return a reference to the method, not call it. Otherwise we get an "unsupported operand types for +" error, since you can't add a method to a string! David
participants (2)
-
DA Loeffler -
Jaroslav Lukesh