Hi there.

Over the last week I've been working to improve WSGI support in Django
and I have sent a few patches which have not received the feedback I
expected to have, so I wanted to ping you. ;-)

To be precise, with those patches Django applications would be able to:
 1.- [Ticket 8927] Use WSGI middleware whose API should be dealt with in
the downstream Django application. For example, Django developers could
be able to use Repoze [1] middleware, like repoze.who or repoze.what,
which are widely used in TurboGears and Pylons.
 2.- [Ticket 12075] Use third-party Django-independent libraries which
do stuff based on the URL arguments (not the query string, but those
named and positional arguments in the URL paths; the ones you define in
your `urlpatterns` variable).
 3.- [Ticket 12091] This is the most exciting one. You'd be able to run
WSGI applications in a Django-lesque way. This is, you could "mount"
other applications in your Django views, dynamically, modifying the
request passed on to the WSGI app (as a Django request object) and
modify the application response (as a Django response object), if
needed.

For example, you could serve mercurial/SVN/etc repositories dynamically,
serve Trac install dynamically, etc. With the following Django view you
could mount Trac applications in the URL path /projects/{project-name}/:
=====
# "dosomething" module
import os
import site

from trac.web.main import dispatch_request as TracApp
from django.http import HttpResponse
from django.views.wsgi import call_wsgi_app

os.environ['PYTHON_EGG_CACHE'] = "/foo/bar/sampledjango/_eggs"

site.addsitedir('/bar/foo/Pyenvs/django-dev/lib/python2.5/site-packages')

def projects(request, project_name):
    if not project_name:
        return HttpResponse("Please specify a project in the URL!")

    project_path = "/foo/bar/sampledjango/trackers/%s" % project_name
    
    if not os.path.exists(project_path):
        return HttpResponse("Project %s does not exist!" % project_name)

    request.environ['trac.env_path'] = project_path
    
    return call_wsgi_app(TracApp, request)

# The URL pattern for the view above would be:
# (r'^projects/(?P<project_name>[a-z]+)?', dosomething.projects),
=====

And if you already authenticated the user in your parent Django
application, the "children" WSGI applications will be aware that the
user was authenticated.

Please let me know what you think about it!

Cheers. :)

[1] http://repoze.org/repoze_components.html#middleware
-- 
Gustavo Narea.
Software Developer.
2degrees, Ltd.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to