Пример #1
0
def load_hashers(password_hashers=None):
    global HASHERS
    global PREFERRED_HASHER

    from webtools.application import get_app
    PASSWORD_HASHERS = get_app().conf.PASSWORD_HASHERS


    hashers = []
    if not password_hashers:
        password_hashers = PASSWORD_HASHERS

    for backend in password_hashers:
        try:
            mod_path, cls_name = backend.rsplit('.', 1)
            mod = importlib.import_module(mod_path)
            hasher_cls = getattr(mod, cls_name)
        except (AttributeError, ImportError, ValueError):
            raise RuntimeError("hasher not found: %s" % backend)
        hasher = hasher_cls()
        if not getattr(hasher, 'algorithm'):
            raise RuntimeError("hasher doesn't specify an "
                                       "algorithm name: %s" % backend)
        hashers.append(hasher)

    HASHERS = dict([(hasher.algorithm, hasher) for hasher in hashers])
    PREFERRED_HASHER = hashers[0]
Пример #2
0
def load_hashers(password_hashers=None):
    global HASHERS
    global PREFERRED_HASHER

    from webtools.application import get_app
    PASSWORD_HASHERS = get_app().conf.PASSWORD_HASHERS

    hashers = []
    if not password_hashers:
        password_hashers = PASSWORD_HASHERS

    for backend in password_hashers:
        try:
            mod_path, cls_name = backend.rsplit('.', 1)
            mod = importlib.import_module(mod_path)
            hasher_cls = getattr(mod, cls_name)
        except (AttributeError, ImportError, ValueError):
            raise RuntimeError("hasher not found: %s" % backend)
        hasher = hasher_cls()
        if not getattr(hasher, 'algorithm'):
            raise RuntimeError("hasher doesn't specify an "
                               "algorithm name: %s" % backend)
        hashers.append(hasher)

    HASHERS = dict([(hasher.algorithm, hasher) for hasher in hashers])
    PREFERRED_HASHER = hashers[0]
Пример #3
0
def get_default_timezone_name(application=None):
    if application is None:
        from webtools.application import get_app
        application = get_app()
    return application.conf.TZ
Пример #4
0
def get_default_timezone_name(application=None):
    if application is None:
        from webtools.application import get_app
        application = get_app()
    return application.conf.TZ