예제 #1
0
    def before_dispatch(self, *args):
        user = users.get_current_user()
        if user:
            UserHelper.inject_params(user)
            self.user = user

        login_url = ''
        logout_url = ''

        if user:
            logout_url = users.create_logout_url("/")
        else:
            login_url = users.create_login_url("/user")

        # allow gmail user only
        r_gmail = re.compile("@gmail\.com$", re.IGNORECASE)
        if user and not r_gmail.search(user.email()):
            self.error_response(302, redirect_to=logout_url)

        self.stash = {
            'h': self,
            'user': user,
            'login_url': login_url,
            'logout_url': logout_url,
        }

        self.data = None
        self.schema = None
예제 #2
0
 def load_data(self, owner_name, schema_name, data_key, use_cache=False):
     data = None
     schema_name = urllib.unquote(schema_name).decode('utf-8')
     try:
         data = Data.retrieve(owner_name, schema_name, data_key, use_cache)
         if data and data.schema and ((UserHelper.extract_user_name(data.schema.owner)) != owner_name or (data.schema.name != schema_name)):
             self.error_response(400, log_msg="")
     except BadKeyError, message:
         data = None
예제 #3
0
    def owner(self):
        owner = None
        if self.data:
            owner = self.data.owner
            UserHelper.inject_params(owner)
        elif self.schema:
            owner = self.schema.owner
            UserHelper.inject_params(owner)
        elif self.stash.has_key('owner'):
            owner = self.stash['owner']
            UserHelper.inject_params(owner)
        else:
            owner = self.user

        return owner