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