def isLockable(self, obj): """Return true if object supports locking. Does not examine lock state or whether the current user can actually lock. """ return WriteLockInterface.isImplementedBy(obj)
def locked(self, object): '''Returns true if an object is locked. Also accepts non-lockable objects, always returning 0.''' if not WriteLockInterface.isImplementedBy(object): return 0 return not not self.locker(object)
def canLock(self, object): """Returns true if the current user can lock the given object.""" if self.locked(object): return 0 if not WriteLockInterface.isImplementedBy(object): return 0 if _checkPermission(LockObjects, object): return 1 return 0
def dav__supportedlock(self): vself = self.v_self() out = '\n' if IWriteLock.providedBy(vself) or \ WriteLockInterface.isImplementedBy(vself): out += (' <n:lockentry>\n' ' <d:lockscope><d:exclusive/></d:lockscope>\n' ' <d:locktype><d:write/></d:locktype>\n' ' </n:lockentry>\n ') return out
def canChange(self, obj): """Returns true if the current user can change the given object. """ if not WriteLockInterface.isImplementedBy(obj): if self.isLockedOut(obj): return 0 if not _checkPermission(ModifyPortalContent, obj): return 0 vt = getToolByName(self, 'portal_versions', None) if vt is not None: if (vt.isUnderVersionControl(obj) and not vt.isCheckedOut(obj)): return 0 return 1
def canChange(self, object): """Returns true if the current user can change the given object.""" if not WriteLockInterface.isImplementedBy(object): if self.isLockedOut(object): return 0 if not _checkPermission(ModifyPortalContent, object): return 0 vt = getToolByName(self, 'portal_versions', None) if vt is not None: if (vt.isUnderVersionControl(object) and not vt.isCheckedOut(object)): return 0 return 1
def locker(self, object): '''Returns the locker of an object''' if not WriteLockInterface.isImplementedBy(object): raise LockingError, "%s is not lockable" % pathOf(object) values = object.wl_lockValues() if not values: return '' creator = values[0].getCreator() if creator: return creator[1] # The user id without the path return '' # An expired lock?
def locker(self, object): '''Returns the locker of an object''' if not WriteLockInterface.isImplementedBy(object): raise LockingError, "%s is not lockable" % pathOf(object) values = object.wl_lockValues() if not values: return '' for lock in values: if lock.isValid(): creator = lock.getCreator() if creator: return creator[1] # The user id without the path # All of the locks are expired or invalid return ''
def dav__lockdiscovery(self): security = getSecurityManager() user = security.getUser().getId() vself = self.v_self() out = '\n' if IWriteLock.providedBy(vself) or \ WriteLockInterface.isImplementedBy(vself): locks = vself.wl_lockValues(killinvalids=1) for lock in locks: creator = lock.getCreator()[-1] if creator == user: fake=0 else: fake=1 out = '%s\n%s' % (out, lock.asLockDiscoveryProperty('n',fake=fake)) out = '%s\n' % out return out
def dav__lockdiscovery(self): security = getSecurityManager() user = security.getUser().getId() vself = self.v_self() out = '\n' if IWriteLock.providedBy(vself) or \ WriteLockInterface.isImplementedBy(vself): locks = vself.wl_lockValues(killinvalids=1) for lock in locks: creator = lock.getCreator()[-1] if creator == user: fake = 0 else: fake = 1 out = '%s\n%s' % (out, lock.asLockDiscoveryProperty('n', fake=fake)) out = '%s\n' % out return out
def test_tracker215(self): self.failUnless(IDynamicType.isImplementedBy(self.root.test)) self.failUnless(WriteLockInterface.isImplementedBy(self.root.test))
def test_tracker215( self ): self.failUnless(IDynamicType.isImplementedBy(self.root.test)) self.failUnless(WriteLockInterface.isImplementedBy(self.root.test))
def isLockable(self, object): """Return true if object supports locking, regardless of lock state or whether the current user can actually lock.""" return WriteLockInterface.isImplementedBy(object)