upgrade 2.5.1 to 2.7.5 causes error in product code
Hello, I have just migrated some custom products from 2.5.1 to 2.7.5, meaning from python 2.1.3 to 2.3.5. I have this bit of code in the index_html page template in the product, which rendered just fine in zope 2.5.1/python 2.1.3: <span tal:condition="python:here.sponsors[0] != ''" tal:omit-tag=""> <h4>Sponsors</h4> <span tal:repeat="line here/sponsors" tal:omit-tag=""> <h5 tal:content="line" /> </span> </span> sponsors is a lines property in the custom product, like so: {'id':'sponsors', 'type':'lines', 'mode':'w'}, Now, in zope 2.7.5/python 2.3.5, I get an error on this part of the above code: python:here.sponsors[0] != '' as follows: Exception Type IndexError Exception Value tuple index out of range Can anyone tell me what's up with this? It worked fine in 2.5.1, now it gives this error in 2.7.5...help... Thanks, John S. And here's the complete... Traceback (innermost last): * Module ZPublisher.Publish, line 101, in publish * Module ZPublisher.mapply, line 88, in mapply * Module ZPublisher.Publish, line 39, in call_object * Module Shared.DC.Scripts.Bindings, line 306, in __call__ * Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec * Module Products.PageTemplates.PageTemplateFile, line 106, in _exec * Module Products.PageTemplates.PageTemplate, line 96, in pt_render <PageTemplateFile at /growingthroughit.org/galleryitems/bg/tw0110/index_html> * Module TAL.TALInterpreter, line 190, in __call__ * Module TAL.TALInterpreter, line 234, in interpret * Module TAL.TALInterpreter, line 671, in do_useMacro * Module TAL.TALInterpreter, line 234, in interpret * Module TAL.TALInterpreter, line 694, in do_defineSlot * Module TAL.TALInterpreter, line 234, in interpret * Module TAL.TALInterpreter, line 636, in do_condition * Module Products.PageTemplates.TALES, line 221, in evaluate URL: index_html Line 58, Column 0 Expression: <PythonExpr here.sponsors[0] != ''> Names: {'container': <GTIGalleryItem at /growingthroughit.org/galleryitems/bg/tw0110>, 'context': <GTIGalleryItem at /growingthroughit.org/galleryitems/bg/tw0110>, 'default': <Products.PageTemplates.TALES.Default instance at 0x40ad2aec>, 'here': <GTIGalleryItem at /growingthroughit.org/galleryitems/bg/tw0110>, 'loop': <SafeMapping instance at 40f297c0>, 'modules': <Products.PageTemplates.ZRPythonExpr._SecureModuleImporter instance at 0x40acccac>, 'nothing': None, 'options': {'args': ()}, 'repeat': <SafeMapping instance at 40f297c0>, 'request': <HTTPRequest, URL=http://www.growingthroughit.org/galleryitems/bg/tw0110/index_html>, 'root': <Application instance at 4189acb0>, 'template': <PageTemplateFile at /growingthroughit.org/galleryitems/bg/tw0110/index_html>, 'traverse_subpath': [], 'user': Anonymous User} * Module Products.PageTemplates.ZRPythonExpr, line 47, in __call__ __traceback_info__: here.sponsors[0] != '' * Module Python expression "here.sponsors[0] != ''", line 1, in <expression> * Module AccessControl.ZopeGuards, line 67, in guarded_getitem IndexError: tuple index out of range ____________________________________________________ Start your day with Yahoo! - make it your home page http://www.yahoo.com/r/hs
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 John Schinnerer wrote:
Hello,
I have just migrated some custom products from 2.5.1 to 2.7.5, meaning from python 2.1.3 to 2.3.5.
I have this bit of code in the index_html page template in the product, which rendered just fine in zope 2.5.1/python 2.1.3:
<span tal:condition="python:here.sponsors[0] != ''" tal:omit-tag=""> <h4>Sponsors</h4> <span tal:repeat="line here/sponsors" tal:omit-tag=""> <h5 tal:content="line" /> </span> </span>
sponsors is a lines property in the custom product, like so:
{'id':'sponsors', 'type':'lines', 'mode':'w'},
Now, in zope 2.7.5/python 2.3.5, I get an error on this part of the above code:
python:here.sponsors[0] != ''
as follows:
Exception Type IndexError Exception Value tuple index out of range
Can anyone tell me what's up with this? It worked fine in 2.5.1, now it gives this error in 2.7.5...help...
Thanks, John S.
And here's the complete...
Traceback (innermost last):
* Module ZPublisher.Publish, line 101, in publish * Module ZPublisher.mapply, line 88, in mapply * Module ZPublisher.Publish, line 39, in call_object * Module Shared.DC.Scripts.Bindings, line 306, in __call__ * Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec * Module Products.PageTemplates.PageTemplateFile, line 106, in _exec * Module Products.PageTemplates.PageTemplate, line 96, in pt_render <PageTemplateFile at /growingthroughit.org/galleryitems/bg/tw0110/index_html> * Module TAL.TALInterpreter, line 190, in __call__ * Module TAL.TALInterpreter, line 234, in interpret * Module TAL.TALInterpreter, line 671, in do_useMacro * Module TAL.TALInterpreter, line 234, in interpret * Module TAL.TALInterpreter, line 694, in do_defineSlot * Module TAL.TALInterpreter, line 234, in interpret * Module TAL.TALInterpreter, line 636, in do_condition * Module Products.PageTemplates.TALES, line 221, in evaluate URL: index_html Line 58, Column 0 Expression: <PythonExpr here.sponsors[0] != ''> Names:
{'container': <GTIGalleryItem at /growingthroughit.org/galleryitems/bg/tw0110>, 'context': <GTIGalleryItem at /growingthroughit.org/galleryitems/bg/tw0110>, 'default': <Products.PageTemplates.TALES.Default instance at 0x40ad2aec>, 'here': <GTIGalleryItem at /growingthroughit.org/galleryitems/bg/tw0110>, 'loop': <SafeMapping instance at 40f297c0>, 'modules': <Products.PageTemplates.ZRPythonExpr._SecureModuleImporter instance at 0x40acccac>, 'nothing': None, 'options': {'args': ()}, 'repeat': <SafeMapping instance at 40f297c0>, 'request': <HTTPRequest, URL=http://www.growingthroughit.org/galleryitems/bg/tw0110/index_html>, 'root': <Application instance at 4189acb0>, 'template': <PageTemplateFile at /growingthroughit.org/galleryitems/bg/tw0110/index_html>, 'traverse_subpath': [], 'user': Anonymous User}
* Module Products.PageTemplates.ZRPythonExpr, line 47, in __call__ __traceback_info__: here.sponsors[0] != '' * Module Python expression "here.sponsors[0] != ''", line 1, in <expression> * Module AccessControl.ZopeGuards, line 67, in guarded_getitem
IndexError: tuple index out of range
Try the following in your Zope 2.7.x sandbox: $ bin/zopectl debug ...
here = app['growingthroughit.org].galleryitems/bg/tw0110 print here.sponsors
If the output is '()', then your sponsors attribute is an empty tuple, which would explain the traceback. Tres. - -- =================================================================== Tres Seaver +1 202-558-7113 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDEJNT+gerLs4ltQ4RAi+GAKCLmWwcO2Z9QpHDhr4EucSjrdHH/QCfcI/M bAR796rT5M5qmVThQWzuAiU= =ha6X -----END PGP SIGNATURE-----
Hello, Thanks Tres, looks like zope 2.7.5/python 2.3.5 is triggering a genuine full-blown error on my code python:here.sponsors[0] != '' if the tuple is empty, whereas 2.5.1/2.1.3 must have been returning some equivalent of boolean 'false' when the tuple was empty. Now I do this python: (here.sponsors) and (here.sponsors[0] != '') and it works again. The second condition may be redundant now I suppose...? thanks, John S. --- Tres Seaver <tseaver@palladion.com> wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
John Schinnerer wrote:
Hello,
I have just migrated some custom products from 2.5.1 to 2.7.5, meaning from python 2.1.3 to 2.3.5.
I have this bit of code in the index_html page template in the product, which rendered just fine in zope 2.5.1/python 2.1.3:
<span tal:condition="python:here.sponsors[0] != ''" tal:omit-tag=""> <h4>Sponsors</h4> <span tal:repeat="line here/sponsors" tal:omit-tag=""> <h5 tal:content="line" /> </span> </span>
sponsors is a lines property in the custom product, like so:
{'id':'sponsors', 'type':'lines', 'mode':'w'},
Now, in zope 2.7.5/python 2.3.5, I get an error on this part of the above code:
python:here.sponsors[0] != ''
as follows:
Exception Type IndexError Exception Value tuple index out of range
Can anyone tell me what's up with this? It worked fine in 2.5.1, now it gives this error in 2.7.5...help...
Thanks, John S.
And here's the complete...
Traceback (innermost last):
* Module ZPublisher.Publish, line 101, in publish * Module ZPublisher.mapply, line 88, in mapply * Module ZPublisher.Publish, line 39, in call_object * Module Shared.DC.Scripts.Bindings, line 306, in __call__ * Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec * Module Products.PageTemplates.PageTemplateFile, line 106, in _exec * Module Products.PageTemplates.PageTemplate, line 96, in pt_render <PageTemplateFile at /growingthroughit.org/galleryitems/bg/tw0110/index_html> * Module TAL.TALInterpreter, line 190, in __call__ * Module TAL.TALInterpreter, line 234, in interpret * Module TAL.TALInterpreter, line 671, in do_useMacro * Module TAL.TALInterpreter, line 234, in interpret * Module TAL.TALInterpreter, line 694, in do_defineSlot * Module TAL.TALInterpreter, line 234, in interpret * Module TAL.TALInterpreter, line 636, in do_condition * Module Products.PageTemplates.TALES, line 221, in evaluate URL: index_html Line 58, Column 0 Expression: <PythonExpr here.sponsors[0] != ''> Names:
{'container': <GTIGalleryItem at /growingthroughit.org/galleryitems/bg/tw0110>, 'context': <GTIGalleryItem at /growingthroughit.org/galleryitems/bg/tw0110>, 'default': <Products.PageTemplates.TALES.Default instance at 0x40ad2aec>, 'here': <GTIGalleryItem at /growingthroughit.org/galleryitems/bg/tw0110>, 'loop': <SafeMapping instance at 40f297c0>, 'modules': <Products.PageTemplates.ZRPythonExpr._SecureModuleImporter instance at 0x40acccac>, 'nothing': None, 'options': {'args': ()}, 'repeat': <SafeMapping instance at 40f297c0>, 'request': <HTTPRequest,
URL=http://www.growingthroughit.org/galleryitems/bg/tw0110/index_html>,
'root': <Application instance at 4189acb0>, 'template': <PageTemplateFile at /growingthroughit.org/galleryitems/bg/tw0110/index_html>, 'traverse_subpath': [], 'user': Anonymous User}
* Module Products.PageTemplates.ZRPythonExpr, line 47, in __call__ __traceback_info__: here.sponsors[0] != '' * Module Python expression "here.sponsors[0] != ''", line 1, in <expression> * Module AccessControl.ZopeGuards, line 67, in guarded_getitem
IndexError: tuple index out of range
Try the following in your Zope 2.7.x sandbox:
$ bin/zopectl debug ...
here = app['growingthroughit.org].galleryitems/bg/tw0110 print here.sponsors
If the output is '()', then your sponsors attribute is an empty tuple, which would explain the traceback.
____________________________________________________ Start your day with Yahoo! - make it your home page http://www.yahoo.com/r/hs
On 27 Aug 2005, at 20:15, John Schinnerer wrote:
python:here.sponsors[0] != ''
if the tuple is empty, whereas 2.5.1/2.1.3 must have been returning some equivalent of boolean 'false' when the tuple was empty.
No. Python 2.1.3 would have blown up the same way.
Now I do this
python: (here.sponsors) and (here.sponsors[0] != '')
and it works again. The second condition may be redundant now I suppose...?
No it is not redundant. A value ('',) would still be True as far as Python is concerned and would pass the first condition. jens
Aloha,
python:here.sponsors[0] != ''
if the tuple is empty, whereas 2.5.1/2.1.3 must have been returning some equivalent of boolean 'false' when the tuple was empty.
No. Python 2.1.3 would have blown up the same way.
Must have been Zope 2.5.1 somehow turning the python blowup into equivalent of boolean 'false' then, or my clearly less than exemplary code would have also failed under 2.5.1, as it does under 2.7.5.
Now I do this
python: (here.sponsors) and (here.sponsors[0] != '')
and it works again. The second condition may be redundant now I suppose...?
No it is not redundant. A value ('',) would still be True as far as Python is concerned and would pass the first condition.
Right, thanks! John S. ____________________________________________________ Start your day with Yahoo! - make it your home page http://www.yahoo.com/r/hs
John Schinnerer wrote:
Hello,
Thanks Tres, looks like zope 2.7.5/python 2.3.5 is triggering a genuine full-blown error on my code
python:here.sponsors[0] != ''
if the tuple is empty, whereas 2.5.1/2.1.3 must have been returning some equivalent of boolean 'false' when the tuple was empty.
Now I do this
python: (here.sponsors) and (here.sponsors[0] != '')
and it works again. The second condition may be redundant now I suppose...?
Yes in earlier Zopes, changing a lines property in the ZMI to empty still resulted in ('',) instead of (). This has been fixed since. Florent -- Florent Guillaume, Nuxeo (Paris, France) CTO, Director of R&D +33 1 40 33 71 59 http://nuxeo.com fg@nuxeo.com
participants (4)
-
Florent Guillaume -
Jens Vagelpohl -
John Schinnerer -
Tres Seaver