[Zope-Checkins] CVS: Zope2 - ZCatalog.py:1.88.6.10 ZCatalogIndexes.py:1.1.2.11
Matthew T. Kromer
matt@digicool.com
Mon, 21 May 2001 16:23:51 -0400 (EDT)
Update of /cvs-repository/Zope2/lib/python/Products/ZCatalog
In directory korak.digicool.com:/tmp/cvs-serv3478/ZCatalog
Modified Files:
Tag: ajung-dropin-registry
ZCatalog.py ZCatalogIndexes.py
Log Message:
ZCatalogIndexes is a dumb object now based on the ZCatalog
--- Updated File ZCatalog.py in package Zope2 --
--- ZCatalog.py 2001/05/21 18:49:13 1.88.6.9
+++ ZCatalog.py 2001/05/21 20:23:50 1.88.6.10
@@ -218,7 +218,7 @@
manage_objectInformation = DTMLFile('dtml/catalogObjectInformation',
globals())
- #Indexes = ZCatalogIndexes()
+ Indexes = ZCatalogIndexes()
threshold=10000
_v_total=0
@@ -250,9 +250,6 @@
#indexes = ZCatalogIndexes('Indexes',vocabulary=self.vocab_id,caller=self)
indexes = self._indexes
- self.Indexes = ZCatalogIndexes('Indexes',vocabulary=self.vocab_id,
- caller=self, indexes=indexes)
-
#self._setObject('Indexes', indexes)
self._catalog.replaceIndexes(indexes)
@@ -398,7 +395,7 @@
def manage_addColumn(self, name, REQUEST=None, RESPONSE=None, URL1=None):
""" add a column """
- self._catalog.addColumn(name)
+ self.addColumn(name)
if REQUEST and RESPONSE:
RESPONSE.redirect(URL1 + '/manage_catalogSchema?manage_tabs_message=Column%20Added')
@@ -406,25 +403,25 @@
def manage_delColumns(self, names, REQUEST=None, RESPONSE=None, URL1=None):
""" del a column """
for name in names:
- self._catalog.delColumn(name)
+ self.delColumn(name)
if REQUEST and RESPONSE:
RESPONSE.redirect(URL1 + '/manage_catalogSchema?manage_tabs_message=Column%20Deleted')
def manage_addIndex(self, name, type, REQUEST=None, RESPONSE=None, URL1=None):
""" add an index """
- self._catalog.addIndex(name, type)
-
+ self.addIndex(name, type)
+
if REQUEST and RESPONSE:
- RESPONSE.redirect(URL1 + '/manage_catalogIndexes?manage_tabs_message=Index%20Added')
+ RESPONSE.redirect(URL1 + '/manage_main?manage_tabs_message=Index%20Added')
def manage_delIndexes(self, names, REQUEST=None, RESPONSE=None, URL1=None):
""" del an index """
for name in names:
- self._catalog.delIndex(name)
+ self.delIndex(name)
if REQUEST and RESPONSE:
- RESPONSE.redirect(URL1 + '/manage_catalogIndexes?manage_tabs_message=Index%20Deleted')
+ RESPONSE.redirect(URL1 + '/manage_main?manage_tabs_message=Index%20Deleted')
def reindexIndex(self,name,REQUEST):
@@ -793,6 +790,7 @@
index = base(name, self)
self._indexes[name] = index
+ self._p_changed = 1
def delIndex(self, name ):
@@ -800,6 +798,7 @@
# Lame.....this needs to be fixed
del self._indexes[name]
+ self._p_changed = 1
def clearIndex(self, name ):
--- Updated File ZCatalogIndexes.py in package Zope2 --
--- ZCatalogIndexes.py 2001/05/21 18:22:18 1.1.2.10
+++ ZCatalogIndexes.py 2001/05/21 20:23:50 1.1.2.11
@@ -105,9 +105,6 @@
"""A mapping object, responding to getattr requests by looking up
the requested indexes in an object manager."""
- # Bleah
- __supports_pluggable_indexes__ = 1
-
# The interfaces we want to show up in our object manager
_product_interfaces = (PluggableIndexInterface, )
@@ -139,220 +136,57 @@
)
)
- def __init__(self, name="Indexes", vocabulary=None,caller=None,
- indexes=None):
-
- self.id = name
- if indexes is None:
- self._indexes = {}
- else:
- self._indexes = indexes
- self._vocab_id = vocabulary
- self.caller = caller
-
- #
- # Dictionary methods; they pretend the object manager is a dictionary
- #
-
- def __len__(self):
- print "ZCatalogIndexes: __len__"
- return len(self._indexes)
-
- def __getitem__(self, name):
- print "ZCatalogIndexes: __getitem__(%s)" % (name)
- if self._indexes.has_key(name): return self._indexes[name]
- if hasattr(self,name): return getattr(self, name)
- raise KeyError,"%s not in ZCatalogIndexes" % name
-
- def __setitem__(self, name, value):
- print "ZCatalogIndexes: __setitem__(%s, %s)" % (name, value)
- self._indexes[name] = value
- self._p_changed = 1
-
- def __delitem__(self, name):
- print "ZCatalogIndexes: __delitem__(%s)" % name
- del self._indexes[name]
- self._p_changed = 1
-
- def keys(self):
- print "ZCatalogIndexes: keys()"
- return self._indexes.keys()
-
- def values(self):
- print "ZCatalogIndexes: values()"
- return self._indexes.values()
-
- def items(self):
- print "ZCatalogIndexes: items()"
- return self._indexes.items()
-
- def has_key(self, name):
- print "ZCatalogIndexes: has_key(%s)" % name
- return self._indexes.has_key(name)
-
- def get(self, name, default=_marker):
- print "ZCatalogIndexes: get(%s,%s)" % (name, default)
- if default is _marker: return self._indexes.get(name)
- return self._indexes.get(name, default)
-
- def clear(self):
- print "ZCatalogIndexes: clear()"
- raise NotImplementedError, "clear is not meaningful on a ZCatalogIndex"
-
- def copy(self):
- print "ZCatalogIndexes: copy()"
- raise NotImplementedError, "copy is not meaningful on a ZCatalogIndex"
-
- def update(self, list):
- print "ZCatalogIndexes: update(%s)" % list
- raise NotImplementedError, "update is not meaningful on a ZCatalogIndex"
-
- #
- # Catalog methods
#
-
- def addIndex(self, caller, name, type):
- print "Add index %s, type %s" % (name, type)
-
- # Convert the type by finding an appropriate product which supports
- # this interface by that name. Bleah
-
- products = self.all_meta_types() # It knows our desired interfaces
-
- p = None
-
- for prod in products:
- if prod['name'] == type:
- p = prod
- break
-
- if p is None:
- raise ValueError, "Index of type %s not found" % type
-
- base = p['instance']
-
- if base is None:
- raise ValueError, "Index type %s does not support addIndex" % type
-
- index = base(name, caller)
-
- self[name] = index
-
-
- def delIndex(self, name ):
- print "del index %s" % (name)
-
- # Lame.....this needs to be fixed
- del self._indexes[name]
-
-
- def clearIndex(self, name ):
- print "clear index %s" % (name)
-
- # Lame.....this needs to be fixed
- self._indexes[name].clear()
-
-
- #
# Object Manager methods
#
# base accessors loop back through our dictionary interface
- def _setOb(self, id, object): self[id] = object
- def _delOb(self, id): del self[id]
+ def _setOb(self, id, object):
+ indexes = self.aq_parent._indexes
+ indexes[id] = object
+ self.aq_parent._indexes = indexes
+ #self.aq_parent._p_changed = 1
+
+ def _delOb(self, id):
+ indexes = self.aq_parent._indexes
+ del indexes[id]
+ self.aq_parent._indexes = indexes
+ #self.aq_parent._p_changed = 1
+
def _getOb(self, id, default=_marker):
- if default is _marker: return self.get(id)
- return self.get(id, default)
+ indexes = self.aq_parent._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
if spec is not None:
if type(spec) == type('s'):
spec = [spec]
set = []
- for ob in self.keys():
- o = self.get(ob)
+ for ob in indexes.keys():
+ o = indexes.get(ob)
if hasattr(o, 'meta_type') and getattr(o,'meta_type') in spec:
set.append(ob)
return set
-
- return self.keys()
-
- def manage_addIndex(self, id, type, REQUEST=None):
- """ add a new index """
-
- id = str(id)
- type = str(type)
-
- print "manage_addIndex: self is %s" % self
-
- # addIndex wants to have the base catalog available to it
- # We'll pass self for now since there isnt a better sol'n
- self.addIndex(self, id, type)
- if REQUEST is not None:
- return self.manage_main(self, REQUEST)
-
-
- def manage_deleteIndex(self, ids, REQUEST=None):
- """ removed indexes from ZCatalog """
-
- print ids
-
- for id in ids:
- print "manage_deleteIndex: self is %s" % id
-
- self.delIndex(id)
-
- if REQUEST is not None:
- return self.manage_main(self, REQUEST)
-
- def manage_clearIndex(self, ids, REQUEST=None):
- """ clear indexes from ZCatalog """
-
- print ids
-
- for id in ids:
- print "manage_clearIndex: self is %s" % id
- self.clearIndex(id)
-
- if REQUEST is not None:
- return self.manage_main(self, REQUEST)
-
- def manage_reindexIndex(self, ids, REQUEST=None):
- """ reindex indexes from ZCatalog """
-
- print ids
-
- for id in ids:
- print "manage_reindexIndex: self is %s" % id
- self.caller.reindexIndex(id,REQUEST)
-
- if REQUEST is not None:
- return self.manage_main(self, REQUEST)
-
-
- def convert_index(self,name,REQUEST=None,RESPONSE=None):
- """ convert an old-style catalog index to a pluggable index """
- print 'convert index',name
-
-
- return "converted"
-# if REQUEST is not None:
-# return self.manage_main(self, REQUEST)
-
+ return indexes.keys()
+ # Eat _setObject calls
+ def _setObject(self, id, object, roles=None, user=None, set_owner=1):
+ pass
#
# traversal
#
def __bobo_traverse__(self, REQUEST, name):
- print "__bobo_traverse__ %s" % name
+ indexes = self.aq_parent._indexes;
- o = self.get(name, None)
+ o = indexes.get(name, None)
if o is not None: return o.__of__(self)
return getattr(self, name)