blogofile
blogofile copied to clipboard
Trying to decode ascii instead of unicode
I had blogofile running on debian wheezy with python3.2 and now had to move the files into debian squeeze running python2.6. That was when the latin characters started to become a problem.
Here is the trace i get when trying to build the site, more especifically, when it tries to make a permalink:
The standard out:
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/Blogofile-0.8b1-py2.6.egg/blogofile/template.py", line 154, in render
rendered = self.mako_template.render(**self)
File "/usr/local/lib/python2.6/dist-packages/Mako-1.0.0-py2.6.egg/mako/template.py", line 443, in render
return runtime._render(self, self.callable_, args, data)
File "/usr/local/lib/python2.6/dist-packages/Mako-1.0.0-py2.6.egg/mako/runtime.py", line 803, in _render
**_kwargs_for_callable(callable_, data))
File "/usr/local/lib/python2.6/dist-packages/Mako-1.0.0-py2.6.egg/mako/runtime.py", line 835, in _render_context
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
File "/usr/local/lib/python2.6/dist-packages/Mako-1.0.0-py2.6.egg/mako/runtime.py", line 860, in _exec_template
callable_(context, *args, **kwargs)
File "_templates/base.mako", line 2, in render_body
${next.body()}
File "_templates/site.mako", line 20, in render_body
${next.body()}
File "_templates/blog/permapage.mako", line 2, in render_body
<%include file="post.mako" args="post=post" />
File "/usr/local/lib/python2.6/dist-packages/Mako-1.0.0-py2.6.egg/mako/runtime.py", line 730, in _include_file
callable_(ctx, **_kwargs_for_include(callable_, context._data, **kwargs))
File "_templates/blog/post.mako", line 18, in render_body
<p><small><span class="blog_post_date">${post.date.strftime("%B %d, %Y at %I:%M %p")}</span> | categories:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3: ordinal not in range(128)
And the tail from the standard error (with blogofile -vv build):
DEBUG:blogofile.post:Permalink: http://example.com/blog/title
ERROR:blogofile.template:Error rendering template: permapage.mako
ERROR:blogofile:Fatal build error occured, calling bf.config.build_exception()
DEBUG:blogofile:Running user's build_finally() function...
Traceback (most recent call last):
File "/usr/local/bin/blogofile", line 9, in <module>
load_entry_point('Blogofile==0.8b1', 'console_scripts', 'blogofile')()
File "/usr/local/lib/python2.6/dist-packages/Blogofile-0.8b1-py2.6.egg/blogofile/main.py", line 58, in main
args.func(args)
File "/usr/local/lib/python2.6/dist-packages/Blogofile-0.8b1-py2.6.egg/blogofile/main.py", line 388, in do_build
writer.write_site()
File "/usr/local/lib/python2.6/dist-packages/Blogofile-0.8b1-py2.6.egg/blogofile/writer.py", line 49, in write_site
self.__run_controllers()
File "/usr/local/lib/python2.6/dist-packages/Blogofile-0.8b1-py2.6.egg/blogofile/writer.py", line 162, in __run_controllers
controller.run_all(namespaces)
File "/usr/local/lib/python2.6/dist-packages/Blogofile-0.8b1-py2.6.egg/blogofile/controller.py", line 229, in run_all
c.mod.run()
File "/usr/local/lib/python2.6/dist-packages/blogofile_blog-0.8b1-py2.6.egg/blogofile_blog/site_src/_controllers/blog/__init__.py", line 86, in run
permapage.run()
File "/usr/local/lib/python2.6/dist-packages/blogofile_blog-0.8b1-py2.6.egg/blogofile_blog/site_src/_controllers/blog/permapage.py", line 12, in run
write_permapages()
File "/usr/local/lib/python2.6/dist-packages/blogofile_blog-0.8b1-py2.6.egg/blogofile_blog/site_src/_controllers/blog/permapage.py", line 38, in write_permapages
"permapage.mako", bf.util.path_join(path, "index.html"), env)
File "/usr/local/lib/python2.6/dist-packages/Blogofile-0.8b1-py2.6.egg/blogofile/plugin.py", line 160, in materialize_template
lookup=self.template_lookup, caller=self.module)
File "/usr/local/lib/python2.6/dist-packages/Blogofile-0.8b1-py2.6.egg/blogofile/template.py", line 386, in materialize_template
template.render(location)
File "/usr/local/lib/python2.6/dist-packages/Blogofile-0.8b1-py2.6.egg/blogofile/template.py", line 154, in render
rendered = self.mako_template.render(**self)
File "/usr/local/lib/python2.6/dist-packages/Mako-1.0.0-py2.6.egg/mako/template.py", line 443, in render
return runtime._render(self, self.callable_, args, data)
File "/usr/local/lib/python2.6/dist-packages/Mako-1.0.0-py2.6.egg/mako/runtime.py", line 803, in _render
**_kwargs_for_callable(callable_, data))
File "/usr/local/lib/python2.6/dist-packages/Mako-1.0.0-py2.6.egg/mako/runtime.py", line 835, in _render_context
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
File "/usr/local/lib/python2.6/dist-packages/Mako-1.0.0-py2.6.egg/mako/runtime.py", line 860, in _exec_template
callable_(context, *args, **kwargs)
File "base_mako", line 21, in render_body
File "site_mako", line 37, in render_body
File "permapage_mako", line 33, in render_body
File "/usr/local/lib/python2.6/dist-packages/Mako-1.0.0-py2.6.egg/mako/runtime.py", line 730, in _include_file
callable_(ctx, **_kwargs_for_include(callable_, context._data, **kwargs))
File "post_mako", line 43, in render_body
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3: ordinal not in range(128)
I have already tried removing the latin characters from categories, titles, etc. Have also changed the accents to html escapes, with no luck.
Reverted to Mako-0.7.2-py2.6 and Unidecode-0.04.9-py2.6 and the song remains the same.
The only circumstance in which it does compile is when there are no posts.
Duplicate of #136, #138, #141, #147, and #148
Tried to change _config.py like suggested to:
def pre_build():
import locale
locale.setlocale(locale.LC_ALL, 'C')
Also downgraded to 0.7.1 The problem remains the same, even with 0.7.1
As I removed all offending characters from _config.py (on blog.name, blog.description, etc.), seems that in some post came up this new message:
Traceback (most recent call last):
File "/usr/local/bin/blogofile", line 9, in <module>
load_entry_point('Blogofile==0.7.1', 'console_scripts', 'blogofile')()
File "/usr/local/lib/python2.6/dist-packages/blogofile/main.py", line 135, in main
args.func(args)
File "/usr/local/lib/python2.6/dist-packages/blogofile/main.py", line 201, in do_build
writer.write_site()
File "/usr/local/lib/python2.6/dist-packages/blogofile/writer.py", line 52, in write_site
self.__run_controllers()
File "/usr/local/lib/python2.6/dist-packages/blogofile/writer.py", line 136, in __run_controllers
controller.run_all()
File "/usr/local/lib/python2.6/dist-packages/blogofile/controller.py", line 203, in run_all
controller.run()
File "_controllers/blog/__init__.py", line 25, in run
blog.posts = post.parse_posts("_posts")
File "_controllers/blog/post.py", line 334, in parse_posts
p = Post(src, filename=post_fn)
File "_controllers/blog/post.py", line 96, in __init__
self.__parse()
File "_controllers/blog/post.py", line 114, in __parse
self.__apply_filters(post_src)
File "_controllers/blog/post.py", line 132, in __apply_filters
self.content = bf.filter.run_chain(self.filters, post_src)
File "/usr/local/lib/python2.6/dist-packages/blogofile/filter.py", line 32, in run_chain
content = f.run(content)
File "_filters/syntax_highlight.py", line 170, in run
m.group('code'), lang, formatter)
File "_filters/syntax_highlight.py", line 102, in highlight_code
pygments.highlight(code, lexer, formatter))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 203-204: ordinal not in range(128)