I asked a question a while back about using Mako templates, in the
thread, it was suggested that one should leave these lines out
completely:
# The following template options are passed to your template engines
#tmpl_options = {}
#tmpl_options['myghty.log_errors'] = True
#tmpl_options['myghty.escapes'] = dict(l=webhelpers.auto_link,
s=webhelpers.simple_format)
this kills the Paste serve outright, the only thing that works is to
define an empty dict
tmpl_options = {}
Maybe the docs should reflect this?
-------------------- Restarting --------------------
Starting server in PID 2504.
serving on 0.0.0.0:5000 view at http://127.0.0.1:5000
Debug at: http://localhost:5000/_debug/view/1179300848
----------------------------------------
Exception happened during processing of request from ('127.0.0.1',
1174)
Traceback (most recent call last):
File "c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste
\httpserver.py",
line 592, in process_request_in_thread
self.finish_request(request, client_address)
File "C:\Python24\lib\SocketServer.py", line 254, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Python24\lib\SocketServer.py", line 521, in __init__
self.handle()
File "c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste
\httpserver.py",
line 400, in handle
BaseHTTPRequestHandler.handle(self)
File "C:\Python24\lib\BaseHTTPServer.py", line 316, in handle
self.handle_one_request()
File "c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste
\httpserver.py",
line 395, in handle_one_request
self.wsgi_execute()
File "c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste
\httpserver.py",
line 266, in wsgi_execute
self.wsgi_start_response)
File "c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste
\cascade.py", lin
e 92, in __call__
return self.apps[-1](environ, start_response)
File "c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste
\registry.py", li
ne 327, in __call__
app_iter = self.application(environ, start_response)
File "c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste
\recursive.py", l
ine 80, in __call__
return self.application(environ, start_response)
File "c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste
\errordocument.py
", line 185, in __call__
app_iter = self.application(environ, change_response)
File "c:\python24\lib\site-packages\Paste-1.3-py2.4.egg\paste
\evalexception\mi
ddleware.py", line 186, in __call__
return self.respond(environ, start_response)
File "c:\python24\lib\site-packages\Pylons-0.9.5-py2.4.egg\pylons
\error.py", l
ine 269, in respond
return debug_info.content()
File "c:\python24\lib\site-packages\Pylons-0.9.5-py2.4.egg\pylons
\error.py", l
ine 308, in content
result = formatter_(self.exc_value)
File "c:\python24\lib\site-packages\Pylons-0.9.5-py2.4.egg\pylons
\error.py", l
ine 288, in mako_html_data
return mako.exceptions.html_error_template().render()[610:-16]
File "c:\python24\lib\site-packages\mako-0.1.5-py2.4.egg\mako
\template.py", li
ne 109, in render
return runtime._render(self, self.callable_, args, data)
File "c:\python24\lib\site-packages\mako-0.1.5-py2.4.egg\mako
\runtime.py", lin
e 286, in _render
_render_context(template, callable_, context, *args,
**_kwargs_for_callable(
callable_, data))
File "c:\python24\lib\site-packages\mako-0.1.5-py2.4.egg\mako
\runtime.py", lin
e 303, in _render_context
_exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
File "c:\python24\lib\site-packages\mako-0.1.5-py2.4.egg\mako
\runtime.py", lin
e 336, in _exec_template
callable_(context, *args, **kwargs)
File "memory:0x124ed90", line 61, in render_body
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position
0: ordinal
not in range(128)
----------------------------------------
CompileException: Could not read template using encoding of 'ascii'.
Did you forget a magic encoding comment? in file 'D:\Projects
\Pylons_projects\test\test\templates/standard.html' at line: 0 char: 0
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <head>
4 <title>Fön</title>
5 <link rel="SHORTCUT ICON" href="img/favicon.ico">
I tried saving the file as UTF-8, that die not help at all, the Paster
server threw an exception :
File "memory:0x128a810", line 61, in render_body
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position
0: ordinal
not in range(128)
Does someone have an idea on the workflow of constructing templaters
for mako from plain HTML from designers?
Thanks
On 16 mai, 10:03, voltron <nhy...@googlemail.com> wrote:
> I did some poking around. This is the Pylons debug:
>
> CompileException: Could not read template using encoding of 'ascii'.
> Did you forget a magic encoding comment? in file 'D:\Projects
> \Pylons_projects\test\test\templates/standard.html' at line: 0 char: 0
> 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> 2 <html>
> 3 <head>
> 4 <title>Fön</title>
> 5 <link rel="SHORTCUT ICON" href="img/favicon.ico">
>
> I tried saving the file as UTF-8, that die not help at all, the Paster
> server threw an exception :
>
> File "memory:0x128a810", line 61, in render_body
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position
> 0: ordinal
> not in range(128)
>
You may want to reads this:
http://docs.pythonweb.org/display/pylonscookbook/Using+Mako+templating+language
The thing is, in the thread, 2 people mentioned that it was
unnecessary, which is true when one does not use umlauts
On May 16, 12:14 pm, "bruno.desthuilli...@gmail.com"
<bruno.desthuilli...@gmail.com> wrote:
> On 16 mai, 10:03, voltron <nhy...@googlemail.com> wrote:
>
>
>
> > I did some poking around. This is the Pylons debug:
>
> > CompileException: Could not read template using encoding of 'ascii'.
> > Did you forget a magic encoding comment? in file 'D:\Projects
> > \Pylons_projects\test\test\templates/standard.html' at line: 0 char: 0
> > 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> > "http://www.w3.org/TR/html4/loose.dtd">
> > 2 <html>
> > 3 <head>
> > 4 <title>Fön</title>
> > 5 <link rel="SHORTCUT ICON" href="img/favicon.ico">
>
> > I tried saving the file as UTF-8, that die not help at all, the Paster
> > server threw an exception :
>
> > File "memory:0x128a810", line 61, in render_body
> > UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position
> > 0: ordinal
> > not in range(128)
>
> You may want to reads this:http://docs.pythonweb.org/display/pylonscookbook/Using+Mako+templatin...
>
> I did some poking around. This is the Pylons debug:
>
> CompileException: Could not read template using encoding of 'ascii'.
> Did you forget a magic encoding comment? in file 'D:\Projects
> \Pylons_projects\test\test\templates/standard.html' at line: 0 char: 0
> 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
> "http://www.w3.org/TR/html4/loose.dtd">
> 2 <html>
> 3 <head>
> 4 <title>Fön</title>
> 5 <link rel="SHORTCUT ICON" href="img/favicon.ico">
You definitely need a magic encoding comment because there's non-
ascii characters in your template.
>
> I tried saving the file as UTF-8, that die not help at all, the Paster
> server threw an exception :
Did you include the magic encoding comment when you did this? Some
editors will also use the utf-8 bom at the beginning of a file to
identify mark the file as being in utf-8 (so a magic encoding comment
isn't required). Python supports the utf-8 bom for .py files, however
mako only started supporting identifying the utf-8 bom in the latest
version (trunk).
>
> File "memory:0x128a810", line 61, in render_body
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position
> 0: ordinal
> not in range(128)
>
> Does someone have an idea on the workflow of constructing templaters
> for mako from plain HTML from designers?
--
Philip Jenvey