def __init__(self): self.moderator = Moderator.get_moderator() if self.moderator.use_memcached: # if settings.USE_CACHING: # For those who develop on windows and not able to beat the drum import memcache self.mc = memcache.Client([settings.MEMCACHED_HOST], debug=1)
def _decorated(*args, **kwargs): # if settings.USE_CACHING: if Moderator.get_moderator().use_memcached: request = args[0] if not CachedRequests.get().can_i_create_claim(request): if not request.user.is_anonymous(): claims_to_mark = Claim.objects.filter(complainer=request.user).order_by("-created")[ : Moderator.get_moderator().claims_per_hour ] for claim in claims_to_mark: claim.moderation = "suspicous" claim.save() return HttpResponse(status=403) else: return view(*args, **kwargs) else: return view(*args, **kwargs)
def __init__(self): self.moderator = Moderator.get_moderator() super(PostThrottle, self).__init__()