[Plone-UI] Re: getting python:test to work in a page template

Alexander Limi limi at plone.org
Fri Apr 18 23:49:36 UTC 2008


This isn't really a UI question, you'll probably get much more feedback on  
the plone-users or product-developers lists. :)

— Alexander

On Wed, 16 Apr 2008 15:10:23 -0700, Annakan  
<xvaultx at xvaultx.com> wrote:

> Hello
> This one drives me nuts. :)
>
> I try to base myself on this tutorial to learn a bit about structural  
> views
> :http://plone.org/documentation/tutorial/create-a-2d-image-sorter-based-on-folder_contents-sorting-functionality/tutorial-all-pages
> more precisely
> http://plone.org/documentation/tutorial/create-a-2d-image-sorter-based-on-folder_contents-sorting-functionality/create-slide-sorter-view
> contains the template I try to understand and adapt.
>
> Plone keeps telling me that in the python:test expression there is a
> nameError : test is not defined.
>
> I can find lots of examples with that kind of code and even the tutorial
> here does it
> http://www.plope.com/Books/2_7Edition/AdvZPT.stx#2-19
>
> I know there could be a "cleaner" way of doing it by using the  
> python/view
> code to calculate a list of list with the pre caclculated values but I am
> not up to do such change yet before completely understanding the code  
> here.
>
> And I really do not see why the python:test is failling exept if there  
> was a
> change preventing its use in plone recently.
> I did not find any such information on the web site though.
>
> It must be something really obvious but I do not see it.
>
>
> Thanks a lot for your time.
>
>
> Here is my last attempt to get the closest possible at what is done in  
> the
> plope book :
>
> <xspan tal:define="oddrow             repeat/item/odd;
>                                         item_url
> item/getURL|item/absolute_url;
>                                         item_id              item/getId;
>                                         item_title_or_id
> item/pretty_title_or_id;
>                                         item_description
> item/Description;
>                                         oddEven               
> string:'even';
>                                         cellId
> string:cell$index;
>                                         large_view
> string:$item_url/image_large;"
>                              tal:attributes="class python:test(oddrow,  
> 'odd
> $cellId sortable-cell','even $cellId sortable-cell');
>                                              id
> string:folder-contents-item-${item_id};
>                                              ondblclick string:return
> openPopup('$large_view', '$item_title_or_id');">
> but to no avail.
>
>
> the traceback is here :
> Time  	2008/04/13 00:56:29.015 GMT+2
> User Name (User Id) 	admin (admin)
> Request URL
> http://127.0.0.1:8080/QeF%20Site/squareview-test/square_view.html
> Exception Type 	NameError
> Exception Value 	name 'test' is not defined
>
> Traceback (innermost last):
>
>     * Module ZPublisher.Publish, line 119, in publish
>     * Module ZPublisher.mapply, line 88, in mapply
>     * Module ZPublisher.Publish, line 42, in call_object
>     * Module Products.Five.browser.metaconfigure, line 417, in __call__
>     * Module Shared.DC.Scripts.Bindings, line 313, in __call__
>     * Module Shared.DC.Scripts.Bindings, line 350, in _bindAndExec
>     * Module Products.PageTemplates.PageTemplateFile, line 129, in _exec
>     * Module Products.PageTemplates.PageTemplate, line 89, in pt_render
>     * Module zope.pagetemplate.pagetemplate, line 117, in pt_render
>     * Module zope.tal.talinterpreter, line 271, in __call__
>     * Module zope.tal.talinterpreter, line 346, in interpret
>     * Module zope.tal.talinterpreter, line 891, in do_useMacro
>     * Module zope.tal.talinterpreter, line 346, in interpret
>     * Module zope.tal.talinterpreter, line 536, in do_optTag_tal
>     * Module zope.tal.talinterpreter, line 521, in do_optTag
>     * Module zope.tal.talinterpreter, line 516, in no_tag
>     * Module zope.tal.talinterpreter, line 346, in interpret
>     * Module zope.tal.talinterpreter, line 957, in do_defineSlot
>     * Module zope.tal.talinterpreter, line 346, in interpret
>     * Module zope.tal.talinterpreter, line 536, in do_optTag_tal
>     * Module zope.tal.talinterpreter, line 521, in do_optTag
>     * Module zope.tal.talinterpreter, line 516, in no_tag
>     * Module zope.tal.talinterpreter, line 346, in interpret
>     * Module zope.tal.talinterpreter, line 861, in do_defineMacro
>     * Module zope.tal.talinterpreter, line 346, in interpret
>     * Module zope.tal.talinterpreter, line 957, in do_defineSlot
>     * Module zope.tal.talinterpreter, line 346, in interpret
>     * Module zope.tal.talinterpreter, line 536, in do_optTag_tal
>     * Module zope.tal.talinterpreter, line 521, in do_optTag
>     * Module zope.tal.talinterpreter, line 516, in no_tag
>     * Module zope.tal.talinterpreter, line 346, in interpret
>     * Module zope.tal.talinterpreter, line 534, in do_optTag_tal
>     * Module zope.tal.talinterpreter, line 516, in no_tag
>     * Module zope.tal.talinterpreter, line 346, in interpret
>     * Module zope.tal.talinterpreter, line 949, in do_defineSlot
>     * Module zope.tal.talinterpreter, line 346, in interpret
>     * Module zope.tal.talinterpreter, line 861, in do_defineMacro
>     * Module zope.tal.talinterpreter, line 346, in interpret
>     * Module zope.tal.talinterpreter, line 536, in do_optTag_tal
>     * Module zope.tal.talinterpreter, line 521, in do_optTag
>     * Module zope.tal.talinterpreter, line 516, in no_tag
>     * Module zope.tal.talinterpreter, line 346, in interpret
>     * Module zope.tal.talinterpreter, line 861, in do_defineMacro
>     * Module zope.tal.talinterpreter, line 346, in interpret
>     * Module zope.tal.talinterpreter, line 536, in do_optTag_tal
>     * Module zope.tal.talinterpreter, line 521, in do_optTag
>     * Module zope.tal.talinterpreter, line 516, in no_tag
>     * Module zope.tal.talinterpreter, line 346, in interpret
>     * Module zope.tal.talinterpreter, line 855, in do_condition
>     * Module zope.tal.talinterpreter, line 346, in interpret
>     * Module zope.tal.talinterpreter, line 536, in do_optTag_tal
>     * Module zope.tal.talinterpreter, line 521, in do_optTag
>     * Module zope.tal.talinterpreter, line 516, in no_tag
>     * Module zope.tal.talinterpreter, line 346, in interpret
>     * Module zope.tal.talinterpreter, line 824, in do_loop_tal
>     * Module zope.tal.talinterpreter, line 346, in interpret
>     * Module zope.tal.talinterpreter, line 536, in do_optTag_tal
>     * Module zope.tal.talinterpreter, line 521, in do_optTag
>     * Module zope.tal.talinterpreter, line 516, in no_tag
>     * Module zope.tal.talinterpreter, line 346, in interpret
>     * Module zope.tal.talinterpreter, line 536, in do_optTag_tal
>     * Module zope.tal.talinterpreter, line 521, in do_optTag
>     * Module zope.tal.talinterpreter, line 516, in no_tag
>     * Module zope.tal.talinterpreter, line 346, in interpret
>     * Module zope.tal.talinterpreter, line 408, in do_startTag
>     * Module zope.tal.talinterpreter, line 485, in attrAction_tal
>     * Module Products.PageTemplates.Expressions, line 228, in  
> evaluateText
>     * Module zope.tales.tales, line 696, in evaluate
>       URL: index
>       Line 27, Column 24
>       Expression: <PythonExpr (test(oddrow, 'odd $cellId
> sortable-cell','even $cellId sortable-cell'))>
>       Names:
>
>       {'container': <ATFolder at /QeF Site/squareview-test>,
>        'context': <ATFolder at /QeF Site/squareview-test>,
>        'default': ,
>        'here': <ATFolder at /QeF Site/squareview-test>,
>        'loop': {'item': <Products.PageTemplates.Expressions.PathIterator
> object at 0x06BC8590>},
>        'nothing': None,
>        'options': {'args': (<Products.Five.metaclass.SimpleViewClass from
> c:\dev\sources\zope\qef\trunk\src\qef.qefcontent\QeF\QeFContent\browser\square_view.pt
> object at 0x06012650>,)},
>        'repeat': <Products.PageTemplates.Expressions.SafeMapping object  
> at
> 0x060F2E90>,
>        'request': <HTTPRequest,
> URL=http://127.0.0.1:8080/QeF%20Site/squareview-test/square_view.html>,
>        'root': <Application at >,
>        'template': <ImplicitAcquirerWrapper object at 0x05F411D0>,
>        'traverse_subpath': [],
>        'user': <PropertiedUser 'admin'>,
>        'view': <Products.Five.metaclass.SimpleViewClass from
> c:\dev\sources\zope\qef\trunk\src\qef.qefcontent\QeF\QeFContent\browser\square_view.pt
> object at 0x06012650>,
>        'views': <zope.app.pagetemplate.viewpagetemplatefile.ViewMapper
> object at 0x06BD06D0>}
>
>     * Module zope.tales.pythonexpr, line 59, in __call__
>       __traceback_info__: (test(oddrow, 'odd $cellId sortable-cell','even
> $cellId sortable-cell'))
>     * Module <string>, line 0, in ?
>
> NameError: name 'test' is not defined
>
>



-- 
Alexander Limi · http://limi.net





More information about the UI mailing list