[Zope-dev] KeyError in GlobalTranslationService.py
Florent Guillaume
fg at nuxeo.com
Wed Aug 11 09:50:12 EDT 2004
Could you give an example of msgid that fails and gives the traceback
included ?
Florent
In article <CA519749-E196-11D8-8D6E-000A95A54FFC at topia.com> you write:
> -=-=-=-=-=-
> -=-=-=-=-=-
>
> I just submitted a patch for Plone 2.0.3
> http://plone.org/collector/3329
> that stops a KeyError from being triggered in
> GlobalTranslationService.py when a msgid contains a "$"
>
> I think that passing a translation key containing $ should not cause an
> Error page.
>
> So here's a patch for Zope that at least prevents the problem.
> Translation Service dudes will probably pick big holes in it.
>
> Oh, and traceback attached below. The msgid was Ca$hville, the title of
> a doc.
>
> --r.
>
> diff GlobalTranslationService.py.orig GlobalTranslationService.py
> 28,31c28,35
> < def repl(m, mapping=mapping):
> < return ustr(mapping[m.group(m.lastindex)])
> < cre = re.compile(r'\$(?:(%s)|\{(%s)\})' % (NAME_RE, NAME_RE))
> < return cre.sub(repl, default or msgid)
> ---
> > try:
> > def repl(m, mapping=mapping):
> > return ustr(mapping[m.group(m.lastindex)])
> > cre = re.compile(r'\$(?:(%s)|\{(%s)\})' % (NAME_RE,
> NAME_RE))
> > return cre.sub(repl, default or msgid)
> > except KeyError:
> > return msgid
>
> Traceback:
>
> Site Error
>
> An error was encountered while publishing this resource.
>
> KeyError
> Sorry, a site error occurred.
>
> Traceback (innermost last):
>
> * Module ZPublisher.Publish, line 163, in publish_module_standard
> * Module ZPublisher.Publish, line 127, in publish
> * Module Zope.App.startup, line 203, in zpublisher_exception_hook
> * Module ZPublisher.Publish, line 100, in publish
> * Module ZPublisher.mapply, line 88, in mapply
> * Module ZPublisher.Publish, line 40, in call_object
> * Module Shared.DC.Scripts.Bindings, line 306, in __call__
> * Module Shared.DC.Scripts.Bindings, line 343, in _bindAndExec
> * Module Products.CMFCore.FSPageTemplate, line 191, in _exec
> * Module Products.CMFCore.FSPageTemplate, line 124, in pt_render
> * Module Products.PageTemplates.PageTemplate, line 96, in pt_render
> <FSPageTemplate at /testdollarproblem/document_view used for
> /testdollarproblem/foo>
> * Module TAL.TALInterpreter, line 189, in __call__
> * Module TAL.TALInterpreter, line 233, in interpret
> * Module TAL.TALInterpreter, line 663, in do_useMacro
> * Module TAL.TALInterpreter, line 233, in interpret
> * Module TAL.TALInterpreter, line 408, in do_optTag_tal
> * Module TAL.TALInterpreter, line 393, in do_optTag
> * Module TAL.TALInterpreter, line 388, in no_tag
> * Module TAL.TALInterpreter, line 233, in interpret
> * Module TAL.TALInterpreter, line 663, in do_useMacro
> * Module TAL.TALInterpreter, line 233, in interpret
> * Module TAL.TALInterpreter, line 605, in do_loop_tal
> * Module TAL.TALInterpreter, line 233, in interpret
> * Module TAL.TALInterpreter, line 408, in do_optTag_tal
> * Module TAL.TALInterpreter, line 393, in do_optTag
> * Module TAL.TALInterpreter, line 388, in no_tag
> * Module TAL.TALInterpreter, line 233, in interpret
> * Module TAL.TALInterpreter, line 629, in do_condition
> * Module TAL.TALInterpreter, line 233, in interpret
> * Module TAL.TALInterpreter, line 552, in do_insertTranslation
> * Module TAL.TALInterpreter, line 615, in translate
> * Module Products.PageTemplates.TALES, line 263, in translate
> * Module Products.PageTemplates.GlobalTranslationService, line 31,
> in
> translate
> * Module Products.PageTemplates.GlobalTranslationService, line 29,
> in repl
>
> KeyError: 'hville' (Also, an error occurred while attempting to render
> the
> standard error message.)
>
>
> Russ Ferriday
> Solution Workshops for Plone
> (+44) (0) 7789 338868
> http://www.solutionworkshops.com
> -=-=-=-=-=-
> [Alternative: text/enriched]
> -=-=-=-=-=-
> -=-=-=-=-=-
>
> _______________________________________________
> Zope-Dev maillist - Zope-Dev at zope.org
> http://mail.zope.org/mailman/listinfo/zope-dev
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope )
>
> -=-=-=-=-=-
--
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 71 59 http://nuxeo.com mailto:fg at nuxeo.com
More information about the Zope-Dev
mailing list