Edgewall Software

Ticket #865 (closed enhancement: worksforme)

Opened 4 years ago

Last modified 2 years ago

twisted.web handler

Reported by: Tristan Seligmann <mithrandi@…> Owned by: jonas
Priority: normal Milestone: 0.9
Component: general Version: devel
Severity: normal Keywords:
Cc:

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

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

Change History

Changed 4 years ago by Tristan Seligmann <mithrandi@…>

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

Changed 4 years ago by Tristan Seligmann <mithrandi@…>

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

Changed 4 years ago by Tristan Seligmann <mithrandi@…>

The patch itself

  Changed 4 years ago by jonas

  • status changed from new to assigned
  • milestone set to 0.9

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.

  Changed 4 years ago by Tristan Seligmann <mithrandi@…>

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

Changed 4 years ago by Tristan Seligmann <mithrandi@…>

Updated version of patch

  Changed 4 years ago by Tristan Seligmann <mithrandi@…>

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).

  Changed 4 years ago by cmlenz

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.

  Changed 4 years ago by Tristan Seligmann <mithrandi@…>

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

Changed 4 years ago by Tristan Seligmann <mithrandi@…>

Version 3 of patch

  Changed 3 years ago by mgood

  • status changed from assigned to closed
  • resolution set to wontfix

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.

  Changed 3 years ago by edsuom

  • status changed from closed to reopened
  • resolution wontfix deleted

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   Changed 2 years ago by mgood

  • status changed from reopened to closed
  • resolution set to worksforme

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.

follow-up: ↓ 11   Changed 2 years ago by cboos

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

in reply to: ↑ 10   Changed 2 years ago by cboos

Replying to cboos:

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

See comment:ticket:3504:16

Add/Change #865 (twisted.web handler)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
to The owner will change from jonas. Next status will be 'closed'
 
Note: See TracTickets for help on using tickets.