[Zope] Re: upgrade 2.5.1 to 2.7.5 causes error in product code
John Schinnerer
johnschinnerer at yahoo.com
Sat Aug 27 14:15:42 EDT 2005
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 at 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
More information about the Zope
mailing list