This very simple middleware will set the 'user' attribute of a mod_python request.. this way the username is logged into the apache log ... useful when making webalizer statistics to see the activity of users ..
(http://sct.sphene.net)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | class ModPythonSetLoggedinUser(object):
def process_request(self, request):
if not isinstance(request, ModPythonRequest):
return None
if not hasattr(request, '_req'):
return None
if not hasattr(request, 'user') or not request.user.is_authenticated():
return None
request._req.user = request.user.username
return None
|
More like this
- Add custom fields to the built-in Group model by jmoppel 1 month, 1 week ago
- Month / Year SelectDateWidget based on django SelectDateWidget by pierreben 4 months, 3 weeks ago
- Python Django CRUD Example Tutorial by tuts_station 5 months, 1 week ago
- Browser-native date input field by kytta 6 months, 3 weeks ago
- Generate and render HTML Table by LLyaudet 7 months ago
Comments
Please login first before commenting.