[Zope-Checkins] CVS: Zope2 - Catalog.py:1.70.6.5 ZCatalog.py:1.88.6.11 ZCatalogIndexes.py:1.1.2.12
Matthew T. Kromer
matt@digicool.com
Mon, 21 May 2001 17:34:58 -0400 (EDT)
Update of /cvs-repository/Zope2/lib/python/Products/ZCatalog
In directory korak.digicool.com:/tmp/cvs-serv3834/ZCatalog
Modified Files:
Tag: ajung-dropin-registry
Catalog.py ZCatalog.py ZCatalogIndexes.py
Log Message:
Move indexes back into catalog from Zcatalog
--- Updated File Catalog.py in package Zope2 --
--- Catalog.py 2001/05/21 18:22:18 1.70.6.4
+++ Catalog.py 2001/05/21 21:34:57 1.70.6.5
@@ -151,14 +151,6 @@
self.updateBrains()
- def replaceIndexes(self, indexes):
- """Replace the existing indexes with a new index container, returning
- the old container."""
-
- oldindexes = self.indexes
- self.indexes = indexes
- return oldindexes
-
def clear(self):
""" clear catalog """
@@ -329,14 +321,15 @@
self.data[key] = tuple(rec)
def addIndex(self, name, index_type):
- """Create a new index, of one of the following index_types
+ """Create a new index, given a name and a index_type.
- Types: 'FieldIndex', 'TextIndex', 'KeywordIndex'.
- """
+ Old format: index_type was a string, 'FieldIndex' 'TextIndex' or
+ 'KeywordIndex' is no longer valid; the actual index must be instantiated
+ and passed in to addIndex.
- raise NotImplementedError, """Catalog.addIndex is no longer implemented.
- Please use Catalog.replaceIndexes and then directly manage the replaced
- indexes."""
+ New format: index_type is the actual index object to be stored.
+
+ """
if self.indexes.has_key(name):
raise 'Index Exists', 'The index specified already exists'
@@ -349,25 +342,11 @@
indexes = self.indexes
- if hasattr(indexes,"__supports_pluggable_indexes__"):
- indexes.addIndex(self, name, index_type)
- else:
- if index_type == 'FieldIndex':
- indexes[name] = UnIndex.UnIndex(name)
- elif index_type == 'TextIndex':
- lexicon=self.lexicon
- if type(lexicon) is type(''):
- lexicon=getattr(self, lexicon).getLexicon()
-
- indexes[name] = UnTextIndex.UnTextIndex(name, None, None,
- lexicon)
- elif index_type == 'KeywordIndex':
- indexes[name] = UnKeywordIndex.UnKeywordIndex(name)
- else:
- raise 'Unknown Index Type', (
- "%s invalid - must be one of %s"
- % (index_type, ['FieldIndex', 'TextIndex', 'KeywordIndex'])
- )
+ if type(index_type) == type(''):
+ raise TypeError,"""Catalog addIndex now requires the index type to
+ be resolved prior to adding; create the proper index in the caller."""
+
+ indexes[name] = index_type;
self.indexes = indexes
--- Updated File ZCatalog.py in package Zope2 --
--- ZCatalog.py 2001/05/21 20:23:50 1.88.6.10
+++ ZCatalog.py 2001/05/21 21:34:57 1.88.6.11
@@ -156,12 +156,12 @@
'action': 'manage_catalogView',
'target': 'manage_main',
'help':('ZCatalog','ZCatalog_Cataloged-Objects.stx')},
- {'label': 'Indexes', # TAB: Indexes
- 'action': 'Indexes/manage_workspace',
- },
{'label': 'Properties', # TAB: Properties
'action': 'manage_propertiesForm',
'help': ('OFSP','Properties.stx')},
+ {'label': 'Indexes', # TAB: Indexes
+ 'action': 'Indexes/manage_workspace',
+ },
{'label': 'Metadata', # TAB: Metadata
'action': 'manage_catalogSchema',
'target':'manage_main',
@@ -245,15 +245,6 @@
self._catalog = Catalog(vocabulary=self.vocab_id)
- self._indexes = {}
-
- #indexes = ZCatalogIndexes('Indexes',vocabulary=self.vocab_id,caller=self)
- indexes = self._indexes
-
- #self._setObject('Indexes', indexes)
-
- self._catalog.replaceIndexes(indexes)
-
self.addColumn('id')
self.addIndex('id', 'FieldIndex')
@@ -789,23 +780,13 @@
index = base(name, self)
- self._indexes[name] = index
- self._p_changed = 1
+ self._catalog.addIndex(name,index)
def delIndex(self, name ):
print "del index %s" % (name)
-
- # Lame.....this needs to be fixed
- del self._indexes[name]
- self._p_changed = 1
-
-
- def clearIndex(self, name ):
- print "clear index %s" % (name)
- # Lame.....this needs to be fixed
- self._indexes[name].clear()
+ self._catalog.delIndex(name)
def addColumn(self, name, default_value=None):
--- Updated File ZCatalogIndexes.py in package Zope2 --
--- ZCatalogIndexes.py 2001/05/21 20:23:50 1.1.2.11
+++ ZCatalogIndexes.py 2001/05/21 21:34:57 1.1.2.12
@@ -142,25 +142,25 @@
# base accessors loop back through our dictionary interface
def _setOb(self, id, object):
- indexes = self.aq_parent._indexes
+ indexes = self.aq_parent._catalog.indexes
indexes[id] = object
self.aq_parent._indexes = indexes
#self.aq_parent._p_changed = 1
def _delOb(self, id):
- indexes = self.aq_parent._indexes
+ indexes = self.aq_parent._catalog.indexes
del indexes[id]
self.aq_parent._indexes = indexes
#self.aq_parent._p_changed = 1
def _getOb(self, id, default=_marker):
- indexes = self.aq_parent._indexes
+ indexes = self.aq_parent._catalog.indexes
if default is _marker: return indexes.get(id)
return indexes.get(id, default)
def objectIds(self, spec=None):
print "ZCatalogIndexes: objectIds(%s)" % spec
- indexes = self.aq_parent._indexes
+ indexes = self.aq_parent._catalog.indexes
if spec is not None:
if type(spec) == type('s'):
spec = [spec]
@@ -184,9 +184,21 @@
#
def __bobo_traverse__(self, REQUEST, name):
- indexes = self.aq_parent._indexes;
+ indexes = self.aq_parent._catalog.indexes;
o = indexes.get(name, None)
- if o is not None: return o.__of__(self)
+ if o is not None:
+ print dir(o)
+ if getattr(o,'manage_workspace', None) is None:
+ o = OldCatalogWrapperObject(o)
+ return o.__of__(self)
return getattr(self, name)
+
+class OldCatalogWrapperObject(SimpleItem, Implicit):
+
+ manage_main = DTMLFile('dtml/oldcatmanage',globals())
+
+ def __init__(self, o):
+ self.index = o
+