def delete(blobId, release='draft'): try: try: thumbnail = None dbGrid = Db().getGridFs('blobs') filename = "%s.%s" % (blobId, release) thumbnail = dbGrid.get_last_version(filename) dbGrid.delete(thumbnail._id) thumbnail = thumbnail.__dict__['_file'] except CorruptGridFile as e: pass except NoFile: pass finally: if not thumbnail or not 'activity' in thumbnail: return True a = ActivityFactory.get(thumbnail['activity']) node = a.__dict__[release] if not 'blobs' in node: return True if not thumbnail['type'] in node['blobs']: return True node['blobs'][thumbnail['type']].remove(str(blobId)) ActivityFactory.update(a) except DbError: output.error('cannot access db', 503)
def get(blobId, release='draft'): try: try: blob = None dbGrid = Db().getGridFs('blobs') blob = dbGrid.get_last_version("%s.%s" % (blobId, release)) except NoFile: pass except CorruptGridFile: pass except DbError: output.error('cannot access db', 503) return blob