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