The Artima Developer Community
Sponsored Link

Python Buzz Forum
Composing WSGI Apps

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ian Bicking

Posts: 900
Nickname: ianb
Registered: Apr, 2003

Ian Bicking is a freelance programmer
Composing WSGI Apps Posted: Aug 3, 2005 2:22 AM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Ian Bicking.
Original Post: Composing WSGI Apps
Feed Title: Ian Bicking
Feed URL: http://www.ianbicking.org/feeds/atom.xml
Feed Description: Thoughts on Python and Programming.
Latest Python Buzz Posts
Latest Python Buzz Posts by Ian Bicking
Latest Posts From Ian Bicking

Advertisement

Dave Warnock is feeling enthusiastic about WSGI and Paste, so I thought I'd give a concrete example of what you can do now...

To get an application running under Paste, the first thing is to tell Paste how to make the application. Let's say your setting up the filebrowser application:

framework = 'wareweb'
root_path = '.../Paste/examples/filebrowser'
publish_dir = os.path.join(root_path, 'web')
# This configuration is for the filebrowser app:
browse_path = '/site1/htdocs'

Let's say you put that in site1_fb.conf. From there, you create a server.conf file like:

server = 'wsgiutils'
port = 5000
urlmap['/'] = "site1_fb.conf"

Now you are serving that application alone. What if you want to support another application? Well, let's say you create site2_fb.conf that looks like the first configuration file but with browse_path = '/site2/htdocs'. Then you do:

urlmap['http://site2.com'] = "site2_fb.conf"

This sets up virtual hosting, so any requests to site2.com go to the application described by site2_fb.conf. Lets say you add a wiki application:

urlmap['/wiki'] = 'wiki.conf'

Now */wiki will go to the application you describe there. They'll all be run the same process (or the same set of worker processes if you are running a forking server).

I just added the virtual hosting feature to urlmap a couple days ago. Another feature that would be nice is a way of capturing variables as you go along. Maybe like:

urlmap['host-regex:^(?P<username>[^.]*).myuserblogs.com$'] = ...

Then I'm thinking that we'd add a key to the WSGI request in environ['paste.urlvars']['username'] (though I'd like to standardize the location where we put these kinds of variables that are found during URL resolution).

For the interested there's some more discussion about the configuration aspect on the Web-SIG mailing list; Chris McDonough recently wrote up a related proposal here.

Read: Composing WSGI Apps

Topic: Apache Authentication and Single-Signon Previous Topic   Next Topic Topic: It's Not Another Damn Framework

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use