Commits

Fabien Schwebel committed c4c9283

woups, forgot to update in 7f4798b2ba62

  • Participants
  • Parent commits 41be8cb

Comments (0)

Files changed (4)

 * send a 404 from time to time...
 * ... or a 403...
 * ... or even a blank page if you want
+* last but not least, a wonderful ASP.NET error page made just for them
 
 Hey, they deserved it!
 
 
 ### Pros:
 
-* lightweight, design not to slow a single bit your website (from a non-miserable point of view, of course)
+* lightweight, designed not to slow a single bit your website (from a non-miserable point of view, of course)
 * support both IPv4 and IPv6
 
 ### Cons:
 
-* does't currently support masks; yes, it can be handy against users having a botnet under control, or in case of a user having a IPv6 range, but the current implementation favors speed over features
+* does't currently support masks; yes, it can be handy against users having a botnet under control or in case of a user having a IPv6 range, but the current implementation favors speed over features
 
 ## Installation & configuration
 
 * `MISERY_403_PROBABILITY`: same for 403 (default: 10)
 * `MISERY_404_PROBABILITY`: I'm gonna let you guess for this one (default: 10)
 * `MISERY_WHITE_SCREEN_PROBABILITY`: same for a nice, 100% pure white (not a single subpixel in the viewport will be off, I promise) (default: 20)
+* `MISERY_ASP_ERROR_PROBABILITY`: a free bonus for the ASP lovers (and I'm sure they are plenty around here), the template renders just great. Oh and: to make it even more beautiful, it's in French (default: 20). Have a quick look:
+![ASP error overview](http://img11.hostingpics.net/pics/560987ASPerror.png)
 
-## Miscellanous
+By default, the miserable users have therefore approximately a 50-50 chance to see the real page. They won't stay long, I promise.
+
+## Miscellaneous
 
 Inspired by the [Drupal Misery module](http://drupal.org/project/misery), see also ["Suspension, Ban or Hellban?"](http://www.codinghorror.com/blog/2011/06/suspension-ban-or-hellban.html) for hellbanning.

File django_misery/middleware.py

 from django.http import Http404
 from django.core.exceptions import PermissionDenied
 from django.contrib.auth import logout
+from django.shortcuts import render_to_response
 
 from django.db import models
 from models import MiseryIP
 e403Probability = getattr(settings, 'MISERY_403_PROBABILITY', '10')
 e404Probability = getattr(settings, 'MISERY_404_PROBABILITY', '10')
 whiteScreenProbability = getattr(settings, 'MISERY_WHITE_SCREEN_PROBABILITY', '20')
-
+ASPdeathProbability = getattr(settings, 'MISERY_ASP_ERROR_PROBABILITY', '20')
 
 class miserize(object):
     def process_request(self, request):
                 raise Http404
             elif randint(0, 100) <= int(whiteScreenProbability):
                 return HttpResponse("")
+            elif randint(0, 100) <= int(ASPdeathProbability):
+                return render_to_response('django_misery/ASPerror.html')
             # else leave him alone, the poor pal

File django_misery/models.py

-import ipcalc
 import datetime
 
 from django.db import models
     description = ("A simple ban system for Django, that does nasty stuff to trolls wandering on your website."),
     license = "MIT License",
     keywords = "django misery hellban slowban",
-    url = "http://packages.python.org/an_example_pypi_project",
+    url = "https://bitbucket.org/fschwebel/django-misery/",
     packages=['django_misery'],
     long_description=read('README.md'),
     classifiers=[