def convert_all(context): catalog = getToolByName(context, 'portal_catalog') portal = getSite() gsettings = GlobalSettings(portal) for brain in catalog(object_provides=OBJECT_PROVIDES): file_item = brain.getObject() if not allowedDocumentType(file_item, gsettings.auto_layout_file_types): continue # let's not switch to the document viewer view # until the document is converted. The conversion # process will check if the layout is set correctly. if file_item.getLayout() != 'documentviewer': settings = Settings(file_item) settings.last_updated = DateTime('1999/01/01').ISO8601() queueJob(file_item) else: settings = Settings(file_item) # also convert if there was an error. if settings.successfully_converted == False: settings.last_updated = DateTime('1999/01/01').ISO8601() settings.filehash = '' queueJob(file_item)
def convert_all(context): catalog = getToolByName(context, 'portal_catalog') portal = getSite() gsettings = GlobalSettings(portal) for brain in catalog(object_provides=IFileContent.__identifier__): file = brain.getObject() if not allowedDocumentType(file, gsettings.auto_layout_file_types): continue # let's not switch to the document viewer view # until the document is converted. The conversion # process will check if the layout is set correctly. if file.getLayout() != 'documentviewer': settings = Settings(file) settings.last_updated = DateTime('1999/01/01').ISO8601() queueJob(file) else: settings = Settings(file) # also convert if there was an error. if settings.successfully_converted == False: settings.last_updated = DateTime('1999/01/01').ISO8601() settings.filehash = '' queueJob(file)
def __call__(self): """ - handle queuing - csrf protection - async - queue position """ mtool = getToolByName(self.context, 'portal_membership') self.manager = mtool.checkPermission('cmf.ManagePortal', self.context) self.async_installed = asyncInstalled() self.converting = False if self.enabled(): req = self.request if req.get('REQUEST_METHOD', 'POST') and \ 'form.action.queue' in req.form.keys(): authenticator = getMultiAdapter((self.context, self.request), name=u"authenticator") if not authenticator.verify(): raise Unauthorized settings = Settings(self.context) settings.last_updated = DateTime('1999/01/01').ISO8601() settings.filehash = '--foobar--' queueJob(self.context) self.converting = True if self.async_installed: self.position = JobRunner(self.context).find_position() queueJob(self.context) else: return self.request.response.redirect( self.context.absolute_url() + '/view') else: if self.async_installed: self.position = JobRunner(self.context).find_position() if self.position > -1: self.converting = True return super(Convert, self).__call__() self.request.response.redirect(self.context.absolute_url() + '/view')