<commit_before>import logging

from flask import request
from flask.ext.acl.predicates import string_predicates
from flask.ext.acl.permissions import string_permissions
from flask.ext.login import current_user, UserMixin, AnonymousUserMixin

from .core.flask import app, auth
from .models import Repo, Group

log = logging.getLogger(__name__)



@auth.context_processor
def provide_user():
    return dict(user=current_user)


@app.before_request
def assert_can_access_url_pieces():
    for v in request.view_args.itervalues():
        if isinstance(v, Repo):
            auth.assert_can('repo.read', v)
        if isinstance(v, Group):
            auth.assert_can('group.read', v)


class Role(object):

    def __init__(self, name):
        self.name = name
    def __repr__(self):
        return '%s(%r)' % (self.__class__.__name__, self.name)<commit_msg>request.view_args doesn't exist on a POST?<commit_after>import logging

from flask import request
from flask.ext.acl.predicates import string_predicates
from flask.ext.acl.permissions import string_permissions
from flask.ext.login import current_user, UserMixin, AnonymousUserMixin

from .core.flask import app, auth
from .models import Repo, Group

log = logging.getLogger(__name__)



@auth.context_processor
def provide_user():
    return dict(user=current_user)


@app.before_request
def assert_can_access_url_pieces():
    for v in (request.view_args or {}).itervalues():
        if isinstance(v, Repo):
            auth.assert_can('repo.read', v)
        if isinstance(v, Group):
            auth.assert_can('group.read', v)


class Role(object):

    def __init__(self, name):
        self.name = name
    def __repr__(self):
        return '%s(%r)' % (self.__class__.__name__, self.name)
{'fraction_non_alphanumeric': 0.10325156873930405, 'fraction_numerical': 0.0, 'mean_word_length': 3.858725761772853, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6910342', 'n_tokens_mistral': 559, 'n_tokens_neox': 533, 'n_words': 140}