# Path: airy/core/conf.py
# class Settings(object):
#     def __init__(self, **entries):
#     def __getattribute__(self, name):
# def _ensure_defaults(dsettings, options, project_root, config_filename):
# def _preconfigure(project_root, config_filename='settings.py', argv=[]):
# 
# Path: airy/core/exceptions.py
# class Http404(Exception):
#     "Requested page does not exist"
#     pass
# 
# Path: airy/core/files/uploadedfile.py
# class SimpleUploadedFile(InMemoryUploadedFile):
#     """
#     A simple representation of a file, which just has content, size, and a name.
#     """
#     def __init__(self, name, content, content_type='text/plain'):
#         content = content or ''
#         super(SimpleUploadedFile, self).__init__(StringIO(content), None, name,
#                                                  content_type, len(content), None)
# 
#     def from_dict(cls, file_dict):
#         """
#         Creates a SimpleUploadedFile object from
#         a dictionary object with the following keys:
#            - filename
#            - content-type
#            - content
#         """
#         return cls(file_dict['filename'],
#                    file_dict['content'],
#                    file_dict.get('content-type', 'text/plain'))
#     from_dict = classmethod(from_dict)
# 
# Path: airy/core/reportbug.py
# def report_on_fail(function):
# 
#     def wrapped(ins, *args, **kwargs):
#         try:
#             return function(ins, *args, **kwargs)
#         except:
#             if settings.debug:
#                 raise
#             ReportBug(ins, args=args, kwargs=kwargs)
# 
#     wrapped.__doc__ = function.__doc__
#     wrapped.__name__ = function.__name__
# 
#     return wrapped
# 
# Path: airy/utils/encoding.py
# def smart_unicode(s, encoding='utf-8', strings_only=False, errors='strict'):
#     """
#     Returns a unicode object representing 's'. Treats bytestrings using the
#     'encoding' codec.
# 
#     If strings_only is True, don't convert (some) non-string-like objects.
#     """
#     if isinstance(s, Promise):
#         # The input is the result of a gettext_lazy() call.
#         return s
#     return force_unicode(s, encoding, strings_only, errors)
# 
# Path: airy/utils/functional.py
# def curry(_curried_func, *args, **kwargs):
#     def _curried(*moreargs, **morekwargs):
#         return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))
#     return _curried


import calendar
import logging
import base64
from airy.core.conf import settings
from airy.core.exceptions import Http404
from airy.core.files.uploadedfile import SimpleUploadedFile
from airy.core.reportbug import report_on_fail
from airy.utils.encoding import smart_unicode
from airy.utils.functional import curry
from tornado.web import *
from tornado.escape import *
from tornadio2 import TornadioRouter, SocketConnection, event
from urlparse import urlparse, parse_qs
from urllib2 import unquote
        a unicode string, but this may be overridden in subclasses.

        This method is used as a filter for both get_argument() and for
        values extracted from the url and passed to get()/post()/etc.

        The name of the argument is provided if known, but may be None
        (e.g. for unnamed groups in the url regex).
        """
        return to_unicode(value)


    #
    # Authentication
    #
    @property
    def current_user(self):
        """The authenticated user for this request.

        Determined by either get_current_user, which you can override to
        set the user based on, e.g., a cookie. If that method is not
        overridden, this method always returns None.

        We lazy-load the current user the first time this method is called
        and cache the result after that.
        """
        if not hasattr(self, "_current_user"):
            self._current_user = self.get_current_user()
        return self._current_user

    def get_current_user(self):

# Path: airy/core/conf.py
# class Settings(object):
#     def __init__(self, **entries):
#     def __getattribute__(self, name):
# def _ensure_defaults(dsettings, options, project_root, config_filename):
# def _preconfigure(project_root, config_filename='settings.py', argv=[]):
# 
# Path: airy/core/exceptions.py
# class Http404(Exception):
#     "Requested page does not exist"
#     pass
# 
# Path: airy/core/files/uploadedfile.py
# class SimpleUploadedFile(InMemoryUploadedFile):
#     """
#     A simple representation of a file, which just has content, size, and a name.
#     """
#     def __init__(self, name, content, content_type='text/plain'):
#         content = content or ''
#         super(SimpleUploadedFile, self).__init__(StringIO(content), None, name,
#                                                  content_type, len(content), None)
# 
#     def from_dict(cls, file_dict):
#         """
#         Creates a SimpleUploadedFile object from
#         a dictionary object with the following keys:
#            - filename
#            - content-type
#            - content
#         """
#         return cls(file_dict['filename'],
#                    file_dict['content'],
#                    file_dict.get('content-type', 'text/plain'))
#     from_dict = classmethod(from_dict)
# 
# Path: airy/core/reportbug.py
# def report_on_fail(function):
# 
#     def wrapped(ins, *args, **kwargs):
#         try:
#             return function(ins, *args, **kwargs)
#         except:
#             if settings.debug:
#                 raise
#             ReportBug(ins, args=args, kwargs=kwargs)
# 
#     wrapped.__doc__ = function.__doc__
#     wrapped.__name__ = function.__name__
# 
#     return wrapped
# 
# Path: airy/utils/encoding.py
# def smart_unicode(s, encoding='utf-8', strings_only=False, errors='strict'):
#     """
#     Returns a unicode object representing 's'. Treats bytestrings using the
#     'encoding' codec.
# 
#     If strings_only is True, don't convert (some) non-string-like objects.
#     """
#     if isinstance(s, Promise):
#         # The input is the result of a gettext_lazy() call.
#         return s
#     return force_unicode(s, encoding, strings_only, errors)
# 
# Path: airy/utils/functional.py
# def curry(_curried_func, *args, **kwargs):
#     def _curried(*moreargs, **morekwargs):
#         return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))
#     return _curried


# Path: airy/core/web.py
import calendar
import logging
import base64
from airy.core.conf import settings
from airy.core.exceptions import Http404
from airy.core.files.uploadedfile import SimpleUploadedFile
from airy.core.reportbug import report_on_fail
from airy.utils.encoding import smart_unicode
from airy.utils.functional import curry
from tornado.web import *
from tornado.escape import *
from tornadio2 import TornadioRouter, SocketConnection, event
from urlparse import urlparse, parse_qs
from urllib2 import unquote

        a unicode string, but this may be overridden in subclasses.

        This method is used as a filter for both get_argument() and for
        values extracted from the url and passed to get()/post()/etc.

        The name of the argument is provided if known, but may be None
        (e.g. for unnamed groups in the url regex).
        """
        return to_unicode(value)


    #
    # Authentication
    #
    @property
    def current_user(self):
        """The authenticated user for this request.

        Determined by either get_current_user, which you can override to
        set the user based on, e.g., a cookie. If that method is not
        overridden, this method always returns None.

        We lazy-load the current user the first time this method is called
        and cache the result after that.
        """
        if not hasattr(self, "_current_user"):
            self._current_user = self.get_current_user()
        return self._current_user

    def get_current_user(self):

        for backend_name in getattr(settings, 'authentication_backends', []):