Hi there, I am calling a macro that reference the 'here' variable within python scripts. However the I am calling the macro from within a tal:repeat block. So the here object within the macro is not the object that I want to be working with. Can anyone tell me how I should be doing this so that macro is referencing the correct object. <metal:block tal:repeat="obj folderContents"> <dd> <div tal:condition="python: obj.portal_type == 'News Item'"> <metal:use use-macro="here/newsitem_view/macros/main"/> </div> </dd> </metal:block> Thanks.
Marius, Tuesday, April 20, 2004, 8:54:36 AM, you wrote:
I am calling a macro that reference the 'here' variable within python scripts. However the I am calling the macro from within a tal:repeat block. So the here object within the macro is not the object that I want to be working with. Can anyone tell me how I should be doing this so that macro is referencing the correct object.
<metal:block tal:repeat="obj folderContents"> <dd> <div tal:condition="python: obj.portal_type == 'News Item'"> <metal:use use-macro="here/newsitem_view/macros/main"/> </div> </dd> </metal:block>
obj The macro is expanded before tal-statements are evaluated, so whatever variables defined outside the macro are available. -- __________________________________________________________________ Geir Bækholt · Interaction Engineer · Plone Solutions Development · Training · Support · http://www.plonesolutions.com __________________________________________________________________
Geir Bækholt wrote:
The macro is expanded before tal-statements are evaluated, so whatever variables defined outside the macro are available.
I've asked this before but never got a good solution. If I want to expand and execute a METAL macro from Python code, what would I have to do then? Regards, Johan -- Johan Carlsson Tel: + 46 8 31 24 94 Colliberty Mob: + 46 70 558 25 24 Torsgatan 72 Email: johanc@easypublisher.com SE-113 37 STOCKHOLM Skype: colliberty
Yes I understand that. However the macro that I am calling uses the 'here' object, which references the object defined outside the loop, not the one that is referenced by 'obj'. What I want to do is to call the macro so that the 'here' reference is now set to the same object as 'obj' Thanks. On Tue, 20 Apr 2004 12:24:38 +0200, "Geir Bækholt" <lists@elvix.com> said:
Marius, Tuesday, April 20, 2004, 8:54:36 AM, you wrote:
I am calling a macro that reference the 'here' variable within python scripts. However the I am calling the macro from within a tal:repeat block. So the here object within the macro is not the object that I want to be working with. Can anyone tell me how I should be doing this so that macro is referencing the correct object.
<metal:block tal:repeat="obj folderContents"> <dd> <div tal:condition="python: obj.portal_type == 'News Item'"> <metal:use use-macro="here/newsitem_view/macros/main"/> </div> </dd> </metal:block>
obj
The macro is expanded before tal-statements are evaluated, so whatever variables defined outside the macro are available.
-- __________________________________________________________________
Geir Bækholt · Interaction Engineer · Plone Solutions
Development · Training · Support · http://www.plonesolutions.com __________________________________________________________________
Marius, Tuesday, April 20, 2004, 2:03:30 PM, you wrote:
Yes I understand that. However the macro that I am calling uses the 'here' object, which references the object defined outside the loop, not the one that is referenced by 'obj'. What I want to do is to call the macro so that the 'here' reference is now set to the same object as 'obj'
I would simply use "obj", but if you are desperate to make them the same (i cannot see for what reason, i must admit.. ) add a <tal:scary define="here obj"> wrapper around (or inside) the macro expansion No guarantees attached ;) good luck -- __________________________________________________________________ Geir Bækholt · Interaction Engineer · Plone Solutions Development · Training · Support · http://www.plonesolutions.com __________________________________________________________________
Marius Gleeson wrote:
Yes I understand that. However the macro that I am calling uses the 'here' object, which references the object defined outside the loop, not the one that is referenced by 'obj'. What I want to do is to call the macro so that the 'here' reference is now set to the same object as 'obj'
Isn't it possible to look up the macro from the obj? (I guess not from Geir's earlier response, but I sure feels intuitive?) E.g. <metal:block tal:repeat="obj folderContents"> <dd> <div tal:condition="python: obj.portal_type == 'News Item'"> <metal:use use-macro="obj/newsitem_view/macros/main"/> ------------------------^^^ </div> </dd> </metal:block> -- Johan Carlsson Tel: + 46 8 31 24 94 Colliberty Mob: + 46 70 558 25 24 Torsgatan 72 Email: johanc@easypublisher.com SE-113 37 STOCKHOLM Skype: colliberty
participants (4)
-
Geir Bækholt -
Johan Carlsson -
Marius Gleeson -
Marius Gleeson