def cache(self, cache_id): if cache_id not in self._caches: import dogpile.cache import dogpile.cache.util # pylint: disable=not-context-manager with _cache_creation_lock: if cache_id not in self._caches: cache = dogpile.cache.make_region( key_mangler=(lambda key: dogpile.cache.util. sha1_mangle_key(key.encode())), ) cache.configure(**get_config('caching.' + cache_id)) self._caches[cache_id] = cache return self._caches[cache_id]
def cache(self, cache_id): if cache_id not in self._caches: import dogpile.cache import dogpile.cache.util # pylint: disable=not-context-manager with _cache_creation_lock: if cache_id not in self._caches: cache = dogpile.cache.make_region( key_mangler=( lambda key: dogpile.cache.util.sha1_mangle_key(key.encode()) ), ) cache.configure(**get_config('caching.' + cache_id)) self._caches[cache_id] = cache return self._caches[cache_id]
import socket import time import os import shutil import tempfile import requests import six import beanbag.bbexcept import logging log = logging.getLogger(__name__) import dogpile.cache cache = dogpile.cache.make_region() cache.configure('dogpile.cache.memory', expiration_time=300) session = requests.Session() def get_group_pk(pdc, target_group): """ Return the primary key int identifier for a component group. """ # List all of our component groups groups = pdc.get_paged(pdc['component-groups']._) ignored_keys = ['components'] for group in groups: # Iterate over them until we find "the one" if all([ group[key] == target_group[key] for key in target_group
import os import shutil import tempfile import requests import requests_kerberos import six import beanbag.bbexcept import logging log = logging.getLogger(__name__) import dogpile.cache cache = dogpile.cache.make_region() cache.configure('dogpile.cache.memory', expiration_time=300) session = requests.Session() def get_group_pk(pdc, target_group): """ Return the primary key int identifier for a component group. """ # List all of our component groups groups = pdc.get_paged(pdc['component-groups']._) ignored_keys = ['components'] for group in groups: # Iterate over them until we find "the one" if all([ group[key] == target_group[key] for key in target_group
# FAS for usernames. FAS2 = AccountSystem( APP.config['FAS_BASE_URL'], username=APP.config['FAS_USERNAME'], password=APP.config['FAS_PASSWORD'], insecure=not APP.config['FAS_CHECK_CERT'] ) # modular imports from fedora_elections import models SESSION = models.create_session(APP.config['DB_URL']) from fedora_elections import forms cache = dogpile.cache.make_region() cache.configure(**APP.config['DOGPILE_CACHE']) from fedora_elections.utils import build_name_map def is_authenticated(): ''' Return a boolean specifying if the user is authenticated or not. ''' return hasattr(flask.g, 'fas_user') and flask.g.fas_user is not None def is_safe_url(target): """ Checks that the target url is safe and sending to the current website not some other malicious one. """ ref_url = urlparse(flask.request.host_url) test_url = urlparse(