1 Configuring Apache:
2
3 To configure applications without authenticators, use the config.py script
4 in tools/Apache to set up mod_python applications. For example:
5
6 python tools/Apache/config.py \
7 mod_python \
8 /home/paulb/Software/Python/WebStack/examples/ModPython/CookiesApp/CookiesHandler.py \
9 /etc/apache2/sites-available \
10 cookies-mod \
11 /cookies \
12 .cookies
13
14 This script can also be used to configure CGI applications.
15
16 --------
17
18 The manual approach:
19
20 For each application, add an Alias line to httpd.conf to point to the directory
21 containing the handler package, then specify the appropriate module name as the
22 PythonHandler.
23
24 Alias /simple "/home/paulb/Software/Python/WebStack/examples/ModPython/SimpleApp"
25
26 <Directory "/home/paulb/Software/Python/WebStack/examples/ModPython/SimpleApp">
27 AddHandler python-program .simple
28 PythonHandler SimpleHandler
29 PythonDebug On
30 </Directory>
31
32 It would appear that the directory really should be distinct from others
33 defined for mod_python, and that the handler should have a distinct name from
34 other handlers employed.
35
36 The WebStack package must reside on the PYTHONPATH, along with the package
37 containing the application itself. Therefore, ensure that the handler uses the
38 appropriate entries in sys.path.
39
40 Using the above definition in httpd.conf, only server resources residing
41 directly below "/simple" in the URL "hierarchy" with names ending in ".simple"
42 would be associated with the Simple WebStack application's resources.
43 Therefore, the following URL paths would access the application:
44
45 /simple/home.simple
46 /simple/tasks.simple/my-tasks
47 /simple/agenda.simple/tomorrow/first-thing
48
49 Examples of URL paths not addressing the application are as follows:
50
51 /agenda/my-agenda.simple
52 /simple/tasks/my-tasks.simple
53
54 --------
55
56 Authentication/authorisation in mod_python:
57
58 Apache imposes fairly strict controls over authentication, requiring the
59 addition of various declarations in the configuration in order to impose
60 access controls on applications, and for WebStack authenticators to be used, a
61 "PythonAuthenHandler" must be declared in the application's configuration
62 section.
63
64 Consequently, it is necessary to define authentication methods in the
65 httpd.conf file as in the following example:
66
67 Alias /auth "/home/paulb/Software/Python/WebStack/examples/ModPython/AuthApp"
68
69 <Directory "/home/paulb/Software/Python/WebStack/examples/ModPython/AuthApp">
70 AddHandler python-program .py
71 PythonHandler AuthHandler
72 PythonAuthenHandler AuthHandler
73 PythonDebug On
74 AuthType Basic
75 AuthName "AuthResource"
76 AuthUserFile /usr/local/apache2/conf/users
77 require valid-user
78 </Directory>
79
80 The details of the application's deployment, including the exact pathname of
81 the users file and the appropriate access policy, must obviously be defined
82 according to the actual application concerned.
83
84 --------
85
86 Session storage with mod_python:
87
88 The very simple SessionStore class provided in WebStack.Helpers.Session, and
89 used by the WebStack.ModPython.Transaction class, requires that a directory be
90 created under the Apache server root with the name "WebStack-sessions". Here are
91 some example commands for doing this:
92
93 cd /usr/local/apache2
94 mkdir WebStack-sessions
95 chown username.groupname WebStack-sessions
96
97 The given "username" and "groupname" correspond to the user and group the Apache
98 server assumes when running.