WebStack

docs/Django/NOTES.txt

579:803bd742ff85
2006-11-06 paulb [project @ 2006-11-06 20:52:21 by paulb] Updated the documentation with details of APPEND_SLASH and authentication.
     1 WebStack supports Django in the sense that WebStack applications can be
     2 deployed within Django instances according to the guidelines described in the
     3 Django documentation plus a few caveats. Here is the basic process:
     4 
     5  1. Create a Django instance or find an existing instance to use.
     6  2. Create or find an application where WebStack resources and applications
     7     shall be deployed.
     8  3. Add URL mappings to the instance's urls.py file - see below for a
     9     description of how this should be done.
    10  4. Add WebStack handlers to the application directory.
    11  5. Add the application to the INSTALLED_APPS definition in the settings.py
    12     file.
    13  6. Add the APPEND_SLASH setting to the settings.py file.
    14  7. Configure Django in mod_python.
    15 
    16 Create a Django instance
    17 ------------------------
    18 
    19 For example:
    20 
    21 django-admin.py startproject djangoinstance
    22 
    23 Create an application
    24 ---------------------
    25 
    26 For example:
    27 
    28 cd djangoinstance
    29 mkdir webstack
    30 
    31 Add URL mappings
    32 ----------------
    33 
    34 The docs/Django/urls.py file contains definitions for the example applications
    35 based on a Django instance called "djangoinstance" (in a directory of that
    36 name) and the "webstack" application (in a directory of that name within the
    37 instance). The urls.py file employs URL patterns to direct requests to each of
    38 the examples.
    39 
    40 Consider the auth example - the following pattern is employed to detect
    41 requests intended for it:
    42 
    43 ^django/webstack/auth(?P<vp>/.*)?
    44 
    45 Here, the example will be accessible via a URL like this:
    46 
    47 http://localhost/django/webstack/auth
    48 
    49 Additional path information is captured by a special named regular expression
    50 group which is used within the WebStack adapter.
    51 
    52 WebStack handlers and adapters
    53 ------------------------------
    54 
    55 The handlers from examples/Django should be copied into or otherwise linked to
    56 from the "webstack" application directory within the Django instance. Each
    57 handler should contain a function, produced by calling the special deploy
    58 function from the Django adapter, with a name as stated in the urls.py file.
    59 
    60 Consider the auth example - the following path to the resource is stated:
    61 
    62 djangoinstance.webstack.authapp.auth
    63 
    64 Here, within the instance and application, the "authapp" handler (provided by
    65 the authapp.py from examples/Django) must contain a function called "auth".
    66 
    67 Add the application to the settings
    68 -----------------------------------
    69 
    70 For example:
    71 
    72 INSTALLED_APPS = (
    73     'django.contrib.auth',
    74     'django.contrib.contenttypes',
    75     'django.contrib.sessions',
    76     'django.contrib.sites',
    77     'djangoinstance.webstack', # Application added here!
    78 )
    79 
    80 Prevent Django from adding slash characters:
    81 
    82 APPEND_SLASH = 0
    83 
    84 Django and mod_python
    85 ---------------------
    86 
    87 For example:
    88 
    89 <Location "/django/">
    90     SetHandler python-program
    91     PythonHandler django.core.handlers.modpython
    92     SetEnv DJANGO_SETTINGS_MODULE djangoinstance.settings
    93     PythonDebug On
    94     PythonPath "['/home/paulb/Software/Python', '/home/paulb/Software/Python/WebStack', '/home/paulb/Software/Python/WebStack/examples/Common'] + sys.path"
    95 </Location>
    96 
    97 Django and authentication
    98 -------------------------
    99 
   100 Whilst Django has its own authentication scheme, WebStack preserves the
   101 standard HTTP notion of a user as provided via the HTTP authentication
   102 mechanisms. Thus, the get_user method on the Transaction object does not
   103 currently access Django's underlying authentication machinery.