Hi, I am using the following statements for displaying links to Localfs objects. <tr tal:repeat="files batch" > <td><input type="checkbox" name="ids:list" value="<dtml-var id>"></td> <td><a href="HOME_URL" tal:attributes="href python:getLink(id)" tal:content="files/id">HOME TITLE OR ID</a></td> <br> </tr> However when I use the python script getLink I receive the following error. What's wrong ? Traceback (innermost last): a.. Module ZPublisher.Publish, line 98, in publish b.. Module ZPublisher.mapply, line 88, in mapply c.. Module ZPublisher.Publish, line 39, in call_object d.. Module Shared.DC.Scripts.Bindings, line 252, in __call__ e.. Module Shared.DC.Scripts.Bindings, line 283, in _bindAndExec f.. Module Products.PageTemplates.ZopePageTemplate, line 228, in _exec g.. Module Products.PageTemplates.PageTemplate, line 95, in pt_render <ZopePageTemplate at /Smartstorage/test3> h.. Module TAL.TALInterpreter, line 200, in __call__ i.. Module TAL.TALInterpreter, line 244, in interpret j.. Module TAL.TALInterpreter, line 636, in do_loop_tal k.. Module TAL.TALInterpreter, line 244, in interpret l.. Module TAL.TALInterpreter, line 295, in do_startTag m.. Module TAL.TALInterpreter, line 363, in attrAction_tal n.. Module Products.PageTemplates.TALES, line 223, in evaluateText o.. Module Products.PageTemplates.TALES, line 217, in evaluate URL: /Smartstorage/test3 Line 18, Column 10 Expression: <PythonExpr getLink(id)> Names: {'container': <Folder instance at 017F7D68>, 'default': <Products.PageTemplates.TALES.Default instance at 0141AC54>, 'here': <Folder instance at 017F7D68>, 'loop': <SafeMapping instance at 018F2B18>, 'modules': <Products.PageTemplates.ZRPythonExpr._SecureModuleImporter instance at 0141A84C>, 'nothing': None, 'options': {'args': ()}, 'repeat': <SafeMapping instance at 018F2B18>, 'request': <HTTPRequest, URL=http://10.0.0.151:8080/Smartstorage/test3>, 'root': <Application instance at 017EF6E8>, 'template': <ZopePageTemplate at /Smartstorage/test3>, 'traverse_subpath': [], 'user': admin}p.. Module Products.PageTemplates.ZRPythonExpr, line 48, in __call__ __traceback_info__: getLink(id) q.. Module Python expression "getLink(id)", line 2, in f NameError: global name 'getLink' is not defined. Regards. Michael
On Thu, Aug 14, 2003 at 03:10:16PM +0200, Michael Bleijerveld wrote:
Hi,
I am using the following statements for displaying links to Localfs objects.
<tr tal:repeat="files batch" > <td><input type="checkbox" name="ids:list" value="<dtml-var id>"></td> <td><a href="HOME_URL" tal:attributes="href python:getLink(id)" tal:content="files/id">HOME TITLE OR ID</a></td> <br> </tr>
However when I use the python script getLink I receive the following error. What's wrong ?
Several things. First, you're mixing tal and DTML. Second, you're not providing a namespace for getLink. Assuming that getLink is a python script that lives somewhere above this template, try this: <tr tal:repeat="file batch" > <td><input type="checkbox" name="ids:list" value="id" tal:attributes="value file/id"></td> <td><a href="HOME_URL" tal:attributes="href python:container.getLink(file.id)" tal:content="file/id">HOME TITLE OR ID</a></td> <br> </tr> Note several changes: - I changed "files" to "file" because it's only one at a time. - Everywhere you use id, it must be file/id (in python, file.id). - value="<dtml-var id>" won't work in TAL ;-) - getLink lives somewhere... I'm betting on container.getLink -- Paul Winkler http://www.slinkp.com Look! Up in the sky! It's SPOT-WELDER X! (random hero from isometric.spaceninja.com)
Paul Winkler wrote:
However when I use the python script getLink I receive the following error. What's wrong ?
Several things. First, you're mixing tal and DTML. Second, you're not providing a namespace for getLink. Assuming that getLink is a python script that lives somewhere above this template, try this:
<tr tal:repeat="file batch" > <td><input type="checkbox" name="ids:list" value="id" tal:attributes="value file/id"></td> <td><a href="HOME_URL" tal:attributes="href python:container.getLink(file.id)" tal:content="file/id">HOME TITLE OR ID</a></td> <br> </tr>
Note several changes: - I changed "files" to "file" because it's only one at a time. - Everywhere you use id, it must be file/id (in python, file.id). - value="<dtml-var id>" won't work in TAL ;-) - getLink lives somewhere... I'm betting on container.getLink
Note that you should never ever use object.id or object/id. Always use the getId() method (in TALES object/getId). Phil
Hi Phil, That doesn't work. Michael ----- Original Message ----- From: "Philipp von Weitershausen" <philipp@weitershausen.de> To: <zope@zope.org> Sent: Thursday, August 14, 2003 4:32 PM Subject: [Zope] Re: get url for localfs objects
Paul Winkler wrote:
However when I use the python script getLink I receive the following error. What's wrong ?
Several things. First, you're mixing tal and DTML. Second, you're not providing a namespace for getLink. Assuming that getLink is a python script that lives somewhere above this template, try this:
<tr tal:repeat="file batch" > <td><input type="checkbox" name="ids:list" value="id" tal:attributes="value file/id"></td> <td><a href="HOME_URL" tal:attributes="href python:container.getLink(file.id)" tal:content="file/id">HOME TITLE OR ID</a></td> <br> </tr>
Note several changes: - I changed "files" to "file" because it's only one at a time. - Everywhere you use id, it must be file/id (in python, file.id). - value="<dtml-var id>" won't work in TAL ;-) - getLink lives somewhere... I'm betting on container.getLink
Note that you should never ever use object.id or object/id. Always use the getId() method (in TALES object/getId).
Phil
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
On Thu, Aug 14, 2003 at 09:32:16AM -0500, Philipp von Weitershausen wrote:
Note that you should never ever use object.id or object/id. Always use the getId() method (in TALES object/getId).
generally true, assuming they are descendants of simpleItem or similar. I feel like I've run into some object that didn't implement getId but I forget what. Also, the original post didn't specify what's being looped over... i dunno if "batch" was from a folder's objectItems(), from a catalog query, or some sql stuff, or what. -- Paul Winkler http://www.slinkp.com Look! Up in the sky! It's SUPER TELEVISION ZIRO! (random hero from isometric.spaceninja.com)
Thanks Paul, It's work perfectly. Greetings. Michael ----- Original Message ----- From: "Paul Winkler" <pw_lists@slinkp.com> To: <zope@zope.org> Sent: Thursday, August 14, 2003 4:20 PM Subject: Re: [Zope] get url for localfs objects
On Thu, Aug 14, 2003 at 03:10:16PM +0200, Michael Bleijerveld wrote:
Hi,
I am using the following statements for displaying links to Localfs objects.
<tr tal:repeat="files batch" > <td><input type="checkbox" name="ids:list" value="<dtml-var id>"></td> <td><a href="HOME_URL" tal:attributes="href python:getLink(id)" tal:content="files/id">HOME TITLE OR ID</a></td> <br> </tr>
However when I use the python script getLink I receive the following error. What's wrong ?
Several things. First, you're mixing tal and DTML. Second, you're not providing a namespace for getLink. Assuming that getLink is a python script that lives somewhere above this template, try this:
<tr tal:repeat="file batch" > <td><input type="checkbox" name="ids:list" value="id" tal:attributes="value file/id"></td> <td><a href="HOME_URL" tal:attributes="href python:container.getLink(file.id)" tal:content="file/id">HOME TITLE OR ID</a></td> <br> </tr>
Note several changes: - I changed "files" to "file" because it's only one at a time. - Everywhere you use id, it must be file/id (in python, file.id). - value="<dtml-var id>" won't work in TAL ;-) - getLink lives somewhere... I'm betting on container.getLink
--
Paul Winkler http://www.slinkp.com Look! Up in the sky! It's SPOT-WELDER X! (random hero from isometric.spaceninja.com)
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
Michael Bleijerveld -
Paul Winkler -
Philipp von Weitershausen