[Zope-Checkins] CVS: Zope2 - Interfaces.py:1.6
Jim Fulton
jim@digicool.com
Sun, 20 May 2001 12:34:10 -0400 (EDT)
Update of /cvs-repository/Zope2/lib/python/BTrees
In directory korak.digicool.com:/tmp/cvs-serv32282
Modified Files:
Interfaces.py
Log Message:
Changed to derive from standard interfaces.
Fixed a type that prevented import.
Changed interface registration to take advantage of the fact
that we have classes.
--- Updated File Interfaces.py in package Zope2 --
--- Interfaces.py 2001/03/15 13:16:22 1.5
+++ Interfaces.py 2001/05/20 16:34:09 1.6
@@ -83,7 +83,7 @@
#
##############################################################################
-import OOBTree, Interface
+import OOBTree, Interface, Interface.Standard
class ICollection(Interface.Base):
@@ -97,16 +97,8 @@
false otherwise.
"""
-class ISized(ICollection):
+class IReadSequence(Interface.Standard.Sequence):
- def __len__():
- """Return the number of items in the set"""
-
-class IReadSequence(Interface.Base):
-
- def __getitem__(index):
- """Return an item for a given index."""
-
def __getslice__(index1, index2):
"""Return a subsequence from the original sequence
@@ -162,7 +154,7 @@
def update(seq):
"""Add the items from the given sequence to the set"""
-class IKeySequence(IKeyed, ISized):
+class IKeySequence(IKeyed, Interface.Standard.Sized):
def __getitem__(index):
"""Return the key in the given index position
@@ -177,33 +169,9 @@
class ITreeSet(IKeyed, ISetMutable):
pass
-
-class IDictionaryIsh(IKeyed, ISized):
-
- def __getitem__(key):
- """Get the value for the given key
-
- Raise a key error if the key if not in the collection.
- """
-
- def get(key, default=None):
- """Get the value for the given key
- Raise a key error if the key if not in the collection and no
- default is specified.
+class IDictionaryIsh(IKeyed, Interface.Standard.MinimalDictionary):
- Return the default if specified and the key is not in the
- collection.
- """
-
- def __setitem__(key, value):
- """Set the value for the given key"""
-
- def __delitem__(key):
- """delete the value for the given key
-
- Raise a key error if the key if not in the collection."""
-
def update(collection):
"""Add the items from the given collection object to the collection
@@ -273,7 +241,7 @@
key=generate_key()
"""
-class IMerge(Interfaces.Base):
+class IMerge(Interface.Base):
"""Object with methods for merging sets, buckets, and trees.
These methods are supplied in modules that define collection
@@ -397,11 +365,8 @@
# Eventually, I need to express this through the interfaces.
#
################################################################
-
-
-Interface.assertTypeImplements(OOBTree.OOSet, ISet)
-Interface.assertTypeImplements(OOBTree.OOTreeSet, ITreeSet)
-Interface.assertTypeImplements(OOBTree.OOBucket, IDictionaryIsh)
-Interface.assertTypeImplements(OOBTree.OOBTree, IBTree)
-
+OOBTree.OOSet.__implements__=ISet
+OOBTree.OOTreeSet.__implements__=ITreeSet
+OOBTree.OOBucket.__implements__=IDictionaryIsh
+OOBTree.OOBTree.__implements__=IBTree