def publish_content(self, content): wftool = getToolByName(self.context, 'portal_workflow') with unrestricted.run_as('Manager'): for action in KNOWN_PUBLISH_ACTIONS: try: wftool.doActionFor(content, action) break except WorkflowException: pass
def update_sources(self): with unrestricted.run_as('Manager'): for source in (b.getObject() for b in self.get_sources()): # Be careful here, this url could be something that the # user is not allowed to look at. For now it needs to be parsed # kml, but if this ever changes there might security problems. kml = utils.fetch_kml_document(source.url) if kml: source.kml = utils.translate_kml_document( self.request, kml ) else: raise NotFound()
def render(self): self.request.response.setHeader("Content-type", "text/plain") # dryrun must be disabled explicitly using &run=1 dryrun = not self.request.get("run") == "1" force_run = bool(self.request.get("force", False)) # this maintenance feature may be run unrestricted as it does not # leak any information and it's behavior cannot be altered by the # user. This allows for easy use via cronjobs. with unrestricted.run_as("Manager"): self.request.set("_authenticator", createToken()) cleanup_scheduler.run(self.context, dryrun, force_run) return u""
def render(self): self.request.response.setHeader("Content-type", "text/plain") # dryrun must be disabled explicitly using &run=1 dryrun = not self.request.get('run') == '1' force_run = bool(self.request.get('force', False)) # this maintenance feature may be run unrestricted as it does not # leak any information and it's behavior cannot be altered by the # user. This allows for easy use via cronjobs. with unrestricted.run_as('Manager'): cleanup_scheduler.run(self.context, dryrun, force_run) return u''
def render(self): self.request.response.setHeader("Content-type", "text/plain") reimport = bool(self.request.get("reimport", False)) ids = self.request.get("source-ids", "").split(",") no_shuffle = bool(self.request.get("no_shuffle", False)) do_run = self.request.get("run") == "1" if do_run: with unrestricted.run_as("Manager"): self.request.set("_authenticator", createToken()) imported, deleted, sources = import_scheduler.run( self.context, reimport, all(ids) and ids or None, no_shuffle ) return u"%i events imported from %i sources (%i deleted)" % (imported, sources, deleted) else: return u""
def render(self): self.request.response.setHeader("Content-type", "text/plain") reimport = bool(self.request.get('reimport', False)) ids = self.request.get('source-ids', '').split(',') no_shuffle = bool(self.request.get('no_shuffle', False)) do_run = self.request.get('run') == '1' if do_run: with unrestricted.run_as('Manager'): imported, deleted, sources = import_scheduler.run( self.context, reimport, all(ids) and ids or None, no_shuffle) return u'%i events imported from %i sources (%i deleted)' % ( imported, sources, deleted) else: return u''
def create_and_save_pdf(data, filename, context, request, toc): """ Create a PDF of the current/all organization(s) and sub-organizations with portrait, memberships, and possibly table of contents and save it in the organization. """ translator = tools.translator(request, 'seantis.agencies') report = OrganizationsReport(data, context.title, translator, toc=toc) filehandle = report.build(context, request) with unrestricted.run_as('Manager'): request.set('_authenticator', createToken()) if filename in context: context.manage_delObjects([filename]) context.invokeFactory(type_name='File', id=filename) file = context.get(filename) file.setContentType('application/pdf') file.setExcludeFromNav(True) file.setFilename(filename) file.setFile(filehandle.getvalue()) file.reindexObject()
def render(self): self.request.response.setHeader("Content-type", "text/plain") reimport = bool(self.request.get('reimport', False)) ids = self.request.get('source-ids', '').split(',') no_shuffle = bool(self.request.get('no_shuffle', False)) do_run = self.request.get('run') == '1' if do_run: with unrestricted.run_as('Manager'): imported, deleted, sources = import_scheduler.run( self.context, reimport, all(ids) and ids or None, no_shuffle ) return u'%i events imported from %i sources (%i deleted)' % ( imported, sources, deleted ) else: return u''