Snippet List
This is a piece of middleware that reports the logged-in user back to Apache. This should cause the logged-in user to be present in the apache access log.
Put it in `settings.MIDDLEWARE_CLASSES` after `AuthenticationMiddleware`.
This has been tested with mod_python but does [not work with wsgi](http://groups.google.com/group/modwsgi/browse_thread/thread/8785a99d4ba7ee99).
The solution is based on [dballanc's snippet](http://www.djangosnippets.org/snippets/420/).
Can easily be combined with any of the [SQL tracing solutions](http://www.djangosnippets.org/tags/debug/).
You might want to run a separate logging server and redirect your logs there. Please refer to the [logging reference manual](http://docs.python.org/lib/module-logging.html).
- log
- mod_python
- debug
- logging
- fcgi
This handler is useful if you serve static/media files directly from Apache only to authenticated users. It checks if a user is not anonymous (and therefore logged in) and redirects to the login site if needed.
The following apache config activates the handler:
<Location "/site_media/company1">
#SetHandler None ##Uncomment if you serve static files in the same virtual host
PythonOption DJANGO_SETTINGS_MODULE mysite.settings
PythonAuthenHandler mysite.myhandler
PythonPath "['/path/to/project'] + sys.path"
Require valid-user
</Location>
- apache
- mod_python
- auth
- static
4 snippets posted so far.