[Zope-Checkins] CVS: Zope/lib/python/Products/ZCatalog - Catalog.py:1.88 ZCatalog.py:1.110
Casey Duncan
casey@zope.com
Tue, 11 Jun 2002 16:20:43 -0400
Update of /cvs-repository/Zope/lib/python/Products/ZCatalog
In directory cvs.zope.org:/tmp/cvs-serv28876/lib/python/Products/ZCatalog
Modified Files:
Catalog.py ZCatalog.py
Log Message:
Removed vocabulary management from catalog/ZCatalog. They now have no awareness of vocabularies.
The only API change was the removal of the getVocabulary method from ZCatalog.
Old-style TextIndexes can now acquire a Vocabulary from anywhere.
No Indexes, metadata or vocabulary objects are created automatically by ZCatalog.
=== Zope/lib/python/Products/ZCatalog/Catalog.py 1.87 => 1.88 ===
def __init__(self, vocabulary=None, brains=None):
+ # Catalogs no longer care about vocabularies and lexicons
+ # so the vocabulary argument is ignored. (Casey)
self.schema = {} # mapping from attribute name to column number
self.names = () # sequence of column names
@@ -63,15 +65,6 @@
self.__len__=BTrees.Length.Length()
self.clear()
- # indexes can share a lexicon or have a private copy. Here,
- # we instantiate a lexicon to be shared by all text indexes.
- # This may change.
-
- if isinstance(vocabulary, types.StringType):
- self.lexicon = vocabulary
- else:
- self.lexicon = Lexicon()
-
if brains is not None:
self._v_brains = brains
@@ -115,11 +108,6 @@
if hasattr(index, '__of__'): index=index.__of__(self)
index._convertBTrees(threshold)
- lexicon=self.lexicon
- if isistance(lexicon, types.StringType):
- lexicon=getattr(self, lexicon).lexicon
- lexicon._convertBTrees(threshold)
-
def __len__(self):
# NOTE, this is never called for new catalogs, since
# each instance overrides this.
@@ -153,8 +141,6 @@
catalog is first activated (from the persistent storage) """
Persistent.__setstate__(self, state)
self.updateBrains()
- if not hasattr(self, 'lexicon'):
- self.lexicon = Lexicon()
def useBrains(self, brains):
""" Sets up the Catalog to return an object (ala ZTables) that
=== Zope/lib/python/Products/ZCatalog/ZCatalog.py 1.109 => 1.110 ===
def manage_addZCatalog(self, id, title,
- vocab_id='create_default_catalog_',
+ vocab_id=None, # Deprecated
REQUEST=None):
"""Add a ZCatalog object
"""
id=str(id)
- title=str(title)
- vocab_id=str(vocab_id)
- if vocab_id == 'create_default_catalog_':
- vocab_id = None
-
+ title=str(title)
c=ZCatalog(id, title, vocab_id, self)
self._setObject(id, c)
if REQUEST is not None:
@@ -156,52 +152,32 @@
_v_transaction = None
def __init__(self, id, title='', vocab_id=None, container=None):
- if vocab_id is not None and container is None:
- raise CatalogError, ("You cannot specify a vocab_id without "
- "also specifying a container.")
+ # ZCatalog no longer cares about vocabularies
+ # so the vocab_id argument is ignored (Casey)
+
if container is not None:
self=self.__of__(container)
self.id=id
self.title=title
-
+
+ # vocabulary and vocab_id are left for backwards
+ # compatibility only, they are not used anymore
self.vocabulary = None
+ self.vocab_id = ''
self.threshold = 10000
self._v_total = 0
- if vocab_id is None:
- v = Vocabulary('Vocabulary', 'Vocabulary', globbing=1)
- self._setObject('Vocabulary', v)
- self.vocabulary = v
- self.vocab_id = 'Vocabulary'
- else:
- self.vocab_id = vocab_id
-
-
- self._catalog = Catalog(vocabulary=self.vocab_id)
-
- self.addColumn('id')
- self.addIndex('id', 'FieldIndex')
-
- self.addColumn('title')
- self.addIndex('title', 'TextIndex')
+ self._catalog = Catalog()
- self.addColumn('meta_type')
- self.addIndex('meta_type', 'FieldIndex')
-
- self.addColumn('bobobase_modification_time')
- self.addIndex('bobobase_modification_time', 'FieldIndex')
-
- self.addColumn('summary')
- self.addIndex('PrincipiaSearchSource', 'TextIndex')
-
- self.addIndex('path','PathIndex')
-
- def __len__(self): return len(self._catalog)
-
- def getVocabulary(self):
- """ more ack! """
- return getattr(self, self.vocab_id)
+ def __len__(self):
+ return len(self._catalog)
+
+
+ # getVocabulary method is no longer supported
+ # def getVocabulary(self):
+ # """ more ack! """
+ # return getattr(self, self.vocab_id)
def manage_edit(self, RESPONSE, URL1, threshold=1000, REQUEST=None):