[Zope] Re: upgrade 2.5.1 to 2.7.5 causes error in product code

Tres Seaver tseaver at palladion.com
Sat Aug 27 12:22:43 EDT 2005


-----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 at 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-----



More information about the Zope mailing list