Edgewall Software
Modify

Opened 20 years ago

Closed 18 years ago

Last modified 12 years ago

#865 closed enhancement (worksforme)

twisted.web handler

Reported by: Tristan Seligmann <mithrandi@…> Owned by: Jonas Borgström
Priority: normal Milestone:
Component: general Version: devel
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

The attached patch adds a twisted.web handler; auth and file uploads are currently non-functional. Sample .rpy and .tac (standalone) scripts are also attached.

Attachments (5)

trac.rpy (110 bytes ) - added by Tristan Seligmann <mithrandi@…> 20 years ago.
Sample .rpy file, place in existing t.w server
trac.tac (359 bytes ) - added by Tristan Seligmann <mithrandi@…> 20 years ago.
Sample .tac file, run with twistd -noy or twistd -oy
tw.patch (4.3 KB ) - added by Tristan Seligmann <mithrandi@…> 20 years ago.
The patch itself
tw.2.patch (8.8 KB ) - added by Tristan Seligmann <mithrandi@…> 19 years ago.
Updated version of patch
tw.3.patch (8.1 KB ) - added by Tristan Seligmann <mithrandi@…> 19 years ago.
Version 3 of patch

Download all attachments as: .zip

Change History (16)

by Tristan Seligmann <mithrandi@…>, 20 years ago

Attachment: trac.rpy added

Sample .rpy file, place in existing t.w server

by Tristan Seligmann <mithrandi@…>, 20 years ago

Attachment: trac.tac added

Sample .tac file, run with twistd -noy or twistd -oy

by Tristan Seligmann <mithrandi@…>, 20 years ago

Attachment: tw.patch added

The patch itself

comment:1 by Jonas Borgström, 20 years ago

Milestone: 0.9
Status: newassigned

Cool, I'll apply the patch and give you commit rights as soon as 0.8 is released and the 0.8-stable branch is created.

comment:2 by Tristan Seligmann <mithrandi@…>, 19 years ago

It's been a while since 0.8 was released, but there doesn't seem to have been any progress here; what's happening?

by Tristan Seligmann <mithrandi@…>, 19 years ago

Attachment: tw.2.patch added

Updated version of patch

comment:3 by Tristan Seligmann <mithrandi@…>, 19 years ago

I've attached an update version of the patch with htdigest auth support. Still no file upload support, because twisted.web throws away the filename when processing file uploads (grr).

comment:4 by Christopher Lenz, 19 years ago

The patch needs updating to the recently refactored web layer. As an advantage, you can know reuse DigestAuth from the trac.web.standalone module, instead of copying the code over.

comment:5 by Tristan Seligmann <mithrandi@…>, 19 years ago

I'm attaching a newly updated patch, that now uses twisted.web2 - file uploads are still broken, pending file upload support in web2.

by Tristan Seligmann <mithrandi@…>, 19 years ago

Attachment: tw.3.patch added

Version 3 of patch

comment:6 by Matthew Good, 19 years ago

Resolution: wontfix
Status: assignedclosed

I think we'll hold off on adding new server frontends until we've added WSGI support, which should make it easier to add and maintain new frontends. See: #1582.

comment:7 by edsuom, 18 years ago

Resolution: wontfix
Status: closedreopened

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)

in reply to:  8 comment:9 by Matthew Good, 18 years ago

Resolution: worksforme
Status: reopenedclosed

Replying to edsuom:

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.

Well, the Twisted project now uses Trac as a WSGI application and #2913, so I think it's safe to say this is working.

comment:10 by Christian Boos, 18 years ago

Is there a recipe somewhere about how to use Trac with Twisted?

in reply to:  10 comment:11 by Christian Boos, 18 years ago

Replying to cboos:

Is there a recipe somewhere about how to use Trac with Twisted?

See comment:ticket:3504:16

comment:12 by Christian Boos, 12 years ago

Milestone: 0.9

(clearing report:35)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jonas Borgström.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jonas Borgström to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.