<commit_before>import logging
from pyramid.security import Allow

from .models import DBSession, User, Group

log = logging.getLogger(__name__)


class GroupFinder(object):

    _users = {}

    def reset(self):
        self._users = {}

    def __call__(self, login, request):

        if login in self._users:
            return self._users[login]

        user = User.by_login(DBSession(), login)
        if user:
            rv =  [g.name for g in user.groups]
        else:
            rv = []
        self._users[login] = rv
        return rv

groupfinder = GroupFinder()


class RootFactory(object):
    __name__ = None
    __parent__ = None

    _acl = None

    def __init__(self, request):
        log.info(u'[%s] %s %s' % (request.client_addr,
                                  request.method,
                                  request.current_route_url()
                                  ))
        self.__acl__ = self.get_acl(request)<commit_msg>Catch exception to prevent pollution of the logs.<commit_after>import logging
from pyramid.security import Allow

from .models import DBSession, User, Group

log = logging.getLogger(__name__)


class GroupFinder(object):

    _users = {}

    def reset(self):
        self._users = {}

    def __call__(self, login, request):

        if login in self._users:
            return self._users[login]

        user = User.by_login(DBSession(), login)
        if user:
            rv =  [g.name for g in user.groups]
        else:
            rv = []
        self._users[login] = rv
        return rv

groupfinder = GroupFinder()


class RootFactory(object):
    __name__ = None
    __parent__ = None

    _acl = None

    def __init__(self, request):

        ca = request.client_addr
        rm = request.method
        try:
            cru = request.current_route_url()
        except ValueError, e:
            cru = e.message

        log.info(u'[%s] %s %s' % (ca, rm, cru))
        self.__acl__ = self.get_acl(request)
{'fraction_non_alphanumeric': 0.09848484848484848, 'fraction_numerical': 0.0, 'mean_word_length': 1.8835516739446871, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7176704', 'n_tokens_mistral': 590, 'n_tokens_neox': 570, 'n_words': 154}