[Commits] (vajda) - added onItemCopy() hook and update Item.copy()
epydoc
commits at osafoundation.org
commits at osafoundation.org
Wed Jul 28 13:40:41 PDT 2004
Commit by: vajda
Modified files:
chandler/repository/item/Indexes.py 1.2 1.3
chandler/repository/item/Item.py 1.141 1.142
chandler/repository/item/ItemRef.py 1.81 1.82
chandler/repository/persistence/DBContainer.py 1.15 1.16
chandler/repository/schema/Types.py 1.66 1.67
chandler/repository/tests/classes/Movie.py 1.1 1.2
Log message:
- added onItemCopy() hook and update Item.copy() epydoc
- added RefDict.get|setIndexEntryValue() and epydoc
ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/repository/item/Indexes.py.diff?r1=text&tr1=1.2&r2=text&tr2=1.3
http://cvs.osafoundation.org/index.cgi/chandler/repository/item/Item.py.diff?r1=text&tr1=1.141&r2=text&tr2=1.142
http://cvs.osafoundation.org/index.cgi/chandler/repository/item/ItemRef.py.diff?r1=text&tr1=1.81&r2=text&tr2=1.82
http://cvs.osafoundation.org/index.cgi/chandler/repository/persistence/DBContainer.py.diff?r1=text&tr1=1.15&r2=text&tr2=1.16
http://cvs.osafoundation.org/index.cgi/chandler/repository/schema/Types.py.diff?r1=text&tr1=1.66&r2=text&tr2=1.67
http://cvs.osafoundation.org/index.cgi/chandler/repository/tests/classes/Movie.py.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
Index: chandler/repository/item/ItemRef.py
diff -u chandler/repository/item/ItemRef.py:1.81 chandler/repository/item/ItemRef.py:1.82
--- chandler/repository/item/ItemRef.py:1.81 Wed Jul 28 08:38:07 2004
+++ chandler/repository/item/ItemRef.py Wed Jul 28 13:40:38 2004
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.81 $"
-__date__ = "$Date: 2004/07/28 15:38:07 $"
+__revision__ = "$Revision: 1.82 $"
+__date__ = "$Date: 2004/07/28 20:40:38 $"
__copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -589,7 +589,8 @@
A ref collection may have any number of indexes. Each index has a
name which is used with the L{placeItem}, L{getByIndex},
- L{resolveIndex}, L{first}, L{last}, L{next}, L{previous} methods.
+ L{getIndexEntryValue}, L{setIndexEntryValue}, L{resolveIndex},
+ L{first}, L{last}, L{next}, L{previous} methods.
Because the implementation of an index depends on the persistence
layer, the type of index is chosen with the C{indexType} parameter
@@ -980,6 +981,39 @@
return self._indexes[indexName].getKey(position)
+ def getIndexEntryValue(self, indexName, item):
+ """
+ Get an index entry value.
+
+ Each entry in a index may store one integer value. This value is
+ initialized to zero.
+
+ @param indexName: the name of the index
+ @type indexName: a string
+ @param item: the item's whose index entry is to be set
+ @type item: an L{Item<repository.item.Item.Item>} instance
+ @return: the index entry value
+ """
+
+ return self._indexes[indexName].getEntryValue(item._uuid)
+
+ def setIndexEntryValue(self, indexName, item, value):
+ """
+ Set an index entry value.
+
+ Each index entry may store one integer value.
+
+ @param indexName: the name of the index
+ @type indexName: a string
+ @param item: the item whose index entry is to be set
+ @type item: an L{Item<repository.item.Item.Item>} instance
+ @param value: the value to set
+ @type value: int
+ """
+
+ self._indexes[indexName].setEntryValue(item._uuid, value)
+ self._item.setDirty(attribute=self._name, dirty=self._item.RDIRTY)
+
def _refCount(self):
return len(self)
Index: chandler/repository/item/Item.py
diff -u chandler/repository/item/Item.py:1.141 chandler/repository/item/Item.py:1.142
--- chandler/repository/item/Item.py:1.141 Tue Jul 27 10:46:19 2004
+++ chandler/repository/item/Item.py Wed Jul 28 13:40:38 2004
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.141 $"
-__date__ = "$Date: 2004/07/27 17:46:19 $"
+__revision__ = "$Revision: 1.142 $"
+__date__ = "$Date: 2004/07/28 20:40:38 $"
__copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -1293,6 +1293,10 @@
L{Cloud<repository.schema.Cloud.Cloud>} instance to drive the copy
operation by using the C{cloudAlias} argument.
+ If this item has an C{onItemCopy} method defined, it is invoked on
+ the copy with the original as argument after the original's
+ attribute values were copied.
+
@param name: the name of the item's copy
@type name: a string
@param parent: the parent of the item's copy, the original's parent
@@ -1331,6 +1335,9 @@
item._values._copy(self._values, copies, copyPolicy)
item._references._copy(self._references, copies, copyPolicy)
+ if hasattr(cls, 'onItemCopy'):
+ item.onItemCopy(self)
+
return item
def delete(self, recursive=False):
Index: chandler/repository/persistence/DBContainer.py
diff -u chandler/repository/persistence/DBContainer.py:1.15 chandler/repository/persistence/DBContainer.py:1.16
--- chandler/repository/persistence/DBContainer.py:1.15 Wed Jul 21 14:32:29 2004
+++ chandler/repository/persistence/DBContainer.py Wed Jul 28 13:40:38 2004
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.15 $"
-__date__ = "$Date: 2004/07/21 21:32:29 $"
+__revision__ = "$Revision: 1.16 $"
+__date__ = "$Date: 2004/07/28 20:40:38 $"
__copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -686,6 +686,7 @@
if node is not None:
level = node.getLevel()
buffer.write(pack('b', node.getLevel()))
+ buffer.write(pack('>l', node._entryValue))
for lvl in xrange(1, level + 1):
point = node.getPoint(lvl)
self._writeValue(buffer, point.prevKey)
@@ -730,9 +731,10 @@
if level == 0:
return None
- offset = 1
node = index._createNode(level)
-
+ node._entryValue = unpack('>l', value[1:5])[0]
+ offset = 5
+
for lvl in xrange(1, level + 1):
point = node.getPoint(lvl)
Index: chandler/repository/schema/Types.py
diff -u chandler/repository/schema/Types.py:1.66 chandler/repository/schema/Types.py:1.67
--- chandler/repository/schema/Types.py:1.66 Fri Jul 23 09:22:44 2004
+++ chandler/repository/schema/Types.py Wed Jul 28 13:40:39 2004
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.66 $"
-__date__ = "$Date: 2004/07/23 16:22:44 $"
+__revision__ = "$Revision: 1.67 $"
+__date__ = "$Date: 2004/07/28 20:40:39 $"
__copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -39,8 +39,7 @@
that is specific to the category of matching types.
For example, Integer < Long < Float or String < Symbol."""
- query = KindQuery()
- matches = [i for i in query.run([self]) if i.recognizes(value)]
+ matches = [i for i in KindQuery().run([self]) if i.recognizes(value)]
if matches:
matches.sort(lambda x, y: x._compareTypes(y))
@@ -57,12 +56,10 @@
def _fillItem(self, name, parent, kind, **kwds):
super(Type, self)._fillItem(name, parent, kind, **kwds)
-
self._status |= Item.SCHEMA | Item.PINNED
- self._registerTypeHandler(self.getImplementationType())
def _registerTypeHandler(self, implementationType):
-
+
if implementationType is not None:
typeHandlers = ItemHandler.typeHandlers[self.itsView]
if implementationType in typeHandlers:
@@ -70,15 +67,11 @@
else:
typeHandlers[implementationType] = [ self._uuid ]
- def getImplementationType(self):
-
- implementationTypes = self.getAttributeValue('implementationTypes',
- _attrDict=self._values,
- default=None)
- if implementationTypes is not None:
- return self.implementationTypes['python']
+ def onItemLoad(self):
+ self._registerTypeHandler(self.getImplementationType())
- return None
+ def getImplementationType(self):
+ return self.implementationTypes['python']
def handlerName(self):
return None
Index: chandler/repository/item/Indexes.py
diff -u chandler/repository/item/Indexes.py:1.2 chandler/repository/item/Indexes.py:1.3
--- chandler/repository/item/Indexes.py:1.2 Wed Jul 28 08:38:07 2004
+++ chandler/repository/item/Indexes.py Wed Jul 28 13:40:38 2004
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.2 $"
-__date__ = "$Date: 2004/07/28 15:38:07 $"
+__revision__ = "$Revision: 1.3 $"
+__date__ = "$Date: 2004/07/28 20:40:38 $"
__copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -71,11 +71,32 @@
responsible for providing persisted implementations.
"""
+ class node(SkipList.node):
+
+ def __init__(self, level, skipList):
+
+ super(NumericIndex.node, self).__init__(level, skipList)
+ self._entryValue = 0
+
+
def __init__(self, **kwds):
Index.__init__(self, **kwds)
SkipList.__init__(self)
+ def _createNode(self, level):
+
+ return NumericIndex.node(level, self)
+
+ def getEntryValue(self, key):
+
+ return self[key]._entryValue
+
+ def setEntryValue(self, key, entryValue):
+
+ self[key]._entryValue = entryValue
+ self._keyChanged(key)
+
def getKey(self, n):
return self.access(self, n)
Index: chandler/repository/tests/classes/Movie.py
diff -u chandler/repository/tests/classes/Movie.py:1.1 chandler/repository/tests/classes/Movie.py:1.2
--- chandler/repository/tests/classes/Movie.py:1.1 Wed Jul 28 08:38:08 2004
+++ chandler/repository/tests/classes/Movie.py Wed Jul 28 13:40:39 2004
@@ -12,3 +12,7 @@
return 1
else:
return 0
+
+ def onItemCopy(self, original):
+
+ print 'copied', self.title, 'from', original.itsUUID
More information about the Commits
mailing list