Login

Middleware to log username into apache logs with mod_python

Author:
kahless
Posted:
March 1, 2007
Language:
Python
Version:
Pre .96
Score:
2 (after 2 ratings)

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

  1. get_object_or_none by azwdevops 7 hours, 15 minutes ago
  2. Mask sensitive data from logger by agusmakmun 1 month, 3 weeks ago
  3. Template tag - list punctuation for a list of items by shapiromatron 1 year, 4 months ago
  4. JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 1 year, 4 months ago
  5. Serializer factory with Django Rest Framework by julio 1 year, 11 months ago

Comments

Please login first before commenting.