Ejemplo n.º 1
0
    def _cleanup(self, **kwargs):
        """ Cleanup thumbs
        """
        index = 0
        now = datetime.now(bucharest)
        logger.info('cleanup old images started ...')
        geQuery = Le('stiam.ro.effective', now)
        query = SearchQuery(geQuery)
        brains = query.apply()

        intids = queryUtility(IIntIds)
        if not intids:
            logger.warn('No intids utility. Cleanup aborted.')
            return index

        for docid in brains:
            try:
                doc = intids.getObject(docid)
            except KeyError, err:
                logger.exception(err)
                continue

            for image in doc.values():
                if not IImage.providedBy(image):
                    continue

                if IBlobImage.providedBy(image):
                    continue

                try:
                    del doc[image.__name__]
                except Exception, err:
                    logger.exception(err)
                    continue

                index += 1
                # Transaction commit
                if index % 20 == 0:
                    logger.info('Commit transaction %s', index)
                    transaction.commit()
Ejemplo n.º 2
0
 def testInterface(self):
     self.failUnless(IImage.implementedBy(Image))
     self.failUnless(verifyClass(IImage, Image))
     self.failUnless(IBlobFile.implementedBy(Image))
     self.failUnless(IBlobImage.implementedBy(Image))
     self.failUnless(verifyClass(IBlobFile, Image))