[Zope3-checkins] CVS: Zope3/src/zope/app/container - interfaces.py:1.1 configure.zcml:1.22 constraints.py:1.5 contained.py:1.10 find.py:1.9 ordered.py:1.8 sample.py:1.11 traversal.py:1.10

Philipp von Weitershausen philikon at philikon.de
Wed Mar 3 05:39:10 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/container
In directory cvs.zope.org:/tmp/cvs-serv7814/container

Modified Files:
	configure.zcml constraints.py contained.py find.py ordered.py 
	sample.py traversal.py 
Added Files:
	interfaces.py 
Log Message:
Moved container interfaces from zope.app.interfaces.container to
zope.app.container.interfaces.


=== Added File Zope3/src/zope/app/container/interfaces.py ===
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Container-related interfaces

$Id: interfaces.py,v 1.1 2004/03/03 10:38:39 philikon Exp $
"""
from zope.interface import Interface, Attribute, implements, Invalid
from zope.component.interfaces import IView
from zope.interface.common.mapping import IItemMapping
from zope.interface.common.mapping import IReadMapping, IEnumerableMapping
from zope.app.location.interfaces import ILocation
from zope.app.event.interfaces import IObjectEvent

class DuplicateIDError(KeyError):
    pass

class ContainerError(Exception):
    """An error of a container with one of its components."""

class InvalidContainerType(Invalid, TypeError):
    """The type of a container is not valid
    """

class InvalidItemType(Invalid, TypeError):
    """The type of an item is not valid
    """

class InvalidType(Invalid, TypeError):
    """The type of an object is not valid
    """

class IContained(ILocation):
    """Objects contained in containers
    """

class IItemContainer(IItemMapping):
    """Minimal readable container
    """

class ISimpleReadContainer(IItemContainer, IReadMapping):
    """Readable content containers
    """

class IReadContainer(ISimpleReadContainer, IEnumerableMapping):
    """Readable containers that can be enumerated.
    """

class IWriteContainer(Interface):
    """An interface for the write aspects of a container."""

    def __setitem__(name, object):
        """Add the given object to the container under the given name.

        Raises a TypeError if the key is not a unicode or ascii string.
        Raises a ValueError if key is empty.

        The container might choose to add a different object than the
        one passed to this method.

        If the object doesn't implement IContained, then one of two
        things must be done:

        1. If the object implements ILocation, then the IContained
           interface must be declared for the object.

        2. Otherwise, a ContainedProxy is created for the object and
           stored.

        The object's __parent__ and __name__ attributes are set to the
        container and the given name.

        If the old parent was None, then an IObjectAddedEvent is
        generated, otherwise, and IObjectMovedEvent is generated.  An
        IObjectModifiedEvent is generated for the container.  If an
        add event is generated and the object can be adapted to
        IAddNotifiable, then the adapter's addNotify method is called
        with the event.  If the object can be adapted to
        IMoveNotifiable, then the adapter's moveNotify method is
        called with the event.

        If the object replaces another object, then the old object is
        deleted before the new object is added, unless the container
        vetos the replacement by raising an exception.

        If the object's __parent__ and __name__ were already set to
        the container and the name, then no events are generated and
        no hooks.  This allows advanced clients to take over event
        generation.

        """

    def __delitem__(name):
        """Delete the nameed object from the container.

        Raises a KeyError if the object is not found.

        If the deleted object's __parent__ and __name__ match the
        container and given name, then an IObjectRemovedEvent is
        generated and the attributes are set to None. If the object
        can be adapted to IMoveNotifiable, then the adapter's
        moveNotify method is called with the event.

        Unless the object's __parent__ and __name__ attributes were
        initially None, generate an IObjectModifiedEvent for the
        container.

        If the object's __parent__ and __name__ were already set to
        None, then no events are generated.  This allows advanced
        clients to take over event generation.

        """

class IItemWriteContainer(IWriteContainer, IItemContainer):
    """A write container that also supports minimal reads."""

class IContentContainer(IWriteContainer):
    """Containers (like folders) that contain ordinary content"""

class IContainer(IReadContainer, IWriteContainer):
    """Readable and writable content container."""

class IOrderedContainer(IContainer):
    """Containers whose contents are maintained in order
    """

    def updateOrder(order):
        """Revise the order of keys, replacing the current ordering.

        order is a list or a tuple containing the set of existing keys in
        the new order. order must contain len(keys()) items and cannot
        contain duplicate keys.

        Raises TypeError if order is not a tuple or a list.

        Raises ValueError if order contains an invalid set of keys.
        """

class IContainerNamesContainer(IContainer):
    """Containers that always choose names for their items
    """


##############################################################################
# Moving Objects

class IObjectMovedEvent(IObjectEvent):
    """An object has been moved"""

    oldParent = Attribute("The old location parent for the object.")
    oldName = Attribute("The old location name for the object.")
    newParent = Attribute("The new location parent for the object.")
    newName = Attribute("The new location name for the object.")

class IMoveNotifiable(Interface):
    """Interface for notification of being deleted, added, or moved."""

    def moveNotify(event):
        """Notify of a move event

        This is called after the object has been added to the new
        location and before it has been deleted from the old.

        """


##############################################################################
# Adding objects

class UnaddableError(ContainerError):
    """An object cannot be added to a container."""

    def __init__(self, container, obj, message=""):
        self.container = container
        self.obj = obj
        self.message = message and ": %s" % message

    def __str__(self):
        return ("%(obj)s cannot be added "
                "to %(container)s%(message)s" % self.__dict__)

class IObjectAddedEvent(IObjectMovedEvent):
    """An object has been added to a container."""

class IAddNotifiable(Interface):
    """Interface for notification of being added."""

    def addNotify(event):
        """Hook method will call after an object is added to container.
        """

class IAdding(IView):

    def add(content):
        """Add content object to container.

        Add using the name in contentName.  Returns the added object
        in the context of its container.

        If contentName is already used in container, raises
        DuplicateIDError.
        """

    contentName = Attribute(
         """The content name, as usually set by the Adder traverser.

         If the content name hasn't been defined yet, returns None.

         Some creation views might use this to optionally display the
         name on forms.
         """
         )

    def nextURL():
        """Return the URL that the creation view should redirect to.

        This is called by the creation view after calling add.

        It is the adder's responsibility, not the creation view's to
        decide what page to display after content is added.
        """

    def renderAddButton():
        """It will add Add button"""


class INameChooser(Interface):

    def checkName(name, object):
        """Check whether an object name is valid.

        Raise a user error if the name is not valid.
        """

    def chooseName(name, object):
        """Choose a unique valid name for the object

        The given name and object may be taken into account when
        choosing the name.

        """

##############################################################################
# Removing objects


class IObjectRemovedEvent(IObjectMovedEvent):
    """An object has been removed from a container"""

class IRemoveNotifiable(Interface):
    """Interface for notification of being deleted."""

    def removeNotify(object, container):
        """Hook method will call before object is removed from container."""


=== Zope3/src/zope/app/container/configure.zcml 1.21 => 1.22 ===
--- Zope3/src/zope/app/container/configure.zcml:1.21	Sun Dec 14 23:30:17 2003
+++ Zope3/src/zope/app/container/configure.zcml	Wed Mar  3 05:38:39 2004
@@ -8,19 +8,19 @@
 
   <adapter
      provides="zope.app.interfaces.find.IFind"
-     for="zope.app.interfaces.container.IReadContainer"
+     for="zope.app.container.interfaces.IReadContainer"
      permission="zope.ManageContent"
      factory="zope.app.container.find.FindAdapter"
      />
 
   <adapter
-      for="zope.app.interfaces.container.IReadContainer"
+      for="zope.app.container.interfaces.IReadContainer"
       provides="zope.app.interfaces.file.IReadDirectory"
       factory=".directory.noop"
       />
 
   <adapter
-      for="zope.app.interfaces.container.IWriteContainer"
+      for="zope.app.container.interfaces.IWriteContainer"
       provides="zope.app.interfaces.file.IWriteDirectory"
       factory=".directory.noop"
       />
@@ -28,25 +28,25 @@
   <adapter
       factory="zope.app.container.traversal.ContainerTraversable"
       provides="zope.app.interfaces.traversing.ITraversable"
-      for="zope.app.interfaces.container.IReadContainer"
+      for="zope.app.container.interfaces.IReadContainer"
       />
 
 
   <adapter
       factory="zope.app.container.size.ContainerSized"
       provides="zope.app.interfaces.size.ISized"
-      for="zope.app.interfaces.container.IReadContainer"
+      for="zope.app.container.interfaces.IReadContainer"
       />
 
   <adapter
-      provides="zope.app.interfaces.container.INameChooser"
-      for="zope.app.interfaces.container.IWriteContainer"
+      provides="zope.app.container.interfaces.INameChooser"
+      for="zope.app.container.interfaces.IWriteContainer"
       factory=".contained.NameChooser"
       />
 
   <event:subscribe
       subscriber=".dependency.CheckDependency"
-      event_types="zope.app.interfaces.container.IObjectRemovedEvent"
+      event_types="zope.app.container.interfaces.IObjectRemovedEvent"
       />
 
   <content class=".constraints.ItemTypePrecondition">


=== Zope3/src/zope/app/container/constraints.py 1.4 => 1.5 ===
--- Zope3/src/zope/app/container/constraints.py:1.4	Wed Dec 10 08:04:53 2003
+++ Zope3/src/zope/app/container/constraints.py	Wed Mar  3 05:38:39 2004
@@ -33,7 +33,7 @@
    ...         "Add an item"
    ...     __setitem__.precondition = preNoZ
 
-   >>> from zope.app.interfaces.container import IContainer
+   >>> from zope.app.container.interfaces import IContainer
    >>> class C1:
    ...     zope.interface.implements(I1, IContainer)
    ...     def __repr__(self):
@@ -151,9 +151,9 @@
    """
 
 import zope.interface
