def get_lock_infos(self): results = [] catalog = self.context.portal_catalog docs = catalog(portal_type='opengever.document.document') for doc in docs: obj = doc.getObject() lockable = IRefreshableLockable(obj) lock_info = lockable.lock_info() if not lock_info == []: infos = {} infos['title'] = obj.Title() infos['url'] = obj.absolute_url() # Ignoring multiple locks for now infos['token'] = lock_info[0]['token'] infos['creator'] = lock_info[0]['creator'] lock_time = datetime.fromtimestamp(lock_info[0]['time']) duration = datetime.now() - lock_time infos['time'] = lock_time.strftime("%Y-%m-%d %H:%M:%S") infos['duration'] = strfdelta(duration, "{days}d {hours}h {minutes}m {seconds}s") infos['type'] = lock_info[0]['type'] manager = getMultiAdapter((obj, obj.REQUEST), ICheckinCheckoutManager) infos['checked_out'] = manager.get_checked_out_by() results.append(infos) return results
def test_migrates_webdav_locks(self): self.login('HANS.MUSTER') document = create(Builder('document') .with_asset_file('text.txt') .checked_out_by('HANS.MUSTER')) lockable = IRefreshableLockable(document) lockable.lock() CheckedOutDocsMigrator( self.portal, {'HANS.MUSTER': 'hans.muster'}, 'move').migrate() self.assertEqual('hans.muster', lockable.lock_info()[0]['creator'])
def lockContext(context): lockable = IRefreshableLockable(context) lockable.lock(STRUCTURALCONTENT_LOCK) token = lockable.lock_info()[0]["token"] lock = lockable.context.wl_getLock(token) lock.setTimeout(MAXTIMEOUT)