I'm trying to use TemplateLookup from Mako, but can't seem to get it to work.

Layout of the test site is:

/var/www
    main.py
    templates/
       index.html

Nginx's config is setup as:

location / {
    fastcgi_pass 127.0.0.1:8080;
    fastcgi_param SERVER_NAME $server_name;
    fastcgi_param SERVER_PORT $server_port;
    fastcgi_param SERVER_PROTOCOL $server_protocol;
    fastcgi_param PATH_INFO $fastcgi_script_name;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param QUERY_STRING $query_string;
    fastcgi_param CONTENT_TYPE $content_type;
    fastcgi_param CONTENT_LENGTH $content_length;
    fastcgi_pass_header Authorization;
    fastcgi_intercept_errors off;
}

Cherrypy's config has:

[global]
server.socket_port = 8080
server.thread_pool = 10
engine.autoreload_on = False
tools.sessions.on = True

A simple cherrypy setup in main.py seems to work fine.

import cherrypy
class Main:
    @cherrypy.expose
    def index(self):
        return 'Hello'

cherrypy.tree.mount(Main(), '/', config='config')

Now, if I modify this to use Mako's template lookup, I get a 500 error. I know it has something to do with serving static files, but I've tried over a dozen different configurations accoring to the cherrypy wiki, but none of them work.

Here's a bare setup I have for the templates:

import cherrypy
from mako.template import Template
from mako.lookup import TemplateLookup

templates = TemplateLookup(directories=['templates'], output_encoding='utf-8')

class Main:
    @cherrypy.expose
    def index(self):
        return templates.get_template('index.html').render(msg='hello')

cherrypy.tree.mount(Main(), '/', config='config')

Does anyone know how I can get this to work ?

link|improve this question
feedback

1 Answer

I just was doing the same with Django..

Took me a while to figure out i needed to install flup to run the application for fastcgi..

You probably have the same problem as me..

Hope this helps :D

link|improve this answer
I'll try this today. Thanks for the response :) – xuniluser Nov 10 '10 at 23:36
Ohh im sorry.. Its called FLUP.. ive updated my answer – Arenstar Nov 11 '10 at 0:37
Oh right. I have that installed already. Without it I can't get it to work at all. In this case, I can't get it to work only when trying to use mako. – xuniluser Nov 11 '10 at 2:06
hmmmm tools.cherrypy.org/wiki/FastCGIWSGI ...... im sorry.. it seems quite hard to bring this all together, im really not sure – Arenstar Nov 11 '10 at 2:13
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.