List Info

Thread: How to use Genshi templating with Cherrypy ?




How to use Genshi templating with Cherrypy ?
user name
2006-09-24 07:45:37
There is a new, and perheaps the best, templating language
called
Genshi
http://genshi.edgewall.or
g/

I tried to use it with cherrypy but wihtout success.
I'm a new t python and cherrypy so obvious things still
illude me 

Does anyone know how to plug Genshi into cherrypy ???

Here is what I tried without any success:
########This is my index.py

import os
import sys
from genshi.template import TemplateLoader
import cherrypy

class Guestbook:
    cherrypy.expose
    def index(self):
	base_path = os.path.dirname(os.path.abspath(__file__))
    	loader = TemplateLoader([base_path])
	tmpl = loader.load('index.html')
	stream = tmpl.generate()
	html = stream.render('xhtml')
	return html

cherrypy.root = Guestbook()
cherrypy.config.update({'sessionFilter.on': True})

if __name__ == '__main__':
	cherrypy.config.update(file="config.txt")
	cherrypy.server.start()


####### Here is my index.html
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "htt
p://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
;
<html xmlns="http://www.w3.org/1999/x
html"
      xmlns:py="http://genshi.edgewall.or
g/"
      xmlnsi=&q
uot;http://www.w3.org/200
1/XInclude"
      lang="en">
 <body>
  <span class="greeting">Hello
Silicon</span>
 </body>
</html>

When I run it cherrypy gets stuck into an infinite loop
displaying the
following, over and over again:

2006/09/24 00:20:20 CONFIG INFO Server parameters:
2006/09/24 00:20:20 CONFIG INFO   server.environment:
development
2006/09/24 00:20:20 CONFIG INFO   server.logToScreen: True
2006/09/24 00:20:20 CONFIG INFO   server.logFile:
2006/09/24 00:20:20 CONFIG INFO   server.protocolVersion:
HTTP/1.0
2006/09/24 00:20:20 CONFIG INFO   server.socketHost:
2006/09/24 00:20:20 CONFIG INFO   server.socketPort: 8080
2006/09/24 00:20:20 CONFIG INFO   server.socketFile:
2006/09/24 00:20:20 CONFIG INFO   server.reverseDNS: False
2006/09/24 00:20:20 CONFIG INFO   server.socketQueueSize: 5
2006/09/24 00:20:20 CONFIG INFO   server.threadPool: 10
Unhandled exception in thread started by
Error in sys.excepthook:


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "cherrypy-users" group.
To post to this group, send email to cherrypy-usersgooglegroups.com
To unsubscribe from this group, send email to
cherrypy-users-unsubscribegooglegroups.com
For more options, visit this group at http://
groups.google.com/group/cherrypy-users
-~----------~----~----~----~------~----~------~--~---

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )