Beispiel #1
0
 def __init__(self, app):
     cache_type = app.config.get('CACHE_TYPE')
     if cache_type == 'memcached':
         host = app.config.get('MEMCACHE_HOST')
         self._cache = cache.MemcachedCache([host])
     elif cache_type == 'appengine':
         self._cache = cache.MemcachedCache()
     elif cache_type == 'local':
         self._cache = cache.SimpleCache()
     else:
         self._cache = cache.NullCache()
Beispiel #2
0
def configure_cache(app):
    if app.config['CACHE_TYPE'] == 'memcached':
        app.cache = cache.MemcachedCache(
            app.config['CACHE_MEMCACHED_SERVERS'],
            key_prefix=app.config.get('CACHE_KEY_PREFIX') or '',
        )

    elif app.config['CACHE_TYPE'] == 'redis':
        kwargs = {
            'host': app.config['CACHE_REDIS_HOST'],
            'port': app.config['CACHE_REDIS_PORT'],
        }

        if app.config['CACHE_REDIS_PASSWORD']:
            kwargs['password'] = app.config['CACHE_REDIS_PASSWORD']

        if app.config['CACHE_REDIS_DB'] is not None:
            kwargs['db'] = app.config['CACHE_REDIS_DB']

        if app.config['CACHE_KEY_PREFIX']:
            kwargs['key_prefix'] = app.config['CACHE_KEY_PREFIX']

        app.cache = cache.RedisCache(**kwargs)

    elif app.config['CACHE_TYPE'] == 'filesystem':
        app.cache = cache.FileSystemCache(app.config['CACHE_DIR'])

    elif app.config['CACHE_TYPE'] == 'null':
        app.cache = cache.NullCache()

    else:
        raise ValueError('Unknown cache type: {}'.format(
            app.config['CACHE_TYPE']))
Beispiel #3
0
        def make_cache(self, xprocess, request):
            def preparefunc(cwd):
                return '', ['memcached']

            xprocess.ensure('memcached', preparefunc)
            c = cache.MemcachedCache(key_prefix='werkzeug-test-case:')
            request.addfinalizer(c.clear)
            return lambda: c
Beispiel #4
0
 def cache(self):
     if utils.is_appengine():
         return werkzeug_cache.MemcachedCache(default_timeout=0)
     return werkzeug_cache.SimpleCache(default_timeout=0)
Beispiel #5
0
 def make_cache(self):
     c = cache.MemcachedCache(key_prefix='werkzeug-test-case:')
     yield lambda: c
     c.clear()
Beispiel #6
0
 def make_cache(self):
     return cache.MemcachedCache(key_prefix='werkzeug-test-case:')
Beispiel #7
0
    None: __cache_module.NullCache,
    'memcached': __cache_module.MemcachedCache,
    'redis': __cache_module.RedisCache
}

__cache_uri = os.environ.get('CACHE_SERVICE')

if __cache_uri:
    try:
        # example __cache_uri is 'redis:dev_redis_1:6379'
        [__cache_type, __url, __port] = __cache_uri.split(':')
    except ValueError as e:
        raise ImproperlyConfigured(
            'CACHE_SERVICE is wrongly formatted. Use "redis:dev_redis_1:6379" as example.'
        )
    if __cache_type == 'redis':
        cache = __cache_module.RedisCache(
            host=__url,
            port=__port,
            default_timeout=os.environ.get('CACHE_TIMEOUT'))
    elif __cache_type == 'memcached':
        cache = __cache_module.MemcachedCache(
            servers=["{url}:{port}".format(url=__url, port=__port)],
            default_timeout=os.environ.get('CACHE_TIMEOUT'))
    else:
        raise ImproperlyConfigured(
            'Unknown cache service, only Memcached and Redis are supported at the moment.'
        )
else:
    cache = __cache_module.NullCache
Beispiel #8
0
Module:             %(module)s
Function:           %(funcName)s
Time:               %(asctime)s

Message:

%(message)s
'''))
    mail_handler.setLevel(logging.ERROR)
    LOG.addHandler(mail_handler)

app.jinja_env.hamlish_mode = 'indented'
app.jinja_env.autoescape = True

app.cache = cache.MemcachedCache(
    [app.config['MEMCACHED_HOST']],
    default_timeout=app.config['MEMCACHED_TIMEOUT'],
    key_prefix='focus')

app.session_interface = flask_memcache_session.Session()


# SMTP
mail = mail_module.Mail(app)

from focus.views.blueprints import global_views
from focus.views.blueprints import images
from focus.views.blueprints import security_groups
from focus.views.blueprints import project_views
from focus.views.blueprints import ssh_keys
from focus.views.blueprints import users_management
from focus.views.blueprints import tariffs