Hash: SHA1

Peter Bengtsson wrote:
> I'm trying to get a product running in Zope 2.12 which I installed in
> a virtualenv with easy_install. It starts fine and all but when I try
> to render a piece of ZPT I get this weird error:
> Traceback (innermost last):
>   Module ZPublisher.Publish, line 127, in publish
>   Module ZPublisher.mapply, line 77, in mapply
>   Module ZPublisher.Publish, line 47, in call_object
>   Module Products.IssueTrackerProduct.IssueTracker, line 12629, in AddIssue
>   Module Shared.DC.Scripts.Bindings, line 324, in __call__
>   Module Shared.DC.Scripts.Bindings, line 361, in _bindAndExec
>   Module Products.PageTemplates.PageTemplateFile, line 130, in _exec
>   Module Products.PageTemplates.PageTemplate, line 80, in pt_render
>   Module zope.pagetemplate.pagetemplate, line 115, in pt_render
>   Module zope.tal.talinterpreter, line 271, in __call__
>   Module zope.tal.talinterpreter, line 343, in interpret
>   Module zope.tal.talinterpreter, line 888, in do_useMacro
>   Module zope.tal.talinterpreter, line 343, in interpret
>   Module zope.tal.talinterpreter, line 533, in do_optTag_tal
>   Module zope.tal.talinterpreter, line 518, in do_optTag
>   Module zope.tal.talinterpreter, line 513, in no_tag
>   Module zope.tal.talinterpreter, line 343, in interpret
>   Module zope.tal.talinterpreter, line 742, in do_insertStructure_tal
>   Module Products.PageTemplates.Expressions, line 220, in evaluateStructure
>   Module zope.tales.tales, line 696, in evaluate
>   Module Products.PageTemplates.ZRPythonExpr, line 49, in __call__
>    - __traceback_info__: here.getRoot().title_or_id().replace(' ',' ')

Note:  no ' ' in that expression.

>   Module PythonExpr, line 1, in <expression>
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position
> 0: ordinal not in range(128)

This says that the title_or_id method is returning a non-ASDII value,
which, after the 'replace' method of the string runs, can't be inlined
into the template.  Try something like:

 here.getRoot().title_or_id().decode('utf8').replace(' ', '&nbsp;')

> After a lot of trial-and-error I managed to figure out that the
> culprit was this piece of ZPT code:
> tal:content="structure python:here.getRoot().title_or_id().replace('
> ','&nbsp;')"
> Stupid and easy to fix; maybe but what if there are other problems like this?
> What's the cause of this? Do I have to set something special up in
> zope.conf just for Page Templates to not convert 'nbsp;' into
> '\xa0\xc2'?

Try installing the PDBDebugMode product in your instance and have a look
at the offending value "live".

- --
Tres Seaver          +1 540-429-0999          tsea...@palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org


Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to