def save_config_path(self): new_config_path = self.request.get('config_path') if self.site.set_config_path(new_config_path): self.site.put() gov = controller.get_current_site_controller() gov.handle_config_changes() self.redirect(admin_url())
def post(self): """ implementation note: If a push task request handler returns an HTTP status code within the range 200 - 299, App Engine considers the task to have completed successfully. If the task returns a status code outside of this range, App Engine retries the task until it succeeds. We treat FormatErrors and DropboxErrors specially. All other errors are assumed to be bad code: An error is logged and status 200 is returned """ resource=db.get(self.request.get('key')) if not resource: logging.info('FetchWorker failed to find resource for %s'%self.request.get('key')) return #Do not fail: we want the queue item to die new_revision=self.request.get_range('new_revision') action=self.request.get('action', 'fetch') if not hasattr(resource, action): logging.info('FetchWorker: Resource object %s does not have method %s'%(resource, action)) return logging.debug('Fetchworker, will initiate %s on %s (new revision: %d)'%(action, resource, new_revision)) gov = None try: gov = controller.get_current_site_controller() getattr(resource,action)(gov, new_revision=new_revision) except (models.InvalidSiteError, models.DropboxError), e: logging.warn('Unable to access dropbox: %s'%e)
def get(self): gov = controller.get_current_site_controller() config_path, config_src = gov.get_config_yaml() self.render_to_template(template_name= 'admin_config.html', template_values = {'config_default': config.DEFAULT_CONFIG_YAML, 'config_path': config_path, 'config_src': config_src})
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 get(self, url): # Check if namespace is initialized try: gov = controller.get_current_site_controller() except models.InvalidSiteError, e: logging.warning('Access to uninitialized namespace %s. Redirecting to %s'%( namespace_manager.get_namespace(), config.ADMIN_URL)) self.redirect(config.ADMIN_URL) return
def get(self): gov = controller.get_current_site_controller() config_path, config_src = gov.get_config_yaml() self.render_to_template(template_name='admin_config.html', template_values={ 'config_default': config.DEFAULT_CONFIG_YAML, 'config_path': config_path, 'config_src': config_src })
def get(self, url): # Check if namespace is initialized try: gov = controller.get_current_site_controller() except models.InvalidSiteError, e: logging.warning( 'Access to uninitialized namespace %s. Redirecting to %s' % (namespace_manager.get_namespace(), config.ADMIN_URL)) self.redirect(config.ADMIN_URL) return
def new_f(self, *args, **kwargs): try: self.gov = controller.get_current_site_controller() except models.InvalidSiteError: logging.debug('Access to admin page of invalid site attempted') self.redirect(admin_url()) return self.user = users.get_current_user() if gov and gov.site.owner_id != user.user_id(): logging.info('/admin/auth: Denying admin access for %s (id: %s). Owner ID is: %s'%(user.email(), user.user_id(), site.owner_id)) self.redirect(admin_url()) return return f(self, *args, **kwargs)
def new_f(self, *args, **kwargs): try: self.gov = controller.get_current_site_controller() except models.InvalidSiteError: logging.debug('Access to admin page of invalid site attempted') self.redirect(admin_url()) return self.user = users.get_current_user() if gov and gov.site.owner_id != user.user_id(): logging.info( '/admin/auth: Denying admin access for %s (id: %s). Owner ID is: %s' % (user.email(), user.user_id(), site.owner_id)) self.redirect(admin_url()) return return f(self, *args, **kwargs)
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 })))