Skip to content

Commit

Permalink
Removed raise of abstend id bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Michel Pelletier committed Jan 17, 2000
1 parent cfbf5f0 commit f503c31
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions Catalog.py
Expand Up @@ -85,6 +85,7 @@

from Persistence import Persistent
import Acquisition
import ExtensionClass
import BTree, OIBTree, IOBTree, IIBTree
IIBucket=IIBTree.Bucket
from intSet import intSet
Expand Down Expand Up @@ -126,7 +127,7 @@ def orify(seq,
return apply(Query.Or,tuple(subqueries))


class Catalog(Persistent, Acquisition.Implicit):
class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
""" An Object Catalog
An Object Catalog maintains a table of object metadata, and a
Expand All @@ -141,7 +142,7 @@ class Catalog(Persistent, Acquisition.Implicit):
_v_brains = NoBrainer
_v_result_class = NoBrainer

def __init__(self, brains=None):
def __init__(self, vocabulary=None, brains=None):

self.schema = {} # mapping from attribute name to column number
self.names = () # sequence of column names
Expand All @@ -163,7 +164,12 @@ def __init__(self, brains=None):
# 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.
self.lexicon = Lexicon()

if type(vocabulary) is type(''):
self.lexicon = vocabulary
else:
#ack!
self.lexicon = Lexicon()

if brains is not None:
self._v_brains = brains
Expand Down Expand Up @@ -352,6 +358,10 @@ def catalogObject(self, object, uid, threshold=None):

total = 0
for x in self.indexes.values():
## tricky! indexes need to acquire now, and because they
## are in a standard dict __getattr__ isn't used, so
## acquisition doesn't kick in, we must explicitly wrap!
x = x.__of__(self)
if hasattr(x, 'index_object'):
blah = x.index_object(i, object, threshold)
total = total + blah
Expand All @@ -369,12 +379,10 @@ def uncatalogObject(self, uid):
catalogued, otherwise it will not get removed from the catalog
"""
if uid not in self.uids.keys():
raise ValueError, "Uncatalog of absent id %s" % `uid`

rid = self.uids[uid]

for x in self.indexes.values():
x = x.__of__(self)
if hasattr(x, 'unindex_object'):
try:
x.unindex_object(rid)
Expand Down Expand Up @@ -452,7 +460,7 @@ def _indexedSearch(self, args, sort_index, append, used,
if used is None: used={}
for i in self.indexes.keys():
try:
index = self.indexes[i]
index = self.indexes[i].__of__(self)
if hasattr(index,'_apply_index'):
r=index._apply_index(args)
if r is not None:
Expand Down

0 comments on commit f503c31

Please sign in to comment.