def __init__(self, root, logfile=None, prefixURL=None): """`prefixURL` is used by WSGI apps. wsgi.py stores it in appRootURL. It is the HTTP url for the nevow.cgi script""" if logfile is not None: self.log = open(logfile, 'a') if prefixURL: self.application = wsgi.createWSGIApplication(root, prefixURL) else: self.application = wsgi.createWSGIApplication(root)
def handler(req): global request request = req req.content_type = "text/html" from nevow import wsgi wsgiApp = wsgi.createWSGIApplication(Index(), prefix) return run_with_modpy(req, wsgiApp)
def get_wsgi_app(): from nevow.wsgi import createWSGIApplication return createWSGIApplication(pages.Root())
from nevow import rend, loaders, wsgi, tags, inevow class NevowPage(rend.Page): addSlash = True docFactory = loaders.stan( tags.html[ tags.head[tags.title['Nevow WSGI hello app']], tags.body[ tags.h1(id='title')['Nevow WSGI hello app'], tags.p(id='welcome')['Welcome to the Nevow (WSGI powered). Just show your environment.'], tags.p(id='environment')[tags.invisible(render=tags.directive('environ'))] ] ] ) def render_environ(self, context, data): environ = inevow.IRequest(context).environ sorted_keys = environ.keys() sorted_keys.sort() inner = [tags.li[k, " => ", str(environ[k])] for k in sorted_keys] return tags.ul[inner] app = wsgi.createWSGIApplication(NevowPage()) if __name__ == '__main__': import sys import helper server = helper.get_arg(sys.argv, "Usage: nevow_wsgi_app.py package.wsgi.server_callable") server(app)
return T.ul[inner] def childFactory(self, ctx, name): return Index(self.name+'/'+name) docFactory = loaders.stan( T.html[ T.head[T.title['Nevow wsgi Test cgi app']], T.body[ T.h1(render=T.directive('name')), T.invisible(render=T.directive('links')) ] ] ) ######################################################### ######################################################### from nevow import wsgi # Pages for test # 1. Index() - Simple URL test # 2. wsgiApp = wsgi.createWSGIApplication(Index()) run_with_cgi(wsgiApp)