from cookbook.cookbook import test as test_cookbook
try:
+ import jinja2
import cherrypy
from cookbook.server import Server
from cookbook.server import test as test_server
template_dir = os.path.join(module_dir, 'template')
config = os.path.join(module_dir, 'config')
s = Server(c, template_dir)
- cherrypy.config.update({ # http://www.cherrypy.org/wiki/ConfigAPI
- 'server.socket_host': options.address,
- 'server.socket_port': int(options.port),
- 'tools.encode.on': True,
- 'tools.encode.encoding': 'utf8',
- 'tools.staticdir.root': static_dir
- })
- app_config = { '/static': { 'tools.staticdir.on': True,
- 'tools.staticdir.dir': '', } }
- cherrypy.quickstart(root=s, config=app_config)
- sys.stderr.write('Saving cookbook\n')
+ if cherrypy.__version__.startswith('3.'):
+ cherrypy.config.update({ # http://www.cherrypy.org/wiki/ConfigAPI
+ 'server.socket_host': options.address,
+ 'server.socket_port': int(options.port),
+ 'tools.encode.on': True,
+ 'tools.encode.encoding': 'utf8',
+ 'tools.staticdir.root': static_dir,
+ })
+ app_config = { '/static': { 'tools.staticdir.on': True,
+ 'tools.staticdir.dir': '', } }
+ cherrypy.quickstart(root=s, config=app_config)
+ elif cherrypy.__version__.startswith('2.'):
+ cherrypy.root = s
+ cherrypy.config.update({
+ 'server.environment': 'production',
+ 'server.socket_host': options.address,
+ 'server.socket_port': int(options.port),
+ 'encoding_filter.on': True,
+ 'encodinf_filter.encoding': 'utf8',
+ 'static_filter.on': True,
+ 'static_filter.dir': static_dir,
+ })
+ import pprint
+ pprint.pprint(cherrypy.config.configs)
+ cherrypy.server.start()
s.cleanup()