-from zope.app.interfaces.container import InvalidItemType, InvalidContainerType
+from zope.app.container.interfaces import InvalidItemType, InvalidContainerType
 from zope.app.i18n import ZopeMessageIDFactory as _
-from zope.app.interfaces.container import IContainer
+from zope.app.container.interfaces import IContainer
 
 def checkObject(container, name, object):
     """Check containement constraints for an object and container


=== Zope3/src/zope/app/container/contained.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/container/contained.py:1.9	Tue Mar  2 13:50:57 2004
+++ Zope3/src/zope/app/container/contained.py	Wed Mar  3 05:38:39 2004
@@ -29,13 +29,13 @@
 from zope.app.event.objectevent import ObjectEvent, modified
 from zope.app.event import publish
 from zope.app.i18n import ZopeMessageIDFactory as _
-from zope.app.interfaces.container import IAddNotifiable, IMoveNotifiable
-from zope.app.interfaces.container import IRemoveNotifiable
-from zope.app.interfaces.container import IContained
-from zope.app.interfaces.container import INameChooser
-from zope.app.interfaces.container import IObjectAddedEvent
-from zope.app.interfaces.container import IObjectMovedEvent
-from zope.app.interfaces.container import IObjectRemovedEvent
+from zope.app.container.interfaces import IAddNotifiable, IMoveNotifiable
+from zope.app.container.interfaces import IRemoveNotifiable
+from zope.app.container.interfaces import IContained
+from zope.app.container.interfaces import INameChooser
+from zope.app.container.interfaces import IObjectAddedEvent
+from zope.app.container.interfaces import IObjectMovedEvent
+from zope.app.container.interfaces import IObjectRemovedEvent
 from zope.app.location.interfaces import ILocation
 from zope.app.container._zope_app_container_contained import ContainedProxyBase
 from zope.app.container._zope_app_container_contained import getProxiedObject
@@ -235,8 +235,8 @@
     ...         self.moved = event
 
     >>> from zope.app.event.objectevent import objectEventCallbackHelper
-    >>> from zope.app.interfaces.container import IObjectAddedEvent
-    >>> from zope.app.interfaces.container import IObjectMovedEvent
+    >>> from zope.app.container.interfaces import IObjectAddedEvent
+    >>> from zope.app.container.interfaces import IObjectMovedEvent
     >>> from zope.component import getService
     >>> from zope.app.services.servicenames import Adapters
     >>> from zope.app.event.interfaces import ISubscriber
@@ -465,7 +465,7 @@
     track the events generated:
 
     >>> from zope.app.event.tests.placelesssetup import getEvents
-    >>> from zope.app.interfaces.container import IObjectRemovedEvent
+    >>> from zope.app.container.interfaces import IObjectRemovedEvent
     >>> from zope.app.event.interfaces import IObjectModifiedEvent
 
     We'll start by creating a container with an item:
@@ -582,7 +582,7 @@
         self.context = context
 
     def checkName(self, name, object):
-        "See zope.app.interfaces.container.INameChooser"
+        "See zope.app.container.interfaces.INameChooser"
 
         if not name:
             raise zapi.UserError(
@@ -608,7 +608,7 @@
 
 
     def chooseName(self, name, object):
-        "See zope.app.interfaces.container.INameChooser"
+        "See zope.app.container.interfaces.INameChooser"
 
         container = self.context
 
@@ -724,9 +724,9 @@
 
 from zope.app.event.function import Subscriber
 from zope.app.folder.interfaces import IRootFolder
-from zope.app.interfaces.container import IWriteContainer
+from zope.app.container.interfaces import IWriteContainer
 from zope.app.interfaces.services.service import IPossibleSite
-from zope.app.interfaces.container import IContainer
+from zope.app.container.interfaces import IContainer
 from transaction import get_transaction
 from zope.component.exceptions import ComponentLookupError
 from zope.app.interfaces.services.registration import IRegistry, INameRegistry


=== Zope3/src/zope/app/container/find.py 1.8 => 1.9 ===
--- Zope3/src/zope/app/container/find.py:1.8	Sun Sep 21 13:31:34 2003
+++ Zope3/src/zope/app/container/find.py	Wed Mar  3 05:38:39 2004
@@ -17,7 +17,7 @@
 """
 
 from zope.app.interfaces.find import IFind, IIdFindFilter
