Opened 7 years ago

Closed 5 years ago

#4947 enhancement closed wontfix (wontfix)

Routes dispatching in twisted.web.server

Reported by: Zach Owned by:
Priority: low Milestone:
Component: web Keywords:
Cc: jknight Branch:

Description (last modified by Tom Prince)

It would be nice to have an option to use Routes-based dispatching in twisted.web.server.

Something like:

from twisted.web.server import Site

class Controller(object):

    def index(self, request):

        return '<html><body>Hello World!</body></html>'

c = Controller()

dispatcher = Dispatcher()

dispatcher.connect(name='index', route='/', controller=c,

factory = Site(dispatcher)

You would then also be able to do stuff like this:

from twisted.web.static import File

dispatcher.putChild('static', File(static_path))

We could adapt something like; we're using this for several internal webservices at work and it's quite nice to program in. : )

Change History (6)

comment:1 Changed 7 years ago by DefaultCC Plugin

Cc: jknight added

comment:2 Changed 7 years ago by Glyph

Description: modified (diff)

Fixing markup

comment:3 Changed 7 years ago by Glyph

Would you mind renaming 'twistedroutes' to 'txroutes' until we include it in the core?

comment:4 Changed 7 years ago by Zach

Not at all, you can now find it here:

comment:5 Changed 5 years ago by Tom Prince

Description: modified (diff)
Priority: normallow is also related.

I think given the diversity of implementations, this is perhaps something that should live outside twisted proper.

comment:6 Changed 5 years ago by Jean-Paul Calderone

Resolution: wontfix
Status: newclosed

Such an API could be part of Twisted, if anyone demonstrates they have a good implementation that a lot of people were happy with, and which many people would benefit from having included in Twisted (simplified deployment story or some implementation enhancement which is only possible by maintaining the code in lockstep with the rest of Twisted Web).

Otherwise there doesn't seem to be much problem caused by distributing these things separately.

Please feel free to re-open in case something qualifies according to my first paragraph.

Note: See TracTickets for help on using tickets.