Acquisition breaking my tal:attributes="href ..." (I think)
How can I circumvent this apparent effect of aquisition? I have a Zope Page Template like so (for a cable TV company Website): 1 <ul tal:repeat= 2 "package python:root.services.digital_tv.packages.objectValues('Cable Package')"> 3 <li><a href="HREF" 4 tal:attributes="href package/feature_list/absolute_url" 5 tal:content="package/title_or_id">PACKAGE TITLE OR ID</a> 6 </li> 7 </ul> 'Cable Package' is a very simple folderish ObjectManager ZClass. My only problem is in line 4. Because all the Cable Package objects acquire the "feature_list" ZPT object from their common parent directory ("packages"), absolute_url resolves to the following in every iteration: ~/services/digital_tv/packages/feature_list This is no good. I want HREF in the different iterations of the "package" repeat variable to resolve to paths specific to the current Cable Package object, e.g.: ~/services/digital_tv/packages/gold/feature_list ~/services/digital_tv/packages/silver/feature_list ~/services/digital_tv/packages/platinum/feature_list (Where gold, silver, and platinum are Cable Package objects within folder "packages".) The actual, aquired feature_list ZPT (in the "packages" folder) in turn calls the individual Cable Package's channel_list method. It all works great when I call the correct URLs directly, because "here" is properly defined in the feature_list template as below: <table tal:repeat="channel here/channel_list"> <tr> <td tal:content="channel/title_or_id">TITLE OR ID</td> <td tal:content="channel/number">000</td> </tr> </table> So, how do I get line 4 in the first snippet to stop resolving to the URL of the acquired feature_list, and instead return the Cable Package-specific URL (gold, silver, platinum)? Thanks so much for caring enough to read this far! Jon Detroit, Michigan, USA
Jon Whitener writes:
How can I circumvent this apparent effect of aquisition?
I have a Zope Page Template like so (for a cable TV company Website):
1 <ul tal:repeat= 2 "package python:root.services.digital_tv.packages.objectValues('Cable Package')"> 3 <li><a href="HREF" 4 tal:attributes="href package/feature_list/absolute_url" 5 tal:content="package/title_or_id">PACKAGE TITLE OR ID</a> 6 </li> 7 </ul>
'Cable Package' is a very simple folderish ObjectManager ZClass.
My only problem is in line 4. Because all the Cable Package objects acquire the "feature_list" ZPT object from their common parent directory ("packages"), absolute_url resolves to the following in every iteration:
~/services/digital_tv/packages/feature_list
Hm, a first try: it seems your 'Cable Package" objects do not contain a 'feature_list' object, which explains why the page template is acquired. If You want to call the page template on these objects, thus their attributes are in the acquisition path of the 'feature_list', You may want to append 'feature_list' by hand to the url, e.g.: 4a tal:attributes="href python:package.absolute_url()+'/feature_list'" or 4b tal:attributes="href python:'%s/feature_list' % package.absolute_url()" Would this help, or did I misunderstood the problem? cheers, clemens
Clemens Robbenhaar, you are my Zope hero. Both techniques (4a and 4b) work perfectly. That makes you "2 for 2" for me in the last 24 hours! Thanks! Jon At 11/27/02, Clemens Robbenhaar wrote:
Jon Whitener writes:
How can I circumvent this apparent effect of aquisition?
I have a Zope Page Template like so (for a cable TV company Website):
1 <ul tal:repeat= 2 "package python:root.services.digital_tv.packages.objectValues('Cable Package')"> 3 <li><a href="HREF" 4 tal:attributes="href package/feature_list/absolute_url" 5 tal:content="package/title_or_id">PACKAGE TITLE OR ID</a> 6 </li> 7 </ul>
'Cable Package' is a very simple folderish ObjectManager ZClass.
My only problem is in line 4. Because all the Cable Package objects acquire the "feature_list" ZPT object from their common parent directory ("packages"), absolute_url resolves to the following in every iteration:
~/services/digital_tv/packages/feature_list
Hm, a first try: it seems your 'Cable Package" objects do not contain a 'feature_list' object, which explains why the page template is acquired.
If You want to call the page template on these objects, thus their attributes are in the acquisition path of the 'feature_list', You may want to append 'feature_list' by hand to the url, e.g.:
4a tal:attributes="href python:package.absolute_url()+'/feature_list'"
or
4b tal:attributes="href python:'%s/feature_list' % package.absolute_url()"
Would this help, or did I misunderstood the problem?
cheers, clemens
participants (2)
-
Clemens Robbenhaar -
Jon Whitener