Skip to content

Commit

Permalink
- Merge tseaver-strexp_delenda-branch to the head.
Browse files Browse the repository at this point in the history
  • Loading branch information
tseaver committed Nov 18, 2003
1 parent 1460ecd commit 3808572
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
17 changes: 9 additions & 8 deletions Catalog.py
Expand Up @@ -42,6 +42,9 @@ def safe_callable(ob):
return callable(ob)


class CatalogError(Exception):
pass

class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
""" An Object Catalog
Expand Down Expand Up @@ -182,10 +185,10 @@ def addColumn(self, name, default_value=None):
names = list(self.names)

if schema.has_key(name):
raise 'Column Exists', 'The column exists'
raise CatalogError, 'The column %s already exists' % name

if name[0] == '_':
raise 'Invalid Meta-Data Name', \
raise CatalogError, \
'Cannot cache fields beginning with "_"'

if not schema.has_key(name):
Expand Down Expand Up @@ -255,13 +258,13 @@ def addIndex(self, name, index_type):
"""

if self.indexes.has_key(name):
raise 'Index Exists', 'The index specified already exists'
raise CatalogError, 'The index %s already exists' % name

if name.startswith('_'):
raise 'Invalid Index Name', 'Cannot index fields beginning with "_"'
raise CatalogError, 'Cannot index fields beginning with "_"'

if not name:
raise 'Invalid Index Name', 'Name of index is empty'
raise CatalogError, 'Name of index is empty'

indexes = self.indexes

Expand All @@ -277,7 +280,7 @@ def delIndex(self, name):
""" deletes an index """

if not self.indexes.has_key(name):
raise 'No Index', 'The index specified does not exist'
raise CatalogError, 'The index %s does not exist' % name

indexes = self.indexes
del indexes[name]
Expand Down Expand Up @@ -754,8 +757,6 @@ def searchResults(self, REQUEST=None, used=None, _merge=1, **kw):
__call__ = searchResults


class CatalogError(Exception): pass

class CatalogSearchArgumentsMap:
"""Multimap catalog arguments coming simultaneously from keywords
and request.
Expand Down
4 changes: 3 additions & 1 deletion regressiontests/regressionCatalogTiming.py
Expand Up @@ -217,7 +217,9 @@ def main():
f = h.getfile()
data = f.read()
print data
raise "Error reading from host %s" % server
class HTTPRequestError(Exception):
pass
raise HTTPRequestError, "Error reading from host %s" % server
f = h.getfile()
out=open(mb,'w')
print "this is going to take a while..."
Expand Down
8 changes: 2 additions & 6 deletions tests/testCatalog.py
Expand Up @@ -76,12 +76,8 @@ def testAdd(self):
'add column failed')

def testAddBad(self):
try:
self._catalog.addColumn('_id')
except:
pass
else:
raise 'invalid metadata column check failed'
from Products.ZCatalog.Catalog import CatalogError
self.assertRaises(CatalogError, self._catalog.addColumn, '_id')

def testDel(self):
self._catalog.addColumn('id')
Expand Down

0 comments on commit 3808572

Please sign in to comment.