Exemplo n.º 1
0
 def post(self,*k,**kk):
     if request.args.get('confirmed'):
         return response_ok(message="Item deleted")
     else:
         return response_request_confirmation(
             message="Are you sure?",
             confirmation_url=url_for('.action_with_confirmation',confirmed=1)
         )
Exemplo n.º 2
0
 def post(self, *k, **kk):
     if request.args.get('confirmed'):
         return response_ok(message="Item deleted")
     else:
         return response_request_confirmation(
             message="Are you sure?",
             confirmation_url=url_for('.action_with_confirmation',
                                      confirmed=1))
Exemplo n.º 3
0
    def dispatch_request(self, *args, **kwargs):
        #check permissions, if something failed will quit
        self.setEnv()

        ret = False
        error = False

        try:
            if not self.check_permissions(*args, **kwargs):
                ret = self.permission_response
        except PermissionDeniedException as e:
            ret = e.return_response
            if request.url == self.tracker.current:
                self.tracker.rollback_referrer()  #infinite loop protection
            error = e.error

        if not ret:
            try:
                ret = self.prepare(*args, **kwargs)
            except RedirectException as e:
                ret = redirect(e.location)
            except ResponseException as e:
                ret = e.response
            except ResponseErrorException as e:
                error = e.error
            except PermissionDeniedException as e:
                ret = e.return_response
                error = e.error

        if not ret and not error:
            #actual response is being serving by requested method name(get/post/etc)
            if self.track and self.method == 'html':
                self.tracker.update_referrer(
                )  #update tracker only on html pages
                if session.has_key(
                        'login_url'
                ):  #after login redirect made by this session var, delete it now
                    del session['login_url']

            try:
                ret = super(MainPage, self).dispatch_request(*args, **kwargs)
                #sucessfull request
            except ResponseErrorException as e:
                error = e.error
            except PermissionDeniedException as e:
                ret = e.return_response
                error = e.error
            #response should be returned in type set by method

        if self.method == 'modal':
            if error:
                #return JS based error
                return response_error(error=error)
            if isinstance(ret, BaseResponse):
                #if response is redirect return it with all required settings
                if ret.headers.get('Location'):
                    return response_redirect(
                        redirect_to=ret.headers.get('Location'),
                        in_modal=self.redirect_in_modal,
                        remember_modal=self.remember_modal)
            else:
                #everything fine, show response
                return response_ok(data=ret, force_modal=True)

        if error:  #got some error, return to current page (tracker was not updated) and show error
            session['error'] = error
            return redirect(self.tracker.current)

        return ret
Exemplo n.º 4
0
 def post(self,*k,**kk):
     return response_ok(message="Action submitted")
Exemplo n.º 5
0
 def post(self, *k, **kk):
     return response_ok(message="Action submitted")
Exemplo n.º 6
0
    def dispatch_request(self, *args, **kwargs):
        #check permissions, if something failed will quit
        self.setEnv()

        ret=False
        error=False


        try:
            if not self.check_permissions(*args,**kwargs):
                ret=self.permission_response
        except PermissionDeniedException as e:
            ret=e.return_response
            if request.url==self.tracker.current:
                self.tracker.rollback_referrer() #infinite loop protection
            error=e.error


        if not ret:
            try:
                ret=self.prepare(*args,**kwargs)
            except RedirectException as e:
                ret=redirect(e.location)
            except ResponseException as e:
                ret=e.response
            except ResponseErrorException as e:
                error=e.error
            except PermissionDeniedException as e:
                ret=e.return_response
                error=e.error

        if not ret and not error:
            #actual response is being serving by requested method name(get/post/etc)
            if self.track and self.method=='html':
                self.tracker.update_referrer()  #update tracker only on html pages
                if session.has_key('login_url'):#after login redirect made by this session var, delete it now
                    del session['login_url']

            try:
                ret=super(MainPage,self).dispatch_request(*args,**kwargs)
                #sucessfull request
            except ResponseErrorException as e:
                error=e.error
            except PermissionDeniedException as e:
                ret=e.return_response
                error=e.error
            #response should be returned in type set by method


        if self.method=='modal':
            if error:
                #return JS based error
                return response_error(error=error)
            if isinstance(ret,BaseResponse):
                #if response is redirect return it with all required settings
                if ret.headers.get('Location'):
                    return response_redirect(
                        redirect_to=ret.headers.get('Location'),
                        in_modal=self.redirect_in_modal,
                        remember_modal=self.remember_modal
                    )
            else:
                #everything fine, show response
                return response_ok(data=ret,force_modal=True)

        if error: #got some error, return to current page (tracker was not updated) and show error
            session['error']=error
            return redirect(self.tracker.current)

        return ret