Commits

EGh5 committed 60c8ebc

minors

Comments (0)

Files changed (2)

doorkeeper/middleware.py

 
 class DoorkeeperMiddleware(object):
     def process_request(self, request):
-    """
-    Each request is investigated. 
-    """
+        """
+          Each request is investigated.
+        """
         sagent = request.META.get('HTTP_USER_AGENT',"n/a")
         saddr = request.META.get('REMOTE_ADDR',"n/a")
         shash = "%s %s"% (saddr, sagent)
         try:
             br=BotRecord.objects.get(bot_hash=shash) # if client exists in BotRecords
-            now=datetime.datetime.now()              
+            now=datetime.datetime.now()
             if br.detention_upto:                    # check detention end time
                 if br.detention_upto> now:           # fresh banned client
                     raise Http404()                  # bounce - it's active bad bot!

doorkeeper/views.py

 # Create your views here.
-from django.http import HttpResponseNotFound
+from django.http import Http404
 
 from models import BotRecord
 import datetime
 
 def inspect(request):
     """
-    View to regiter suspicious client and raise Http404
-    
+    View to register suspicious client and raise Http404
+
     """
     sagent  =request.META.get('HTTP_USER_AGENT',"n/a")
     saddr=request.META.get('REMOTE_ADDR',"n/a")
                 br.detention_upto=now+delta
                 br.jail_count+=1
         br.save()
-        
     except BotRecord.DoesNotExist:
         br=BotRecord.objects.create(bot_hash=shash,bot_name=sagent, bot_adr=saddr)
         br.save()