Skip to main content

Mako tool for cherrypy

Project description

CherrypyMako is a cherrypy plugin that provides Mako template engine , within cherrypy as a tool.

Example:

demo.py:

import os.path
import cherrypy
import CherrypyMako
import datetime
CherrypyMako.setup()
root_dir = os.path.abspath( os.path.dirname(__file__))

class Root(object):

    @cherrypy.expose
    @cherrypy.tools.mako(filename='index.html')
    def index(self):
        return {'currentTime':datetime.datetime.now()}


_cp_config={
    'global':{
        'server.socket_host'  : '0.0.0.0',
        'server.socket_port'  : 1919,
        'tools.mako.directories' : [os.path.join(root_dir,'templates')],
    },
}

if __name__ == '__main__':
    cherrypy.quickstart(Root(), '', config=_cp_config)

index.html:

<html>
        <head>
                <title>Cherrypy Mako Tool Demo</title>
        </head>
        <body>
                ${currentTime}
        </body>
</html>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

CherrypyMako-0.3.1.tar.gz (2.6 kB view hashes)

Uploaded Source

Built Distribution

CherrypyMako-0.3.1-py2.7.egg (4.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page