Oops I copied a traceback from one of my attempts at fixing it.

Tres, that worked, thanks. I'm curious why it's necessary though. It seems
to me it should "just work" right? Can anyone explain further why that step
is necessary once a view is wrapped?  ( related note, wrapper views are
awesome, the docs could totally use more wrapper view examples! =)

Malte, how do I do that? Is it possible to do that when I am using a
renderer argument to a view zcml registration? I am having problems when I
get unicode out of the db too but haven't figured out whether it's a
chameleon setting I'm missing or a mysql encoding setting that's off.

thanks guys
Iain

On Thu, Dec 16, 2010 at 5:58 AM, Malthe Borch <mbo...@gmail.com> wrote:

> Alternatively, enable implicit decoding using
> ``default_encoding="utf-8"`` (in the template constructor). This is
> enabled on Plone, for instance.
>
> \malthe
>
> On 16 December 2010 14:47, Tres Seaver <tsea...@palladion.com> wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > On 12/15/2010 10:18 PM, Iain Duncan wrote:
> >> Not sure where I'm supposed to ask this now, here? Pyramid list?
> >>
> >> I have  view with a chameleon template that contains utf-8 unicode
> special
> >> chars. It renders fine when rendered on it's own from a view. As soon as
> I
> >> wrap that view with a wrapper view, I get errors with the wrapper
> choking on
> >> the unicode.
> >>
> >> My master views call method is like this:
> >>
> >> def __call__(self):
> >>     tmpl_dict = {}
> >>     tmpl_dict['inner_content'] = self.request.wrapped_body
> >>     return tmpl_dict
> >>
> >>
> >> I get the following traceback ( snipped ):
> >> File
> >>
> "/home/jordans/Jordans/eggs/repoze.bfg-1.2.2-py2.6.egg/repoze/bfg/router.py",
> >> line 130, in __call__
> >> response = view_callable(context, request)
> >> File
> >>
> "/home/jordans/Jordans/eggs/repoze.bfg-1.2.2-py2.6.egg/repoze/bfg/configuration.py",
> >> line 1724, in _owrapped_view
> >> wrapper_viewname)
> >> File
> >>
> "/home/jordans/Jordans/eggs/repoze.bfg-1.2.2-py2.6.egg/repoze/bfg/view.py",
> >> line 90, in render_view_to_response
> >> return view(context, request)
> >> File
> >>
> "/home/jordans/Jordans/eggs/repoze.bfg-1.2.2-py2.6.egg/repoze/bfg/configuration.py",
> >> line 1663, in _bfg_class_view
> >> response = inst()
> >> File "/home/jordans/Jordans/jordans/views/master_view.py", line 22, in
> >> __call__
> >> tmpl_dict['inner_content'] = u"%s" % self.request.wrapped_body
> >> UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position
> 4090:
> >> ordinal not in range(128)
> >>
> >>
> >> Any clues?
> >
> > The code in the traceback doesn't match the sample you showed above:
> > the 'wrapped_body' is an encoded string (WebOb responses always encode
> > the body with the supplied charset) which the view is trying to decode
> > (back?) to unicode without supplying the encoding.  The default encoding
> > used by WebOb is 'UTF-8', so I would try:
> >
> >    def __call__(self):
> >        tmpl_dict = {}
> >        body = self.request.wrapped_body
> >        tmpl_dict['inner_content'] = body.decode('UTF-8')
> >        return tmpl_dict
> >
> >
> >
> > Tres.
> > - --
> > ===================================================================
> > Tres Seaver          +1 540-429-0999          tsea...@palladion.com
> > Palladion Software   "Excellence by Design"    http://palladion.com
> > -----BEGIN PGP SIGNATURE-----
> > Version: GnuPG v1.4.10 (GNU/Linux)
> > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
> >
> > iEYEARECAAYFAk0KGHEACgkQ+gerLs4ltQ7FZQCgzIl5cIsJbt1viMO8KKAre97j
> > ne8An1T4tFdxXHTQzOcSJyWpP7hGiBcq
> > =Ty1s
> > -----END PGP SIGNATURE-----
> > _______________________________________________
> > Repoze-dev mailing list
> > Repoze-dev@lists.repoze.org
> > http://lists.repoze.org/listinfo/repoze-dev
> >
>
_______________________________________________
Repoze-dev mailing list
Repoze-dev@lists.repoze.org
http://lists.repoze.org/listinfo/repoze-dev

Reply via email to