-from zope.app.interfaces.container import IReadContainer
+from zope.app.container.interfaces import IReadContainer
 from zope.interface import implements
 
 class FindAdapter(object):


=== Zope3/src/zope/app/container/ordered.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/container/ordered.py:1.7	Fri Feb 20 11:57:24 2004
+++ Zope3/src/zope/app/container/ordered.py	Wed Mar  3 05:38:39 2004
@@ -13,11 +13,10 @@
 ##############################################################################
 """Ordered container implementation.
 
-Revision information:
 $Id$
 """
 
-from zope.app.interfaces.container import IOrderedContainer
+from zope.app.container.interfaces import IOrderedContainer
 from zope.interface import implements
 from persistent import Persistent
 from persistent.dict import PersistentDict


=== Zope3/src/zope/app/container/sample.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/container/sample.py:1.10	Wed Feb 25 18:02:23 2004
+++ Zope3/src/zope/app/container/sample.py	Wed Mar  3 05:38:39 2004
@@ -18,10 +18,9 @@
 It might be useful as a mix-in for some classes, but many classes will
 need a very different implementation.
 
-Revision information:
 $Id$
 """
-from zope.app.interfaces.container import IContainer
+from zope.app.container.interfaces import IContainer
 from zope.interface import implements
 from zope.app.container.contained import Contained, setitem, uncontained
 


=== Zope3/src/zope/app/container/traversal.py 1.9 => 1.10 ===
--- Zope3/src/zope/app/container/traversal.py:1.9	Fri Feb 13 21:58:29 2004
+++ Zope3/src/zope/app/container/traversal.py	Wed Mar  3 05:38:39 2004
@@ -22,8 +22,8 @@
 from zope.publisher.interfaces import NotFound
 
 from zope.app import zapi
-from zope.app.interfaces.container import ISimpleReadContainer, IItemContainer
-from zope.app.interfaces.container import IReadContainer
+from zope.app.container.interfaces import ISimpleReadContainer, IItemContainer
+from zope.app.container.interfaces import IReadContainer
 from zope.app.interfaces.traversing import ITraversable
 from zope.app.traversing.namespace import UnexpectedParameters
 




More information about the Zope3-Checkins mailing list