=== modified file 'demo/demo/templates/index.html' --- demo/demo/templates/index.html 2009-03-27 17:51:33 +0000 +++ demo/demo/templates/index.html 2009-03-31 12:13:47 +0000 @@ -1,4 +1,5 @@ - + + Python Library for Open Flash Chart 2 - Demo @@ -8,7 +9,7 @@ @@ -35,14 +36,16 @@ - - - - + % for i, (kind, text) in enumerate(charts): + + + + + % endfor
- - - -
+ + + +
=== modified file 'demo/demo/utils.py' --- demo/demo/utils.py 2009-03-27 17:17:27 +0000 +++ demo/demo/utils.py 2009-03-31 12:13:47 +0000 @@ -4,7 +4,7 @@ import cherrypy import simplejson -from genshi.template import TemplateLoader +from mako.template import Template def find_resource(package_or_module, *names): @@ -17,9 +17,6 @@ return os.path.abspath(os.path.join(os.path.dirname(ref.__file__), *names)) -__loader = TemplateLoader(auto_reload=True) - - def load_template(template, module=None): if not template: @@ -30,11 +27,13 @@ else: template = os.path.abspath(template) - return __loader.load(template) - - - -def expose(format='xhtml', template=None, content_type='text/html'): + return Template(filename=template) + + +def expose(format='html', template=None, content_type='text/html'): + + if format == 'json': + content_type = 'text/javascript' def expose_wrapper(func): @@ -43,14 +42,14 @@ tmpl = load_template(template, func.__module__) res = func(*args, **kw) + cherrypy.response.headers['content-type'] = content_type + if tmpl: - stream = tmpl.generate(**res) - return stream.render(format) + res = tmpl.render(**res) if format == 'json': - cherrypy.response.headers['content-type'] = 'text/javascript' return simplejson.dumps(res) - + return str(res) func_wrapper.func_name = func.func_name