[Commits] (vajda) - released chandlerdb-0.5-7
commits at osafoundation.org
commits at osafoundation.org
Mon Apr 18 12:42:41 PDT 2005
Commit by: vajda
Modified files:
chandler/Makefile 1.99 1.100
chandler/repository/item/Children.py 1.1 1.2
chandler/repository/item/Item.py 1.205 1.206
chandler/repository/item/Monitors.py 1.11 1.12
chandler/repository/item/RefCollections.py 1.15 1.16
chandler/repository/item/Values.py 1.45 1.46
chandler/repository/packs/schema.pack 1.23 1.24
chandler/repository/packs/schema/model/clouds/Struct.cloud None 1.1
chandler/repository/packs/schema/model/clouds/Attribute.cloud 1.5 1.6
chandler/repository/packs/schema/model/clouds/Item.cloud 1.4 1.5
chandler/repository/packs/schema/model/clouds/Kind.cloud 1.5 1.6
chandler/repository/persistence/DBRefs.py 1.6 1.7
chandler/repository/persistence/DBRepositoryView.py 1.12 1.13
chandler/repository/persistence/FileContainer.py 1.19 1.20
chandler/repository/persistence/RepositoryError.py 1.17 1.18
chandler/repository/persistence/RepositoryView.py 1.38 1.39
chandler/repository/schema/Cloud.py 1.27 1.28
chandler/repository/schema/Kind.py 1.108 1.109
chandler/repository/schema/TypeHandler.py 1.2 1.3
chandler/repository/schema/Types.py 1.79 1.80
chandler/repository/tests/TestImport.py None 1.1
chandler/repository/tests/TestNullView.py 1.1 None
chandler/repository/util/LinkedMap.py 1.27 1.28
Log message:
- released chandlerdb-0.5-7
- released PyLucene-0.9.8-188, maybe fixed bug 2821
- reworked importItem() to support copying on export
- fixed bug in ref collection copy where aliases would not get copied
- fixed bugs in cloud copy with persistent collections
- improved assertion error message for bug 2821
- added trivial support for 'none' include policy in Endpoint.getItems()
- reworked importItem() unit tests
- added RefList.setAlias()
Bugzilla links:
http://bugzilla.osafoundation.org/show_bug.cgi?id=2821
http://bugzilla.osafoundation.org/show_bug.cgi?id=2821
ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/Makefile.diff?r1=text&tr1=1.99&r2=text&tr2=1.100
http://cvs.osafoundation.org/index.cgi/chandler/repository/item/Children.py.diff?r1=text&tr1=1.1&r2=text&tr2=1.2
http://cvs.osafoundation.org/index.cgi/chandler/repository/item/Item.py.diff?r1=text&tr1=1.205&r2=text&tr2=1.206
http://cvs.osafoundation.org/index.cgi/chandler/repository/item/Monitors.py.diff?r1=text&tr1=1.11&r2=text&tr2=1.12
http://cvs.osafoundation.org/index.cgi/chandler/repository/item/RefCollections.py.diff?r1=text&tr1=1.15&r2=text&tr2=1.16
http://cvs.osafoundation.org/index.cgi/chandler/repository/item/Values.py.diff?r1=text&tr1=1.45&r2=text&tr2=1.46
http://cvs.osafoundation.org/index.cgi/chandler/repository/packs/schema.pack.diff?r1=text&tr1=1.23&r2=text&tr2=1.24
http://cvs.osafoundation.org/index.cgi/chandler/repository/packs/schema/model/clouds/Struct.cloud?rev=1.1&content-type=text/vnd.viewcvs-markup
http://cvs.osafoundation.org/index.cgi/chandler/repository/packs/schema/model/clouds/Attribute.cloud.diff?r1=text&tr1=1.5&r2=text&tr2=1.6
http://cvs.osafoundation.org/index.cgi/chandler/repository/packs/schema/model/clouds/Item.cloud.diff?r1=text&tr1=1.4&r2=text&tr2=1.5
http://cvs.osafoundation.org/index.cgi/chandler/repository/packs/schema/model/clouds/Kind.cloud.diff?r1=text&tr1=1.5&r2=text&tr2=1.6
http://cvs.osafoundation.org/index.cgi/chandler/repository/persistence/DBRefs.py.diff?r1=text&tr1=1.6&r2=text&tr2=1.7
http://cvs.osafoundation.org/index.cgi/chandler/repository/persistence/DBRepositoryView.py.diff?r1=text&tr1=1.12&r2=text&tr2=1.13
http://cvs.osafoundation.org/index.cgi/chandler/repository/persistence/FileContainer.py.diff?r1=text&tr1=1.19&r2=text&tr2=1.20
http://cvs.osafoundation.org/index.cgi/chandler/repository/persistence/RepositoryError.py.diff?r1=text&tr1=1.17&r2=text&tr2=1.18
http://cvs.osafoundation.org/index.cgi/chandler/repository/persistence/RepositoryView.py.diff?r1=text&tr1=1.38&r2=text&tr2=1.39
http://cvs.osafoundation.org/index.cgi/chandler/repository/schema/Cloud.py.diff?r1=text&tr1=1.27&r2=text&tr2=1.28
http://cvs.osafoundation.org/index.cgi/chandler/repository/schema/Kind.py.diff?r1=text&tr1=1.108&r2=text&tr2=1.109
http://cvs.osafoundation.org/index.cgi/chandler/repository/schema/TypeHandler.py.diff?r1=text&tr1=1.2&r2=text&tr2=1.3
http://cvs.osafoundation.org/index.cgi/chandler/repository/schema/Types.py.diff?r1=text&tr1=1.79&r2=text&tr2=1.80
http://cvs.osafoundation.org/index.cgi/chandler/repository/tests/TestImport.py?rev=1.1&content-type=text/vnd.viewcvs-markup
http://cvs.osafoundation.org/index.cgi/chandler/repository/tests/TestNullView.py.diff?r1=text&tr1=1.1&r2=text&tr2=None
http://cvs.osafoundation.org/index.cgi/chandler/repository/util/LinkedMap.py.diff?r1=text&tr1=1.27&r2=text&tr2=1.28
Index: chandler/repository/persistence/DBRepositoryView.py
diff -u chandler/repository/persistence/DBRepositoryView.py:1.12 chandler/repository/persistence/DBRepositoryView.py:1.13
--- chandler/repository/persistence/DBRepositoryView.py:1.12 Mon Apr 4 15:13:21 2005
+++ chandler/repository/persistence/DBRepositoryView.py Mon Apr 18 12:41:34 2005
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.12 $"
-__date__ = "$Date: 2005/04/04 22:13:21 $"
+__revision__ = "$Revision: 1.13 $"
+__date__ = "$Date: 2005/04/18 19:41:34 $"
__copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -94,7 +94,7 @@
store = self.repository.store
results = []
docs = store.searchItems(self._version, query)
- for (uuid, (ver, attribute)) in docs.iteritems():
+ for uuid, (ver, attribute) in docs.iteritems():
if not uuid in self._deletedRegistry:
item = self.find(uuid, load=load)
if item is not None:
Index: chandler/repository/persistence/FileContainer.py
diff -u chandler/repository/persistence/FileContainer.py:1.19 chandler/repository/persistence/FileContainer.py:1.20
--- chandler/repository/persistence/FileContainer.py:1.19 Fri Mar 18 13:41:48 2005
+++ chandler/repository/persistence/FileContainer.py Mon Apr 18 12:41:34 2005
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.19 $"
-__date__ = "$Date: 2005/03/18 21:41:48 $"
+__revision__ = "$Revision: 1.20 $"
+__date__ = "$Date: 2005/04/18 19:41:34 $"
__copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -430,10 +430,6 @@
indexWriter = IndexWriter(directory, StandardAnalyzer(), True)
indexWriter.close()
- def close(self):
-
- super(IndexContainer, self).close()
-
def getIndexWriter(self):
writer = IndexWriter(DbDirectory(self.store.txn,
@@ -467,21 +463,15 @@
self._flags)
searcher = IndexSearcher(directory)
query = QueryParser.parse(query, "contents", StandardAnalyzer())
- hits = searcher.search(query)
- len = hits.length()
docs = {}
- i = 0
-
- while i < len:
- hit = hits.doc(i)
- ver = long(hit.get('version'))
+ for i, doc in searcher.search(query):
+ ver = long(doc['version'])
if ver <= version:
- uuid = UUID(hit.get('owner'))
+ uuid = UUID(doc['owner'])
dv = docs.get(uuid, None)
- if dv is None or dv is not None and dv[0] < ver:
- docs[uuid] = (ver, hit.get('attribute'))
- i += 1
+ if dv is None or dv[0] < ver:
+ docs[uuid] = (ver, doc['attribute'])
searcher.close()
Index: chandler/repository/schema/Types.py
diff -u chandler/repository/schema/Types.py:1.79 chandler/repository/schema/Types.py:1.80
--- chandler/repository/schema/Types.py:1.79 Fri Mar 18 13:41:51 2005
+++ chandler/repository/schema/Types.py Mon Apr 18 12:41:36 2005
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.79 $"
-__date__ = "$Date: 2005/03/18 21:41:51 $"
+__revision__ = "$Revision: 1.80 $"
+__date__ = "$Date: 2005/04/18 19:41:36 $"
__copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -25,12 +25,26 @@
class TypeKind(Kind):
- def _fillItem(self, name, parent, kind, **kwds):
+ def onItemLoad(self, view):
+
+ TypeHandler.typeHandlers[view][None] = self
+
+ def onItemCopy(self, view):
+
+ TypeHandler.typeHandlers[view][None] = self
- super(TypeKind, self)._fillItem(name, parent, kind, **kwds)
+ def onItemImport(self, view):
- typeHandlers = TypeHandler.typeHandlers[self.itsView]
- typeHandlers[None] = self
+ if view is not self.itsView:
+ try:
+ del TypeHandler.typeHandlers[self.itsView][None]
+ except KeyError:
+ pass
+ TypeHandler.typeHandlers[view][None] = self
+
+ def onViewClose(self, view):
+
+ TypeHandler.clear(view)
def findTypes(self, value):
"""Return a list of types recognizing value.
@@ -58,21 +72,37 @@
super(Type, self)._fillItem(name, parent, kind, **kwds)
self._status |= Item.SCHEMA | Item.PINNED
- def _registerTypeHandler(self, implementationType):
+ def _registerTypeHandler(self, implementationType, view):
if implementationType is not None:
try:
- typeHandlers = TypeHandler.typeHandlers[self.itsView]
+ typeHandlers = TypeHandler.typeHandlers[view]
except KeyError:
- typeHandlers = TypeHandler.typeHandlers[self.itsView] = {}
+ typeHandlers = TypeHandler.typeHandlers[view] = {}
if implementationType in typeHandlers:
typeHandlers[implementationType].append(self)
else:
typeHandlers[implementationType] = [ self ]
+ def _unregisterTypeHandler(self, implementationType, view):
+
+ if implementationType is not None:
+ try:
+ TypeHandler.typeHandlers[view][implementationType].remove(self)
+ except KeyError:
+ return
+ except ValueError:
+ return
+
def onItemLoad(self, view):
- self._registerTypeHandler(self.getImplementationType())
+ self._registerTypeHandler(self.getImplementationType(), view)
+
+ def onItemImport(self, view):
+ if view is not self.itsView:
+ implementationType = self.getImplementationType()
+ self._unregisterTypeHandler(implementationType, self.itsView)
+ self._registerTypeHandler(implementationType, view)
def getImplementationType(self):
return self.getAttributeValue('implementationTypes',
@@ -128,10 +158,17 @@
class String(Type):
- def _fillItem(self, name, parent, kind, **kwds):
+ def onItemLoad(self, view):
+
+ super(String, self).onItemLoad(view)
+ self._registerTypeHandler(str, view)
+
+ def onItemImport(self, view):
- super(String, self)._fillItem(name, parent, kind, **kwds)
- self._registerTypeHandler(str)
+ super(String, self).onItemImport(view)
+ if view is not self.itsView:
+ self._unregisterTypeHandler(str, self.itsView)
+ self._registerTypeHandler(str, view)
def getImplementationType(self):
Index: chandler/repository/persistence/RepositoryError.py
diff -u chandler/repository/persistence/RepositoryError.py:1.17 chandler/repository/persistence/RepositoryError.py:1.18
--- chandler/repository/persistence/RepositoryError.py:1.17 Mon Apr 4 15:13:21 2005
+++ chandler/repository/persistence/RepositoryError.py Mon Apr 18 12:41:34 2005
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.17 $"
-__date__ = "$Date: 2005/04/04 22:13:21 $"
+__revision__ = "$Revision: 1.18 $"
+__date__ = "$Date: 2005/04/18 19:41:34 $"
__copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -103,3 +103,16 @@
def __str__(self):
return self.__doc__ %(self.args[0], self.args[1], self.args[2])
+
+
+class ImportParentError(ItemImportError):
+ "No matching import parent %s for %s found"
+
+ def __str__(self):
+ return self.__doc__ %(self.args[0].itsPath, self.args[1]._repr_())
+
+class ImportKindError(ItemImportError):
+ "No matching import kind %s for %s found"
+
+ def __str__(self):
+ return self.__doc__ %(self.args[0].itsPath, self.args[1]._repr_())
Index: chandler/repository/schema/Kind.py
diff -u chandler/repository/schema/Kind.py:1.108 chandler/repository/schema/Kind.py:1.109
--- chandler/repository/schema/Kind.py:1.108 Mon Apr 4 15:13:21 2005
+++ chandler/repository/schema/Kind.py Mon Apr 18 12:41:36 2005
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.108 $"
-__date__ = "$Date: 2005/04/04 22:13:21 $"
+__revision__ = "$Revision: 1.109 $"
+__date__ = "$Date: 2005/04/18 19:41:36 $"
__copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -46,7 +46,7 @@
def _fillItem(self, name, parent, kind, **kwds):
super(Kind, self)._fillItem(name, parent, kind, **kwds)
- if not kwds['update']:
+ if not kwds.get('update'):
self.__init()
def onItemLoad(self, view):
Index: chandler/repository/persistence/DBRefs.py
diff -u chandler/repository/persistence/DBRefs.py:1.6 chandler/repository/persistence/DBRefs.py:1.7
--- chandler/repository/persistence/DBRefs.py:1.6 Mon Apr 4 15:13:21 2005
+++ chandler/repository/persistence/DBRefs.py Mon Apr 18 12:41:34 2005
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.6 $"
-__date__ = "$Date: 2005/04/04 22:13:21 $"
+__revision__ = "$Revision: 1.7 $"
+__date__ = "$Date: 2005/04/18 19:41:34 $"
__copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -46,11 +46,12 @@
return self.view.repository.store._refs
- def _copy_(self, target):
+ def _copy_(self, orig):
- target._changedRefs.clear()
- target._changedRefs.update(self._changedRefs)
- target._count = self._count
+ self._changedRefs.clear()
+ if isinstance(orig, PersistentRefs):
+ self._changedRefs.update(orig._changedRefs)
+ self._count = len(orig)
def _setItem(self, item):
@@ -322,10 +323,10 @@
return super(DBRefList, self)._createIndex(indexType, **kwds)
- def _copy_(self, target):
+ def _copy_(self, orig):
- RefList._copy_(self, target)
- PersistentRefs._copy_(self, target)
+ RefList._copy_(self, orig)
+ PersistentRefs._copy_(self, orig)
def _clear_(self):
@@ -343,7 +344,7 @@
target._original = self
- self._copy_(target)
+ target._copy_(self)
self._item._references[self._name] = target
try:
@@ -555,6 +556,10 @@
super(DBChildren, self).linkChanged(link, key)
self._changeRef(key, link)
+ def _unloadChild(self, child):
+
+ self._unloadRef(child)
+
def __delitem__(self, key):
link = super(DBChildren, self).__delitem__(key)
@@ -626,10 +631,10 @@
self._flags &= ~LinkedMap.NEW
PersistentRefs._clearDirties(self)
- def _copy_(self, target):
+ def _copy_(self, orig):
- Children._copy_(self, target)
- PersistentRefs._copy_(self, target)
+ Children._copy_(self, orig)
+ PersistentRefs._copy_(self, orig)
def _clear_(self):
@@ -654,7 +659,7 @@
target = self.view._createChildren(self._item, False)
target._original = self
- self._copy_(target)
+ target._copy_(self)
self._item._setChildren(target)
PersistentRefs._mergeChanges(target, oldVersion, toVersion)
Index: chandler/repository/util/LinkedMap.py
diff -u chandler/repository/util/LinkedMap.py:1.27 chandler/repository/util/LinkedMap.py:1.28
--- chandler/repository/util/LinkedMap.py:1.27 Fri Mar 18 13:41:53 2005
+++ chandler/repository/util/LinkedMap.py Mon Apr 18 12:41:38 2005
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.27 $"
-__date__ = "$Date: 2005/03/18 21:41:53 $"
+__revision__ = "$Revision: 1.28 $"
+__date__ = "$Date: 2005/04/18 19:41:38 $"
__copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -25,11 +25,11 @@
return "<link: %s>" %(self._value.__repr__())
- def _copy_(self, target):
+ def _copy_(self, orig):
- target._previousKey = self._previousKey
- target._nextKey = self._nextKey
- target._alias = self._alias
+ self._previousKey = orig._previousKey
+ self._nextKey = orig._nextKey
+ self._alias = orig._alias
def _setNext(self, nextKey, key, linkedMap):
@@ -92,20 +92,20 @@
if self._aliases is not None:
self._aliases.clear()
- def _copy_(self, target):
+ def _copy_(self, orig):
- target._clear_()
+ self._clear_()
- for key, link in super(LinkedMap, self).iteritems():
- targetLink = target._makeLink(link.getValue(self))
- link._copy_(targetLink)
- target._insert(key, targetLink)
+ for key, origLink in super(LinkedMap, orig).iteritems():
+ link = self._makeLink(origLink.getValue(orig))
+ link._copy_(origLink)
+ self._insert(key, link)
- target._firstKey = self._firstKey
- target._lastKey = self._lastKey
+ self._firstKey = orig._firstKey
+ self._lastKey = orig._lastKey
- if self._aliases is not None:
- target._aliases = self._aliases.copy()
+ if orig._aliases is not None:
+ self._aliases = orig._aliases.copy()
def linkChanged(self, link, key):
pass
Index: chandler/repository/schema/TypeHandler.py
diff -u chandler/repository/schema/TypeHandler.py:1.2 chandler/repository/schema/TypeHandler.py:1.3
--- chandler/repository/schema/TypeHandler.py:1.2 Fri Mar 18 13:41:51 2005
+++ chandler/repository/schema/TypeHandler.py Mon Apr 18 12:41:36 2005
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.2 $"
-__date__ = "$Date: 2005/03/18 21:41:51 $"
+__revision__ = "$Revision: 1.3 $"
+__date__ = "$Date: 2005/04/18 19:41:36 $"
__copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -39,10 +39,18 @@
return cls.typeHandler(view, value).makeString(value)
+ def clear(cls, view):
+
+ try:
+ cls.typeHandlers[view].clear()
+ except KeyError:
+ pass
+
typeHandler = classmethod(typeHandler)
makeString = classmethod(makeString)
makeValue = classmethod(makeValue)
+ clear = classmethod(clear)
typeHandlers = {}
typeDispatch = {
Index: chandler/repository/persistence/RepositoryView.py
diff -u chandler/repository/persistence/RepositoryView.py:1.38 chandler/repository/persistence/RepositoryView.py:1.39
--- chandler/repository/persistence/RepositoryView.py:1.38 Mon Apr 4 15:13:21 2005
+++ chandler/repository/persistence/RepositoryView.py Mon Apr 18 12:41:34 2005
@@ -1,21 +1,17 @@
-__revision__ = "$Revision: 1.38 $"
-__date__ = "$Date: 2005/04/04 22:13:21 $"
+__revision__ = "$Revision: 1.39 $"
+__date__ = "$Date: 2005/04/18 19:41:34 $"
__copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
-import logging, heapq, sys, gc
-
-from threading import currentThread, Thread
+import logging, heapq, sys, gc, threading
from chandlerdb.util.uuid import UUID
from chandlerdb.item.item import CItem
from repository.util.Path import Path
from repository.util.ThreadSemaphore import ThreadSemaphore
from repository.util.Lob import Lob
-from repository.persistence.RepositoryError \
- import RepositoryError, VersionConflictError, \
- RecursiveLoadItemError, ItemImportError
+from repository.persistence.RepositoryError import *
from repository.item.Children import Children
from repository.item.RefCollections import TransientRefList
@@ -44,7 +40,7 @@
raise RepositoryError, "Repository is not open"
self.repository = repository
- self.name = name or currentThread().getName()
+ self.name = name or threading.currentThread().getName()
self.openView()
@@ -154,6 +150,8 @@
repository._openViews.remove(self)
for item in self._registry.itervalues():
+ if hasattr(type(item), 'onViewClose'):
+ item.onViewClose(self)
item._setStale()
self._registry.clear()
@@ -363,6 +361,10 @@
return self.find(uuid, load)
+ def findMatch(self, view, matches=None):
+
+ return view
+
def _findKind(self, spec, withSchema):
return self.find(spec)
@@ -791,90 +793,83 @@
def importItem(self, item):
- if self.find(item._uuid) is not None:
- raise ItemImportError, (item, self, "item already exists")
-
items = set()
view = item.itsView
if view is self:
return items
- item._collectItems(items,
- lambda _item: (_item.isNew() or
- self.find(_item._uuid) is None))
-
+ replace = {}
+
+ def filterItem(_item):
+ if _item.findMatch(self, replace):
+ return False
+
+ if _item._isCopyExport():
+ _item._copyExport(self, 'export', replace)
+ return False
+
+ return True
+
+ item._collectItems(items, filterItem)
+ self._importValues(items, replace, view)
+ self._importItems(items, replace, view)
+
+ return items
+
+ def _importValues(self, items, replace, view):
+
sameType = type(self) is type(view)
- for _item in items:
- kind = _item._kind
+ for item in items:
+ kind = item._kind
if not (kind is None or kind in items):
- localKind = self.find(kind._uuid)
+ localKind = replace.get(kind)
if localKind is None:
- raise ItemImportError, (_item, self,
- "Kind %s not found" %(kind.itsPath))
- item._kind = kind
-
- for key, value in _item._values.iteritems():
- if not sameType and isinstance(value, Lob):
- _item._values[key] = value.copy(self)
-
- for key, value in _item._references.items():
- if value is not None:
- if value._isRefList():
- if sameType or value._isTransient():
- previous = None
- for other in value:
- if other not in items:
- value.remove(other)
- other = self.find(other._uuid)
- value.insertItem(other, previous)
- else:
- localValue = self._createRefList(_item, value._name, value._otherName, True, False, True, UUID())
- value._copyIndexes(localValue)
- for other in value:
- if other in items:
- localValue._setRef(other, load=True,
- noMonitors=True)
- else:
- value.remove(other)
- path = other.itsPath
- other = self.find(other._uuid)
- localValue.append(other)
- localValue._aliases = value._aliases
- _item._references[key] = localValue
- else:
- if value._isUUID():
- value = self.find(value)
- if value not in items:
- _item.removeAttributeValue(key)
- _item.setAttributeValue(key, value)
-
- for _item in items:
- parent = _item.itsParent
- if hasattr(type(_item), 'onItemImport'):
- _item.onItemImport(self)
+ localKind = self.find(kind._uuid)
+ if localKind is None:
+ raise ImportKindError, (kind, item)
+ item._kind = localKind
+ localKind._setupClass(type(item))
+
+ try:
+ item._status |= CItem.IMPORTING
+ item._values._import(self)
+ item._references._import(self, items, replace)
+ finally:
+ item._status &= ~CItem.IMPORTING
+
+ def _importItems(self, items, replace, view):
+
+ sameType = type(self) is type(view)
+
+ def setRoot(root, _item):
+ view._unregisterItem(_item, False)
+ self._registerItem(_item)
+ _item._root = root
+ for child in _item.iterChildren():
+ setRoot(root, child)
+
+ for item in items:
+ if hasattr(type(item), 'onItemImport'):
+ item.onItemImport(self)
+ if not sameType and item.hasChildren():
+ children = self._createChildren(item, True)
+ for child in item.iterChildren():
+ children._append(child)
+ item._children = children
+ parent = item.itsParent
if not parent in items:
- if parent is view:
- localParent = self
- else:
- localParent = self.find(parent._uuid)
+ localParent = parent.findMatch(self, replace)
+ if localParent is None:
+ raise ImportParentError, (parent, item)
if localParent is not parent:
- def setRoot(root, __item):
- view._unregisterItem(__item, False)
- self._registerItem(__item)
- __item._root = root
- for child in __item.iterChildren():
- setRoot(root, child)
- if _item.isNew():
- parent._removeItem(_item)
+ if item.isNew():
+ parent._removeItem(item)
else:
- parent._unloadChild(_item)
- root = localParent._addItem(_item)
- _item._parent = localParent
- setRoot(root, _item)
-
- return items
-
+ parent._unloadChild(item)
+ root = localParent._addItem(item)
+ item._parent = localParent
+ setRoot(root, item)
itsUUID = property(__getUUID)
itsName = property(__getName)
Index: chandler/repository/schema/Cloud.py
diff -u chandler/repository/schema/Cloud.py:1.27 chandler/repository/schema/Cloud.py:1.28
--- chandler/repository/schema/Cloud.py:1.27 Thu Apr 7 10:13:30 2005
+++ chandler/repository/schema/Cloud.py Mon Apr 18 12:41:36 2005
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.27 $"
-__date__ = "$Date: 2005/04/07 17:13:30 $"
+__revision__ = "$Revision: 1.28 $"
+__date__ = "$Date: 2005/04/18 19:41:36 $"
__copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -214,6 +214,49 @@
for item in deleting:
deleteItem(item)
+ def exportItems(self, item, view, cloudAlias, matches):
+
+ items = {}
+ references = {}
+ copies = {}
+
+ exporting = self.getItems(item, cloudAlias, items, references)
+
+ def exportOther(copy, other, policy):
+ if other is None:
+ return None
+
+ uuid = other._uuid
+ if uuid in items or uuid in references:
+ match = other.findMatch(view, matches)
+ if match is not None:
+ return match
+
+ elif other._isCopyExport():
+ otherParent = other.itsParent
+ parent = otherParent.findMatch(view, matches)
+ if parent is None:
+ parent = exportOther(None, otherParent, None)
+ if parent is None or parent is Item.Nil:
+ raise ValueError, 'export parent (%s) not found while exporting %s: %s' %(otherParent.itsPath, other.itsPath, parent)
+ otherKind = other.itsKind
+ kind = otherKind.findMatch(view, matches)
+ if kind is None:
+ kind = exportOther(None, otherKind, None)
+ match = other.copy(other._name, parent,
+ copies, 'remove', None, exportOther,
+ kind)
+ matches[other] = match
+ return match
+
+ else:
+ return other
+
+ return Item.Nil
+
+ for item in exporting:
+ exportOther(None, item, None)
+
def getAttributeEndpoints(self, attrName, index=0, cloudAlias=None):
endpoints = []
@@ -363,7 +406,6 @@
references[item._uuid] = item
elif policy == 'byCloud':
-
def getItems(cloud):
results.extend(cloud.getItems(item, cloudAlias,
items, references, trace))
@@ -383,11 +425,11 @@
getItems(cloud)
elif policy == 'byMethod':
- method = self.getAttributeValue('method', default=None,
- _attrDict=self._values)
- if method is not None:
- results.extend(getattr(item, method)(items, references,
- cloudAlias))
+ results.extend(getattr(item, self.method)(items, references,
+ cloudAlias))
+
+ elif policy == 'none':
+ pass
else:
raise NotImplementedError, policy
@@ -447,7 +489,7 @@
if isinstance(value, Item) or isinstance(value, RefList):
values.append(value)
elif isinstance(value, PersistentCollection):
- values.append(value._getItems())
+ values.append(value._iterItems())
else:
raise TypeError, type(value)
@@ -455,7 +497,7 @@
for name in self.attribute:
if isinstance(value, PersistentCollection):
values = []
- for v in value._getItems():
+ for v in value._iterItems():
append(values, v.getAttributeValue(name, default=None))
value = values
elif isinstance(value, RefList):
@@ -487,6 +529,9 @@
if isinstance(value, Item):
return [value]
+ if isinstance(value, PersistentCollection):
+ return value._iterItems()
+
return value
Index: chandler/Makefile
diff -u chandler/Makefile:1.99 chandler/Makefile:1.100
--- chandler/Makefile:1.99 Tue Apr 12 18:16:28 2005
+++ chandler/Makefile Mon Apr 18 12:41:28 2005
@@ -19,7 +19,7 @@
# these get installed into release or debug
ARCHIVES=$(CHANDLERARCHIVES)/Launchers-$(SNAP)-0.4-9.tar.gz \
- $(CHANDLERARCHIVES)/chandlerdb-$(SNAP)-0.5-6.tar.gz \
+ $(CHANDLERARCHIVES)/chandlerdb-$(SNAP)-0.5-7.tar.gz \
$(CHANDLERARCHIVES)/db-$(SNAP)-4.3.27-1.tar.gz \
$(CHANDLERARCHIVES)/egenix-mx-base-$(SNAP)-2.1.0-3.tar.gz \
$(CHANDLERARCHIVES)/epydoc-$(SNAP)-2.1-2.tar.gz \
@@ -27,7 +27,7 @@
$(CHANDLERARCHIVES)/libxml2-$(SNAP)-2.6.16-3.tar.gz \
$(CHANDLERARCHIVES)/m2crypto-$(SNAP)-0.12-9.tar.gz \
$(CHANDLERARCHIVES)/pychecker-$(SNAP)-0.8.13-2.tar.gz \
- $(CHANDLERARCHIVES)/pylucene-$(SNAP)-0.9.8-1.tar.gz \
+ $(CHANDLERARCHIVES)/pylucene-$(SNAP)-0.9.8-188-1.tar.gz \
$(CHANDLERARCHIVES)/python-$(SNAP)-2.4-2.tar.gz \
$(CHANDLERARCHIVES)/soappy-$(SNAP)-0.10.2-2.tar.gz \
$(CHANDLERARCHIVES)/twisted-$(SNAP)-r11303-4.tar.gz \
Index: chandler/repository/item/Children.py
diff -u chandler/repository/item/Children.py:1.1 chandler/repository/item/Children.py:1.2
--- chandler/repository/item/Children.py:1.1 Mon Apr 4 15:13:19 2005
+++ chandler/repository/item/Children.py Mon Apr 18 12:41:29 2005
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.1 $"
-__date__ = "$Date: 2005/04/04 22:13:19 $"
+__revision__ = "$Revision: 1.2 $"
+__date__ = "$Date: 2005/04/18 19:41:29 $"
__copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -41,7 +41,11 @@
def _unloadChild(self, child):
- self._unloadRef(child)
+ raise NotImplementedError, "%s._unloadChild" %(type(self))
+
+ def _append(self, child):
+
+ self.__setitem__(child._uuid, child, None, None, child._name)
def __repr__(self):
Index: chandler/repository/item/Item.py
diff -u chandler/repository/item/Item.py:1.205 chandler/repository/item/Item.py:1.206
--- chandler/repository/item/Item.py:1.205 Mon Apr 4 19:23:39 2005
+++ chandler/repository/item/Item.py Mon Apr 18 12:41:30 2005
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.205 $"
-__date__ = "$Date: 2005/04/05 02:23:39 $"
+__revision__ = "$Revision: 1.206 $"
+__date__ = "$Date: 2005/04/18 19:41:30 $"
__copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -715,6 +715,10 @@
kind = self._kind
if kind is not None:
+ if kind.itsView is not self.itsView:
+ self.itsView.logger.error("kind %s for item %s is in view %s, not in item's view %s", kind.itsPath, self.itsPath, kind.itsView, self.itsView)
+ return False
+
for name, desc in kind._getDescriptors(type(self)).iteritems():
attrDict, required = desc.isValueRequired(self)
if required and name not in attrDict:
@@ -1275,7 +1279,7 @@
return items.values()
def copy(self, name=None, parent=None, copies=None,
- copyPolicy=None, cloudAlias=None, copyFn=None):
+ copyPolicy=None, cloudAlias=None, copyFn=None, kind=None):
"""
Copy this item.
@@ -1325,8 +1329,12 @@
cls = type(self)
item = cls.__new__(cls)
- item._fillItem(name, parent or self.itsParent, self._kind,
- uuid = UUID(), version = self._version,
+ if kind is None:
+ kind = self._kind
+ if kind is not None:
+ kind._setupClass(cls)
+ item._fillItem(name, parent or self.itsParent, kind,
+ uuid = UUID(), version = 0,
values = Values(item), references = References(item))
item._status |= Item.NEW
copies[self._uuid] = item
@@ -1446,10 +1454,25 @@
self._status &= ~Item.DELETING
for other in others:
- if other.refCount(counted=True) == 0:
- other.delete(recursive=recursive, deletePolicy=deletePolicy)
+ if other.refCount(True) == 0:
+ other.delete(recursive, deletePolicy)
self._kind = None
+
+ def _copyExport(self, view, cloudAlias, matches):
+
+ if not self in matches:
+ kind = self._kind
+ if kind is None:
+ parent = self.itsParent.findMatch(view, matches)
+ if parent is None:
+ raise ValueError, 'match for parent (%s) not found' %(self.itsParent.itsPath)
+ matches[self] = self.copy(self._name, parent)
+ else:
+ for cloud in kind.getClouds(cloudAlias):
+ cloud.exportItems(self, view, cloudAlias, matches)
+
+ return matches[self]
def __getName(self):
@@ -2115,6 +2138,22 @@
return self.getRepositoryView().find(uuid, load)
+ def findMatch(self, view, matches=None):
+
+ if matches is not None:
+ match = matches.get(self)
+ else:
+ match = None
+
+ if match is None:
+ match = view.find(self._uuid)
+ if match is None and self._name is not None:
+ match = view.find(self.itsPath)
+ if not (match is None or matches is None):
+ matches[self] = match
+
+ return match
+
def _unloadItem(self, reloadable):
if self.isDirty():
Index: chandler/repository/item/Monitors.py
diff -u chandler/repository/item/Monitors.py:1.11 chandler/repository/item/Monitors.py:1.12
--- chandler/repository/item/Monitors.py:1.11 Mon Apr 4 15:13:20 2005
+++ chandler/repository/item/Monitors.py Mon Apr 18 12:41:30 2005
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.11 $"
-__date__ = "$Date: 2005/04/04 22:13:20 $"
+__revision__ = "$Revision: 1.12 $"
+__date__ = "$Date: 2005/04/18 19:41:30 $"
__copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -16,12 +16,20 @@
def onItemImport(self, view):
+ if view is not self.itsView:
+ try:
+ del Monitors.instances[self.itsView]
+ except KeyError:
+ pass
+ self.setPinned()
+ Monitors.instances[view] = self
+
+ def onViewClose(self, view):
+
try:
- del Monitors.instances[self.itsView]
+ del Monitors.instances[view]
except KeyError:
pass
-
- Monitors.instances[view] = self
def getInstance(cls, view):
@@ -40,6 +48,9 @@
monitors = cls.getInstance(item.itsView).monitoring[op][attribute]
except KeyError:
return
+ except AttributeError:
+ print 'no monitor singleton'
+ return
for monitorItem, method, args, kwds in monitors:
getattr(monitorItem, method)(op, item, attribute, *args, **kwds)
Index: chandler/repository/item/Values.py
diff -u chandler/repository/item/Values.py:1.45 chandler/repository/item/Values.py:1.46
--- chandler/repository/item/Values.py:1.45 Mon Apr 4 15:13:20 2005
+++ chandler/repository/item/Values.py Mon Apr 18 12:41:30 2005
@@ -1,12 +1,13 @@
-__revision__ = "$Revision: 1.45 $"
-__date__ = "$Date: 2005/04/04 22:13:20 $"
+__revision__ = "$Revision: 1.46 $"
+__date__ = "$Date: 2005/04/18 19:41:30 $"
__copyright__ = "Copyright (c) 2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
from chandlerdb.util.uuid import UUID
from chandlerdb.item.ItemError import *
from repository.util.Path import Path
+from repository.util.Lob import Lob
from repository.item.PersistentCollections import PersistentCollection
from repository.item.RefCollections import RefList
from repository.util.SingleRef import SingleRef
@@ -76,6 +77,14 @@
else:
self[name] = value
+ self._copyFlags(orig, name)
+
+ def _copyFlags(self, orig, name):
+
+ flags = orig._getFlags(name, 0) & Values.COPYMASK
+ if flags != 0:
+ self._setFlags(name, flags)
+
def __setitem__(self, key, value):
if self._getFlags(key) & Values.READONLY:
@@ -344,6 +353,14 @@
return result
+ def _import(self, view):
+
+ item = self._item
+ if type(view) is not type(item.itsView):
+ for key, value in self.iteritems():
+ if isinstance(value, Lob):
+ item.setAttributeValue(key, value.copy(view), self)
+
READONLY = 0x0001 # value is read-only
@@ -351,7 +368,8 @@
TRANSIENT = 0x0200 # value is transient
NOINHERIT = 0x0400 # no schema for inheriting a value
SAVEMASK = 0x00ff # save these flags
-
+ COPYMASK = READONLY | TRANSIENT | NOINHERIT
+
class References(Values):
@@ -365,7 +383,9 @@
if other is not None:
view = self._item.itsView
otherView = other.itsView
- if otherView is not view:
+ if not (otherView is view or
+ self._item._isImporting() or
+ other._isImporting()):
if otherView._isNullView() or view._isNullView():
view.importItem(other)
else:
@@ -561,6 +581,7 @@
value._copy(item, name, policy, copyFn)
else:
orig._copyRef(item, name, value, policy, copyFn)
+ self._copyFlags(orig, name)
def _unload(self):
@@ -755,6 +776,11 @@
other, self._item.itsPath, name)
return False
+ if other.itsView is not self._item.itsView:
+ logger.error("views don't match: %s at %s.%s",
+ other, self._item.itsPath, name)
+ return False
+
otherName = self._item._kind.getOtherName(name, default=None)
if otherName is None:
logger.error('otherName is None for attribute %s.%s',
@@ -818,7 +844,51 @@
result = result and check
return result
-
+
+ def _import(self, view, items, replace):
+
+ item = self._item
+ itemView = item.itsView
+ sameType = type(view) is type(itemView)
+
+ for key, value in self.items():
+ if value is not None:
+ if value._isRefList():
+ if sameType or value._isTransient():
+ previous = None
+ for other in value:
+ if other not in items:
+ alias = value.getAlias(other)
+ value.remove(other)
+ localOther = other.findMatch(view, replace)
+ if localOther is not None:
+ value.insertItem(localOther, previous)
+ if alias is not None:
+ value.setAlias(other, alias)
+ else:
+ localValue = view._createRefList(item, value._name, value._otherName, True, False, True, UUID())
+ value._copyIndexes(localValue)
+ for other in value:
+ if other in items:
+ localValue._setRef(other, load=True,
+ alias=value.getAlias(other),
+ noMonitors=True)
+ else:
+ value.remove(other)
+ localOther = other.findMatch(view, replace)
+ if localOther is not None:
+ localValue.append(localOther,
+ value.getAlias(other))
+ item._references[key] = localValue
+ else:
+ if value._isUUID():
+ value = itemView.find(value)
+ if value not in items:
+ localOther = value.findMatch(view, replace)
+ item.removeAttributeValue(key)
+ if localOther is not None:
+ item.setAttributeValue(key, localOther)
+
class ItemValue(object):
'A superclass for values that are owned by an item.'
Index: chandler/repository/item/RefCollections.py
diff -u chandler/repository/item/RefCollections.py:1.15 chandler/repository/item/RefCollections.py:1.16
--- chandler/repository/item/RefCollections.py:1.15 Mon Apr 4 15:13:20 2005
+++ chandler/repository/item/RefCollections.py Mon Apr 18 12:41:30 2005
@@ -1,6 +1,6 @@
-__revision__ = "$Revision: 1.15 $"
-__date__ = "$Date: 2005/04/04 22:13:20 $"
+__revision__ = "$Revision: 1.16 $"
+__date__ = "$Date: 2005/04/18 19:41:30 $"
__copyright__ = "Copyright (c) 2003-2004 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -95,8 +95,11 @@
for key in self.iterkeys():
link = self._get(key)
copyOther = copyFn(copyItem, link.getValue(self), policy)
- if copyOther is not copyItem.Nil and copyOther not in refList:
- refList.append(copyOther, link._alias)
+ if copyOther is not copyItem.Nil:
+ if copyOther not in refList:
+ refList.append(copyOther, link._alias)
+ elif link._alias is not None:
+ refList.setAlias(copyOther, link._alias)
return refList
@@ -534,6 +537,10 @@
return self._get(item._uuid)._alias
+ def setAlias(self, item, alias):
+
+ return super(RefList, self).setAlias(item._uuid, alias)
+
def getByIndex(self, indexName, position):
"""
Get an item through its position in an index.
Index: chandler/repository/packs/schema.pack
diff -u chandler/repository/packs/schema.pack:1.23 chandler/repository/packs/schema.pack:1.24
--- chandler/repository/packs/schema.pack:1.23 Thu Jan 27 22:03:47 2005
+++ chandler/repository/packs/schema.pack Mon Apr 18 12:41:30 2005
@@ -32,6 +32,7 @@
<item file="Kind.cloud" />
<item file="Attribute.cloud" />
<item file="Item.cloud" />
+ <item file="Struct.cloud" />
</item>
<item file="Mixins.namespace" />
Index: chandler/repository/packs/schema/model/clouds/Attribute.cloud
diff -u chandler/repository/packs/schema/model/clouds/Attribute.cloud:1.5 chandler/repository/packs/schema/model/clouds/Attribute.cloud:1.6
--- chandler/repository/packs/schema/model/clouds/Attribute.cloud:1.5 Mon Nov 8 09:41:25 2004
+++ chandler/repository/packs/schema/model/clouds/Attribute.cloud Mon Apr 18 12:41:32 2005
@@ -13,7 +13,7 @@
-->
</ref>
- <ref name="kind" otherAlias="remote"
+ <ref name="kind" otherAlias="export"
type="path">//Schema/Core/Attribute</ref>
</item>
@@ -29,7 +29,7 @@
<attribute name="attribute">
<value>type</value>
</attribute>
- <attribute name="includePolicy">byValue</attribute>
+ <attribute name="includePolicy">byCloud</attribute>
</item>
</items>
Index: chandler/repository/packs/schema/model/clouds/Item.cloud
diff -u chandler/repository/packs/schema/model/clouds/Item.cloud:1.4 chandler/repository/packs/schema/model/clouds/Item.cloud:1.5
--- chandler/repository/packs/schema/model/clouds/Item.cloud:1.4 Mon Nov 8 09:41:25 2004
+++ chandler/repository/packs/schema/model/clouds/Item.cloud Mon Apr 18 12:41:32 2005
@@ -9,7 +9,7 @@
<ref name="endpoints">
</ref>
- <ref name="kind" otherAlias="remote"
+ <ref name="kind" otherAlias="export"
type="path">//Schema/Core/Item</ref>
</item>
Index: chandler/repository/packs/schema/model/clouds/Kind.cloud
diff -u chandler/repository/packs/schema/model/clouds/Kind.cloud:1.5 chandler/repository/packs/schema/model/clouds/Kind.cloud:1.6
--- chandler/repository/packs/schema/model/clouds/Kind.cloud:1.5 Mon Nov 8 09:41:25 2004
+++ chandler/repository/packs/schema/model/clouds/Kind.cloud Mon Apr 18 12:41:32 2005
@@ -13,7 +13,7 @@
-->
</ref>
- <ref name="kind" otherAlias="remote"
+ <ref name="kind" otherAlias="export"
type="path">//Schema/Core/Kind</ref>
</item>
@@ -30,8 +30,6 @@
<value>attributes</value>
</attribute>
<attribute name="includePolicy">byCloud</attribute>
-
- <ref name="cloud" type="path">//Schema/Core/Clouds/Attribute</ref>
</item>
<item>
@@ -40,15 +38,28 @@
<parent type="path">//Schema/Core/Clouds/Kind</parent>
<ref name="clouds">
- <ref otherAlias="inheritedAttributes" type="path">..</ref>
+ <ref otherAlias="attributes" type="path">..</ref>
</ref>
<attribute name="attribute">
<value>inheritedAttributes</value>
</attribute>
<attribute name="includePolicy">byCloud</attribute>
+ </item>
+
+ <item>
+ <name>superKinds</name>
+ <kind type="path">//Schema/Core/Endpoint</kind>
+ <parent type="path">//Schema/Core/Clouds/Kind</parent>
- <ref name="cloud" type="path">//Schema/Core/Clouds/Attribute</ref>
+ <ref name="clouds">
+ <ref otherAlias="inheritedAttributes" type="path">..</ref>
+ </ref>
+
+ <attribute name="attribute">
+ <value>superKinds</value>
+ </attribute>
+ <attribute name="includePolicy">byCloud</attribute>
</item>
</items>
More information about the Commits
mailing list