Ksenia Marasanova wrote: > Sorry if this is a trivial question, but does it sounds reasonable to > use WSGI for "pluggable" standard applications, instead of usual > Python imports? For example, standard news module, like: > > app = NewsApp(path='/site/news/') > > The content of news app would be inserted into site template, > generated by main publisher. If there are any examples of such WSGI > use, I'll be glad to hear that...
I think you are describing something along the lines of what Paste Deploy is doing (http://pythonpaste.org/deploy/paste-deploy.html). It uses Eggs with entry points (though plain imports are also allowed). So if you have a news application, you'd add this to its setup.py: setup( name="NewsApp", ... entry_points={ 'paste.app_factory': 'main=news.wsgiapp:make_app'}) news.wsgiapp looks like: def make_app(global_conf, database): # database is a required configuration variable specific to news # you return a plain WSGI application here Then to deploy it, you create a configuration file (lets say site.ini): [composit:main] use = egg:Paste#urlmap /site/news = news /site/wiki = wiki / = static [app:news] use = egg:NewsApp database = sqlite:/path/to/db [app:wiki] use = egg:MoinMoin [app:static] use = egg:Paste#static document_root = /var/www Then to use the configuration file you do: from paste.deploy import loadapp app = loadapp('config:/path/to/site.ini') # app is now a WSGI application that dispatches # based on URL to the three configured applications Or you can do: paster serve site.ini At least this will work if you define a server in the config file, like: [server:main] use = egg:PasteScript#wsgiutils port = 8000 _______________________________________________ Web-SIG mailing list Web-SIG@python.org Web SIG: http://www.python.org/sigs/web-sig Unsubscribe: http://mail.python.org/mailman/options/web-sig/archive%40mail-archive.com