# Path: modules/user/model/session.py
# class UserSession(AbstractSession):
#     namespace = 'user'
# 
#     def isLogged(self):
#         if 'user_key' in self:
#             return True
#         else:
#             return False
# 
#     def getUser(self):
#         if 'user_key' in self:
#             user = User.get(self['user_key'])
#             if not user:
#                 raise BaseException('User with key %s not found' % (self['user_key']))
#             return user
#         return False
# 
#     def setUserAsLogged(self, user):
#         self['user_key'] = str(user.key())
# 
#     def setUserAsLoggedByKey(self, key):
#         self['user_key'] = key
# 
# Path: lib/registry.py
# class Registry(dict):
#     def set(self, key, value):
#         self[key] = value
#     def get(self, key):
#         if self.has_key(key):
#             return self[key]
#         else:
#             return False


from modules.user.model.session import UserSession
from google.appengine.ext import webapp
from lib.registry import Registry
        if not UserSession().isLogged():
            raise BaseException('You are not authorized')
        return f(*args, **kwargs)

    return _inner

#decorator
def guest_only(f):
    def _inner(*args, **kwargs):
        if UserSession().isLogged():
            raise BaseException('You are not authorized')
        return f(*args, **kwargs)

    return _inner

#decorator
def is_admin(f):
    def _inner(*args, **kwargs):
        if not UserSession().isLogged() or not UserSession().getUser().is_admin:
            raise BaseException('You are not authorized')
        return f(*args, **kwargs)

    return _inner

class RequestHandler(webapp.RequestHandler):
      def initialize(self, *args, **kwargs):
          super(RequestHandler, self).initialize(*args, **kwargs)

          Registry().set('request', self.request)
          Registry().set('response', self.response)

# Path: modules/user/model/session.py
# class UserSession(AbstractSession):
#     namespace = 'user'
# 
#     def isLogged(self):
#         if 'user_key' in self:
#             return True
#         else:
#             return False
# 
#     def getUser(self):
#         if 'user_key' in self:
#             user = User.get(self['user_key'])
#             if not user:
#                 raise BaseException('User with key %s not found' % (self['user_key']))
#             return user
#         return False
# 
#     def setUserAsLogged(self, user):
#         self['user_key'] = str(user.key())
# 
#     def setUserAsLoggedByKey(self, key):
#         self['user_key'] = key
# 
# Path: lib/registry.py
# class Registry(dict):
#     def set(self, key, value):
#         self[key] = value
#     def get(self, key):
#         if self.has_key(key):
#             return self[key]
#         else:
#             return False


# Path: modules/core/model/app.py
from modules.user.model.session import UserSession
from google.appengine.ext import webapp
from lib.registry import Registry

        if not UserSession().isLogged():
            raise BaseException('You are not authorized')
        return f(*args, **kwargs)

    return _inner

#decorator
def guest_only(f):
    def _inner(*args, **kwargs):
        if UserSession().isLogged():
            raise BaseException('You are not authorized')
        return f(*args, **kwargs)

    return _inner

#decorator
def is_admin(f):
    def _inner(*args, **kwargs):
        if not UserSession().isLogged() or not UserSession().getUser().is_admin:
            raise BaseException('You are not authorized')
        return f(*args, **kwargs)

    return _inner

class RequestHandler(webapp.RequestHandler):
      def initialize(self, *args, **kwargs):
          super(RequestHandler, self).initialize(*args, **kwargs)

          Registry().set('request', self.request)
          Registry().set('response', self.response)

          Registry().set('session', self.request.environ['beaker.session'])