There is a new, and perheaps the best, templating language called
Genshi
http://genshi.edgewall.org/
I tried to use it with cherrypy but wihtout success.
I'm a new to python and cherrypy and some obvious things still elude 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"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/"
xmlns:xi="http://www.w3.org/2001/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
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---