# Path: pybb/util.py
# _MARKUP_ENGINES = {}
# _MARKUP_ENGINES_FORMATTERS = {}
# _MARKUP_ENGINES_QUOTERS = {}
# def resolve_class(name):
# def resolve_function(path):
# def get_markup_engine(name=None):
# def _get_markup_formatter(name=None):
# def _get_markup_quoter(name=None):
# def get_body_cleaner(name):
# def unescape(text):
# def get_pybb_profile(user):
# def get_pybb_profile_model():
# def build_cache_key(key_name, **kwargs):
#     def __init__(self, to, *args, **kwargs):
#     def deconstruct(self, *args, **kwargs):
#     def __call__(self, instance, filename):
# class FilePathGenerator(object):
# 
# Path: pybb/compat.py
# def is_authenticated(user):
#     if django.VERSION > (1, 9):
#         return user.is_authenticated
# 
#     return user.is_authenticated()


import django
from django.utils import translation
from django.db.models import ObjectDoesNotExist
from pybb import util
from pybb.compat import is_authenticated
    from django.utils.deprecation import MiddlewareMixin
                from pybb.signals import user_saved
# -*- coding: utf-8 -*-

from __future__ import unicode_literals


if django.VERSION < (1, 10):  # pragma: no cover
    MiddlewareParentClass = object
else:  # pragma: no cover
    MiddlewareParentClass = MiddlewareMixin


class PybbMiddleware(MiddlewareParentClass):
    def process_request(self, request):
        if is_authenticated(request.user):
            try:
                # Here we try to load profile, but can get error
                # if user created during syncdb but profile model
                # under south control. (Like pybb.Profile).
                profile = util.get_pybb_profile(request.user)
            except ObjectDoesNotExist:
                # Ok, we should create new profile for this user
                # and grant permissions for add posts
                # It should be caused rarely, so we move import signal here
                # to prevent circular import
                user_saved(request.user, created=True)

# Path: pybb/util.py
# _MARKUP_ENGINES = {}
# _MARKUP_ENGINES_FORMATTERS = {}
# _MARKUP_ENGINES_QUOTERS = {}
# def resolve_class(name):
# def resolve_function(path):
# def get_markup_engine(name=None):
# def _get_markup_formatter(name=None):
# def _get_markup_quoter(name=None):
# def get_body_cleaner(name):
# def unescape(text):
# def get_pybb_profile(user):
# def get_pybb_profile_model():
# def build_cache_key(key_name, **kwargs):
#     def __init__(self, to, *args, **kwargs):
#     def deconstruct(self, *args, **kwargs):
#     def __call__(self, instance, filename):
# class FilePathGenerator(object):
# 
# Path: pybb/compat.py
# def is_authenticated(user):
#     if django.VERSION > (1, 9):
#         return user.is_authenticated
# 
#     return user.is_authenticated()


# Path: pybb/middleware.py
import django
from django.utils import translation
from django.db.models import ObjectDoesNotExist
from pybb import util
from pybb.compat import is_authenticated
    from django.utils.deprecation import MiddlewareMixin
                from pybb.signals import user_saved

# -*- coding: utf-8 -*-

from __future__ import unicode_literals


if django.VERSION < (1, 10):  # pragma: no cover
    MiddlewareParentClass = object
else:  # pragma: no cover
    MiddlewareParentClass = MiddlewareMixin


class PybbMiddleware(MiddlewareParentClass):
    def process_request(self, request):
        if is_authenticated(request.user):
            try:
                # Here we try to load profile, but can get error
                # if user created during syncdb but profile model
                # under south control. (Like pybb.Profile).
                profile = util.get_pybb_profile(request.user)
            except ObjectDoesNotExist:
                # Ok, we should create new profile for this user
                # and grant permissions for add posts
                # It should be caused rarely, so we move import signal here
                # to prevent circular import
                user_saved(request.user, created=True)

                profile = util.get_pybb_profile(request.user)