[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Content/Folder - Folder.py:1.1.4.3 FolderLimit.py:1.1.4.2 LoadedFolder.py:1.1.4.2 LoadedFolderFields.py:1.1.4.2 OrderedFolder.py:1.1.4.2 folder.zcml:1.1.4.4
Steve Alexander
steve@cat-box.net
Sun, 26 May 2002 14:21:19 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Content/Folder
In directory cvs.zope.org:/tmp/cvs-serv6102/lib/python/Zope/App/OFS/Content/Folder
Modified Files:
Tag: Zope-3x-branch
Folder.py FolderLimit.py LoadedFolder.py LoadedFolderFields.py
OrderedFolder.py folder.zcml
Log Message:
Security-related management screens now work!
I've had to change the way use of Annotations is declared in classes
a little bit. I'll explain more about that in an email to
zope3-dev shortly.
=== Zope3/lib/python/Zope/App/OFS/Content/Folder/Folder.py 1.1.4.2 => 1.1.4.3 ===
##############################################################################
from Zope.App.OFS.Container.IContainer import IContainer
-from Zope.App.OFS.Annotation.IAttributeAnnotatable import IAttributeAnnotatable
import Persistence
from Persistence.BTrees.OOBTree import OOBTree
@@ -22,7 +21,7 @@
from Zope.ComponentArchitecture.IServiceManagerContainer import \
IServiceManagerContainer
from types import StringTypes
-
+from Zope.App.OFS.Annotation.IAnnotatable import IAnnotatable
from Zope.App.OFS.Container.Exceptions import UnaddableError
class IFolder(IContainer, IServiceManagerContainer):
@@ -31,11 +30,8 @@
class Folder(Persistence.Persistent, ServiceManagerContainer):
"""The standard Zope Folder implementation."""
- __implements__ = (
- IFolder,
- IAttributeAnnotatable,
- )
-
+ __implements__ = IFolder, IAnnotatable
+
def __init__(self):
self.data = OOBTree()
=== Zope3/lib/python/Zope/App/OFS/Content/Folder/FolderLimit.py 1.1.4.1 => 1.1.4.2 ===
#
##############################################################################
-"""
-
-Revision information:
+"""
+
+Revision information:
$Id$
-"""
-
-from Zope.App.OFS.Container.IContainerLimit import IContainerLimit
-from Zope.App.OFS.Container.Exceptions import UnaddableError
-
-
-class FolderLimitExceededError(UnaddableError):
- """Exception that is raised, when the limit of the folder was
- reached."""
- pass
-
-
-class FolderLimit:
- """Implements a feature that allows to restrict the amount of items in
- a Folder.
- """
-
- __implements__ = (IContainerLimit,)
-
- _limit = 1000
-
- ############################################################
- # Implementation methods for interface
- # Zope.App.OFS.IContainerLimit
-
- def setLimit(self, limit):
- '''See interface IContainerLimit'''
- self._limit = limit
-
-
- def getLimit(self):
- '''See interface IContainerLimit'''
- return self._limit
-
-
- def isLimitReached(self):
- '''See interface IContainerLimit'''
- if self.objectCount() >= self._limit:
- return 1
- else:
- return 0
-
- #
- ############################################################
+"""
+
+from Zope.App.OFS.Container.IContainerLimit import IContainerLimit
+from Zope.App.OFS.Container.Exceptions import UnaddableError
+
+
+class FolderLimitExceededError(UnaddableError):
+ """Exception that is raised, when the limit of the folder was
+ reached."""
+ pass
+
+
+class FolderLimit:
+ """Implements a feature that allows to restrict the amount of items in
+ a Folder.
+ """
+
+ __implements__ = IContainerLimit
+
+ _limit = 1000
+
+ ############################################################
+ # Implementation methods for interface
+ # Zope.App.OFS.IContainerLimit
+
+ def setLimit(self, limit):
+ '''See interface IContainerLimit'''
+ self._limit = limit
+
+
+ def getLimit(self):
+ '''See interface IContainerLimit'''
+ return self._limit
+
+
+ def isLimitReached(self):
+ '''See interface IContainerLimit'''
+ if self.objectCount() >= self._limit:
+ return 1
+ else:
+ return 0
+
+ #
+ ############################################################
=== Zope3/lib/python/Zope/App/OFS/Content/Folder/LoadedFolder.py 1.1.4.1 => 1.1.4.2 ===
"""
- __implements__ = (ILoadedFolder,) + \
- Folder.__implements__ + \
- FolderLimit.__implements__ + \
- OrderedFolder.__implements__
+ __implements__ = (ILoadedFolder, Folder.__implements__,
+ FolderLimit.__implements__, OrderedFolder.__implements__)
# XXX Reimplementation of some of the IReadContainer API. Shrug.
=== Zope3/lib/python/Zope/App/OFS/Content/Folder/LoadedFolderFields.py 1.1.4.1 => 1.1.4.2 ===
#
##############################################################################
-"""
-
+"""
+
$Id$
-"""
+"""
+
+
+from Zope.App.Formulator import getField
+
-
-from Zope.App.Formulator import getField
-
-
-LimitField = getField('IntegerField')(
- id='limit',
- title='Limit',
- description='Limit of objects in the container.',
- start=1,
- default=1000 )
+LimitField = getField('IntegerField')(
+ id='limit',
+ title='Limit',
+ description='Limit of objects in the container.',
+ start=1,
+ default=1000 )
=== Zope3/lib/python/Zope/App/OFS/Content/Folder/OrderedFolder.py 1.1.4.1 => 1.1.4.2 ===
#
##############################################################################
-"""
-Revision information:
+"""
+Revision information:
$Id$
-
-"""
-
-from Zope.App.OFS.Container.IOrderedContainer import IOrderedContainer
-from types import StringType
-
-
-class OrderedFolder:
- """Adds the Ordering Feature to a Folder
- """
-
- __implements__ = (IOrderedContainer,)
-
- _orderedIds = ()
-
-
- def moveObjectsByPositions(self, ids, positionDelta):
- """ """
-
- if type(ids) is StringType:
- ids = (ids,)
-
- # Interestingly enough, we need to switch the order when
- # moving, so that the movements won't cancel each
- # other
- if positionDelta > 0:
- ids = list(ids)
- ids.reverse()
-
- moved_objects = 0
-
- for id in ids:
- old_position = self.getObjectPosition(id)
- new_position = old_position + positionDelta
- # Make sure the new position makes sense and is valid
- if not (old_position == new_position or
- new_position > self.objectCount() or
- new_position < 0):
-
- id_list = list(self._orderedIds)
- # now delete the entry ...
- id_list.remove(id)
- # ... and now add it again
- id_list.insert(new_position, id)
- self._orderedIds = tuple(id_list)
-
- moved_objects += 1
-
- return moved_objects
-
-
- ############################################################
- # Implementation methods for interface
- # Zope.App.OFS.IOrderedContainer
-
- def getObjectPosition(self, id):
- '''See interface IOrderedContainer'''
-
- if id in self._orderedIds:
- return list(self._orderedIds).index(id)
- else:
- # If the object was not found, throw an error.
- # Yeah, that is good raise 'ObjectNotFound',
- raise ( 'ObjectNotFound',
- 'The object named %s was not found.' %id)
-
-
- def moveObjectsDown(self, ids):
- '''See interface IOrderedContainer'''
- return self.moveObjectsByPositions(ids, +1)
-
-
- def moveObjectsUp(self, ids):
- '''See interface IOrderedContainer'''
- return self.moveObjectsByPositions(ids, -1)
-
-
- def moveObjectsToTop(self, ids):
- '''See interface IOrderedContainer'''
- if type(ids) is StringType:
- ids = (ids,)
-
- position_delta = - self.getObjectPosition(ids[0])
- return self.moveObjectsByPositions(ids, position_delta)
-
-
- def moveObjectsToBottom(self, ids):
- '''See interface IOrderedContainer'''
- if type(ids) is StringType:
- ids = (ids,)
-
- # Whee, we will do the reverse twice, but for going to the bottom
- # there is no other choice.
- ids = list(ids)
- ids.reverse()
-
- position_delta = self.objectCount() - \
- self.getObjectPosition(ids[-1]) - 1
-
- return self.moveObjectsByPositions(ids, position_delta)
-
-
- def moveObjectToPosition(self, id, position):
- '''See interface IOrderedContainer'''
- return self.moveObjectsByPositions(id,
- position - self.getObjectPosition(id))
-
- #
- ############################################################
-
+
+"""
+
+from Zope.App.OFS.Container.IOrderedContainer import IOrderedContainer
+from types import StringType
+
+
+class OrderedFolder:
+ """Adds the Ordering Feature to a Folder
+ """
+
+ __implements__ = IOrderedContainer
+
+ _orderedIds = ()
+
+
+ def moveObjectsByPositions(self, ids, positionDelta):
+ """ """
+
+ if type(ids) is StringType:
+ ids = (ids,)
+
+ # Interestingly enough, we need to switch the order when
+ # moving, so that the movements won't cancel each
+ # other
+ if positionDelta > 0:
+ ids = list(ids)
+ ids.reverse()
+
+ moved_objects = 0
+
+ for id in ids:
+ old_position = self.getObjectPosition(id)
+ new_position = old_position + positionDelta
+ # Make sure the new position makes sense and is valid
+ if not (old_position == new_position or
+ new_position > self.objectCount() or
+ new_position < 0):
+
+ id_list = list(self._orderedIds)
+ # now delete the entry ...
+ id_list.remove(id)
+ # ... and now add it again
+ id_list.insert(new_position, id)
+ self._orderedIds = tuple(id_list)
+
+ moved_objects += 1
+
+ return moved_objects
+
+
+ ############################################################
+ # Implementation methods for interface
+ # Zope.App.OFS.IOrderedContainer
+
+ def getObjectPosition(self, id):
+ '''See interface IOrderedContainer'''
+
+ if id in self._orderedIds:
+ return list(self._orderedIds).index(id)
+ else:
+ # If the object was not found, throw an error.
+ # Yeah, that is good raise 'ObjectNotFound',
+ raise ( 'ObjectNotFound',
+ 'The object named %s was not found.' %id)
+
+
+ def moveObjectsDown(self, ids):
+ '''See interface IOrderedContainer'''
+ return self.moveObjectsByPositions(ids, +1)
+
+
+ def moveObjectsUp(self, ids):
+ '''See interface IOrderedContainer'''
+ return self.moveObjectsByPositions(ids, -1)
+
+
+ def moveObjectsToTop(self, ids):
+ '''See interface IOrderedContainer'''
+ if type(ids) is StringType:
+ ids = (ids,)
+
+ position_delta = - self.getObjectPosition(ids[0])
+ return self.moveObjectsByPositions(ids, position_delta)
+
+
+ def moveObjectsToBottom(self, ids):
+ '''See interface IOrderedContainer'''
+ if type(ids) is StringType:
+ ids = (ids,)
+
+ # Whee, we will do the reverse twice, but for going to the bottom
+ # there is no other choice.
+ ids = list(ids)
+ ids.reverse()
+
+ position_delta = self.objectCount() - \
+ self.getObjectPosition(ids[-1]) - 1
+
+ return self.moveObjectsByPositions(ids, position_delta)
+
+
+ def moveObjectToPosition(self, id, position):
+ '''See interface IOrderedContainer'''
+ return self.moveObjectsByPositions(id,
+ position - self.getObjectPosition(id))
+
+ #
+ ############################################################
+
=== Zope3/lib/python/Zope/App/OFS/Content/Folder/folder.zcml 1.1.4.3 => 1.1.4.4 ===
</security:protectClass>
+
+ <adapter
+ factory="Zope.App.OFS.Annotation.AttributeAnnotations."
+ provides="Zope.App.OFS.Annotation.IAnnotations."
+ for=".Folder.IFolder." />
+
+
<zmi:tabs for="Zope.App.OFS.Container.IContainerLimit.">
<zmi:tab label="Limit" action="limit;view"/>
</zmi:tabs>