#865: twisted.web handler
------------------------------------------------------------+---------------
Reporter: Tristan Seligmann <[EMAIL PROTECTED]> | Owner: jonas
Type: enhancement | Status:
reopened
Priority: normal | Milestone:
Component: general | Version:
devel
Severity: normal | Resolution:
Keywords: |
------------------------------------------------------------+---------------
Changes (by edsuom):
* status: closed => reopened
* resolution: wontfix =>
Comment:
I access trac as a WSGI resource of my twisted.web2 HTTP server, and
everything seems to be working fine. The only exception is bug #2913,
which is a result of trac running in a persistent Python process when
accessed via ''tracd'' or WSGI.
Here's the code I use:
{{{
# Access Trac from Twisted Web2 via WSGI
# This snippet of fairly obvious code written by Edwin A. Suominen
# and hereby dedicated to the public domain.
from twisted.web2.wsgi import WSGIResource
import trac.web.main
class TracResource(WSGIResource):
"""
I provide a Trac site for a specified path via a WSGI gateway.
The WSGI application is L{trac.web.main.dispatch_request}, the 'Main
entry
point for the Trac web interface.' It has the following required
WSGI-compliant parameters:
environ: the WSGI environment dict
start_response: the WSGI callback for starting the response
"""
def __init__(self, path):
self.path = path
WSGIResource.__init__(self, self.tracApplication)
def tracApplication(self, environ, start_response):
"""
This method is the callable object that provides access to my
particular Trac environment via WSGI.
"""
environ['trac.env_path'] = self.path
return trac.web.main.dispatch_request(environ, start_response)
}}}
--
Ticket URL: <http://projects.edgewall.com/trac/ticket/865>
The Trac Project <http://trac.edgewall.com/>
_______________________________________________
Trac-Tickets mailing list
[email protected]
http://lists.edgewall.com/mailman/listinfo/trac-tickets