Basic app

A stand-alone script is provided in examples/standalone.py to test basic features provided by the notmm toolkit!

To start the demo from a shell:

% cd examples
% cp development.ini.sample development.ini
% source ./djangorc 
% python2.7 ./standalone.py

Serving Django apps with the 'wsgiref' module

The wsgiref module is a standard package useful for WSGI development and validation of WSGI applications. It is also a excellent tool to setup a minimal webserver for development of regular Django apps.

Running web applications in development mode

The tools/httpserver.py script provides a convenience wrapper for developers to allow testing the web application using the wsgiref.validate module while in development mode.

Legacy Django applications

To bootstrap LiveStore using the default configuration, use:

% /usr/local/bin/python /usr/local/bin/httpserver.py -d -c /home/steiner/LiveStore-1.0/conf/satchmo_conf.ini --disable-auth --settings=local_settings --pythonpath=/opt/local/django-r13404dev:/home/steiner/LiveStore-1.0:/home/steiner/LiveStore-1.0/contrib:/home/steiner/LiveStore-1.0/lib satchmo_store

Generic WSGI applications

Here a recipe for a generic like web application using a customized development.ini.local file:

% source /etc/djangorc
% cp development.ini development.ini.local
% httpserver.py -c development.ini.local myapp
Using Python base classes for persistence.
memcached support is disabled!
<notmm.dbapi.orm.schevo_compat.XdserverProxy object at 0xa7d0b34>
Initializing on 2012-07-25 14:29:37 EDT -0400
Starting HTTP server on http://gthcfoundation.org:8133/
Please consider donating if you want to support this project!
Visit http://pledgie.com/campaigns/16268 for more info.

Programming URLconf objects using the 'RegexURLMap' API

The notmm.utils.urlmap module provides a experimental API to further extend the Django RegexURLResolver to allow easy decoupling of urls.py files.

add_routes(view_func, *args)

The function RegexURLMap.add_routes is the primary interface for accessing URLconf objects. Note that it takes the same arguments than the patterns function provided in Django.

   1 #!/usr/bin/env python
   2 from notmm.utils.urlmap import RegexURLMap
   3 urlpatterns = RegexURLMap()
   4 urlpatterns.add_routes('myapp.views',
   5     # main index.html document
   6     (r'^$|index.html$', 'index', dict(extra_context=
   7         {'link_set': link_set,
   8          'image_set': image_set}
   9     )))
  10 # Can be repeated indefinitely until commit() has been called
  11 urlpatterns.commit()

include(urlconf)

In addition to add_routes, the RegexURLMap extension provides the include function to include additional URLconf objects from a regular Python module or script:

urlpatterns = RegexURLMap()
urlpatterns.include('company_cms.urls', prefix="^intranet/")

Serving a MoinMoin handler in WSGI mode

Please see /WikiApp for details on configuring MoinMoin using the wikiapp extension! :)

just another Wiki: DjangoHotSauce/Cookbook (last edited 2017-03-02 11:59:24 by anonymous)