예제 #1
0
파일: LockTool.py 프로젝트: bendavis78/zope
    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)
예제 #2
0
파일: LockTool.py 프로젝트: goschtl/zope
    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)
예제 #3
0
    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)
예제 #4
0
 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
예제 #5
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
예제 #6
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
예제 #7
0
파일: LockTool.py 프로젝트: bendavis78/zope
 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
예제 #8
0
파일: LockTool.py 프로젝트: goschtl/zope
 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
예제 #9
0
파일: LockTool.py 프로젝트: bendavis78/zope
    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?
예제 #10
0
    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 ''
예제 #11
0
    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
예제 #12
0
    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
예제 #13
0
 def test_tracker215(self):
     self.failUnless(IDynamicType.isImplementedBy(self.root.test))
     self.failUnless(WriteLockInterface.isImplementedBy(self.root.test))
예제 #14
0
 def test_tracker215( self ):
     self.failUnless(IDynamicType.isImplementedBy(self.root.test))
     self.failUnless(WriteLockInterface.isImplementedBy(self.root.test))
예제 #15
0
 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)