I have ported a little pyramid app of mine to python3, almost
successfully, i. e. after some tweaking (using waitress etc,
won't go in the details here) it is already running.
But when it comes to rendering some pages, I get error msgs
concering byte vs string, see below. Those pages are assembled with
pyramid_viewgroup, which did install fine also for python3.
my app running on python2 had no particular problems (but see below: "what makes
things worse") when it came to rendering something like
<div tal:replace="structure provider('content')" />
omitting my configuration details here (but can provide them of course,
if needed), as I think they are fairly in line with the pyramid_viewgroup
docs.
Now, when running this same app on python3 I get:
...
File "/tmp/tmpdt09n6/page_936675d2dcac12f54a19c37066990109e30ddb34.py", line
341, in render
__cache_58307216 = getitem('provider')('content')
File
"/home/reuleaux/eggs/pyramid_viewgroup-0.5-py3.2.egg/pyramid_viewgroup/__init__.py",
line 37, in __call__
return render_view(self.context, self.request, name, secure)
File "/home/reuleaux/work/website/py3/pyramid/pyramid/view.py", line 139, in
render_view
return ''.join(iterable)
TypeError: sequence item 0: expected str instance, bytes found
- Expression: "provider('content')"
- Filename: ... /reuleaux/work/website/py3/src/website/templates/page.pt
- Location: (85:29)
- Source: ... tal:replace="structure provider('content')" />
^^^^^^^^^^^^^^^^^^^
- Arguments: repeat: {...} (0)
renderer_name: templates/page.pt
req: <Request - at 0x3774f50>
Markup: <function Markup at 0x371a2f8>
request: <Request - at 0x3774f50>
provider: <Provider - at 0x37870d0>
renderer_info: <RendererHelper - at 0x3787110>
context: <NotFound - at 0x3787150>
escape: False
view: <NoneType - at 0x84bf40>
Any idea? I guess/hope that pyramid_viewgroup is just not all that
popular, and noone has actually tried running it on python3.
What makes things worse, is that my simple case
<div tal:replace="structure provider('content')" />
worked even on python 2 only for pages that had no umlauts in them,
but I am german, living in France and we have lots of umlauts here
in Europe, so my workaround in python 2 was to
use
<div tal:replace="structure Markup(provider('content'))" />
instead, with Markup() defined as
def Markup(s):
return s.decode('utf-8')
and provided for rendering with
return render_to_response(
'templates/page.pt',
{ 'provider': Provider(cntxt, req),
'Markup': Markup,
},
request=req,
)
Now in python3 not even the simple pages without umlauts render any
more, no matter if I use this Markup() or not. But of course, any
page with or without umlauts (templates written in utf-8) should render.
Any idea?
-Andreas
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.