Example #1
0
 def post(self):
     """
     Callers should supply 'action'
     Callers can supply 'redirect_url'
     Action and response will be be delivered to redirect_url 
     """
     if not self.site:
         logging.info('/admin-post: Denying admin access')
         return self.error(403)
     action = self.request.POST.get('action').lower()
     nexturl = self.request.POST.get('redirect_url', admin_url())
     gov = controller.get_current_site_controller()
     logging.debug('Admin/post, action =%s, nexturl: %s'%(action, nexturl))
     response = ''
     assert(action in ['save', 'flush', 'reload', 'verify', 'delete', 'sync'])
     if action == 'save':
         self.save_config_path()
     elif action == 'flush':
         cache.flush_all()
     elif action == 'reload':
         models.flush_resources(self.site)
     elif action == 'verify':
         gov.do_verify_database_consistency()
     elif action == 'sync':
         models.schedule_sync(gov)
     elif action == 'delete':
         #todo
         raise NotImplemented('Delte not implemented')
     
     self.redirect('%s?%s'%(nexturl, urllib.urlencode({'action': action, 'response': response})))
Example #2
0
    def post(self):
        """
        Callers should supply 'action'
        Callers can supply 'redirect_url'
        Action and response will be be delivered to redirect_url 
        """
        if not self.site:
            logging.info('/admin-post: Denying admin access')
            return self.error(403)
        action = self.request.POST.get('action').lower()
        nexturl = self.request.POST.get('redirect_url', admin_url())
        gov = controller.get_current_site_controller()
        logging.debug('Admin/post, action =%s, nexturl: %s' %
                      (action, nexturl))
        response = ''
        assert (action
                in ['save', 'flush', 'reload', 'verify', 'delete', 'sync'])
        if action == 'save':
            self.save_config_path()
        elif action == 'flush':
            cache.flush_all()
        elif action == 'reload':
            models.flush_resources(self.site)
        elif action == 'verify':
            gov.do_verify_database_consistency()
        elif action == 'sync':
            models.schedule_sync(gov)
        elif action == 'delete':
            #todo
            raise NotImplemented('Delte not implemented')

        self.redirect(
            '%s?%s' %
            (nexturl, urllib.urlencode({
                'action': action,
                'response': response
            })))
 def handle_config_changes(self):
     logging.debug("Config has changed")
     cache.flush_all()
     self.cdefer(verify_database_consistency, _countdown=2)
 def handle_config_changes(self):
     logging.debug('Config has changed')
     cache.flush_all()
     self.cdefer(verify_database_consistency, _countdown=2)