# Path: bnw/core/base.py
# def genid(idlen):
# def cropstring(string, maxlen):
# def _(s, user):
# def get_webui_base(user):
# def get_https_webui_base():
# def get_http_webui_base():
# class BnwResponse(Exception):  # we do it idiotic way!


from base import *
from bnw.core.base import BnwResponse, config
import random
import time
import pymongo.errors
import bnw.core.bnw_objects as objs
# -*- coding: utf-8 -*-


@defer.inlineCallbacks
def throttle_check(user):
    throttle = yield objs.Throttle.find_and_modify({'user': user},{'$inc':{'bucket':1}},upsert=True)
    if throttle and throttle.get('bucket',0) >= config.throttle_bucket_size:

# Path: bnw/core/base.py
# def genid(idlen):
# def cropstring(string, maxlen):
# def _(s, user):
# def get_webui_base(user):
# def get_https_webui_base():
# def get_http_webui_base():
# class BnwResponse(Exception):  # we do it idiotic way!


# Path: bnw/handlers/throttle.py
from base import *
from bnw.core.base import BnwResponse, config
import random
import time
import pymongo.errors
import bnw.core.bnw_objects as objs

# -*- coding: utf-8 -*-


@defer.inlineCallbacks
def throttle_check(user):
    throttle = yield objs.Throttle.find_and_modify({'user': user},{'$inc':{'bucket':1}},upsert=True)
    if throttle and throttle.get('bucket',0) >= config.throttle_bucket_size:

        wtime = ( throttle['bucket'] - config.throttle_bucket_size + 1 ) * config.throttle_leak_speed