Commit 20890ca4 authored by Steve Alexander's avatar Steve Alexander

Merge ZCatalog API cleanup into trunk.

parent 5ceff2c4
......@@ -198,9 +198,13 @@ class ZCatalog(Folder, Persistent, Implicit):
'manage_catalogAdvanced', 'manage_objectInformation',
'manage_catalogReindex', 'manage_catalogFoundItems',
'manage_catalogClear', 'manage_addColumn', 'manage_delColumns',
'manage_addIndex', 'manage_delIndexes', 'manage_main',
'availableSplitters'],
'manage_catalogClear', 'manage_addColumn', 'manage_delColumn',
'manage_addIndex', 'manage_delIndex', 'manage_clearIndex',
'manage_reindexIndex', 'manage_main', 'availableSplitters',
# these two are deprecated:
'manage_delColumns', 'manage_deleteIndex'
],
['Manager']),
('Search ZCatalog',
......@@ -294,10 +298,12 @@ class ZCatalog(Folder, Persistent, Implicit):
RESPONSE.redirect(URL1 + '/manage_catalogAdvanced?manage_tabs_message=Catalog%20Changed')
def manage_catalogObject(self, REQUEST, RESPONSE, URL1, urls=None):
""" index all Zope objects that 'urls' point to """
""" index Zope object(s) that 'urls' point to """
if urls:
if isinstance(urls, types.StringType):
urls=(urls,)
for url in urls:
obj = self.resolve_path(url)
if not obj:
......@@ -309,9 +315,12 @@ class ZCatalog(Folder, Persistent, Implicit):
def manage_uncatalogObject(self, REQUEST, RESPONSE, URL1, urls=None):
""" removes Zope object 'urls' from catalog """
""" removes Zope object(s) 'urls' from catalog """
if urls:
if isinstance(urls, types.StringType):
urls=(urls,)
for url in urls:
self.uncatalog_object(url)
......@@ -406,14 +415,33 @@ class ZCatalog(Folder, Persistent, Implicit):
if REQUEST and RESPONSE:
RESPONSE.redirect(URL1 + '/manage_catalogSchema?manage_tabs_message=Column%20Added')
def manage_delColumns(self, names, REQUEST=None, RESPONSE=None, URL1=None):
""" del a column """
""" Deprecated method. Use manage_delColumn instead. """
# log a deprecation warning
import warnings
warnings.warn("The manage_delColumns method of ZCatalog is deprecated"\
"since Zope 2.4.2.\n"\
"This method is only kept for backwards compatibility for a while\n"\
"and will go away in a future release.\n"\
"\n"\
"Please use instead the manage_delColumn method.\n"\
,DeprecationWarning)
self.manage_delColumn(names, REQUEST=REQUEST, RESPONSE=RESPONSE, URL1=URL1)
def manage_delColumn(self, names, REQUEST=None, RESPONSE=None, URL1=None):
""" delete a column or some columns """
if isinstance(names, types.StringType):
names = (names,)
for name in names:
self.delColumn(name)
if REQUEST and RESPONSE:
RESPONSE.redirect(URL1 + '/manage_catalogSchema?manage_tabs_message=Column%20Deleted')
def manage_addIndex(self, name, type, extra=None,REQUEST=None, RESPONSE=None, URL1=None):
""" add an index """
self.addIndex(name, type,extra)
......@@ -424,26 +452,48 @@ class ZCatalog(Folder, Persistent, Implicit):
def manage_deleteIndex(self, ids=None, REQUEST=None, RESPONSE=None,
URL1=None):
""" del an index """
""" Deprecated method. Use manage_delIndex instead. """
# log a deprecation warning
import warnings
warnings.warn("The manage_deleteIndex method of ZCatalog is deprecated"\
"since Zope 2.4.2.\n"\
"This method is only kept for backwards compatibility for a while\n"\
"and will go away in a future release.\n"\
"\n"\
"Please use instead the manage_delIndex method.\n"\
,DeprecationWarning)
self.manage_delIndex(ids=ids, REQUEST=REQUEST, RESPONSE=RESPONSE, URL1=URL1)
def manage_delIndex(self, ids=None, REQUEST=None, RESPONSE=None,
URL1=None):
""" delete an index or some indexes """
if not ids:
return MessageDialog(title='No items specified',
message='No items were specified!',
action = "./manage_main",)
if isinstance(ids, types.StringType):
ids = (ids,)
for name in ids:
self.delIndex(name)
if REQUEST and RESPONSE:
RESPONSE.redirect(URL1 + '/manage_main?manage_tabs_message=Index%20Deleted')
def manage_clearIndex(self, ids=None, REQUEST=None, RESPONSE=None,
URL1=None):
""" del an index """
""" clear an index or some indexes """
if not ids:
return MessageDialog(title='No items specified',
message='No items were specified!',
action = "./manage_main",)
if isinstance(ids, types.StringType):
ids = (ids,)
for name in ids:
self.clearIndex(name)
......@@ -462,15 +512,19 @@ class ZCatalog(Folder, Persistent, Implicit):
if obj is not None:
self.catalog_object(obj, p, idxs=[name])
def manage_reindexIndex(self, ids=None, REQUEST=None, RESPONSE=None, URL1=None):
""" Reindex indexes from a ZCatalog"""
""" Reindex indexe(s) from a ZCatalog"""
if not ids:
return MessageDialog(title='No items specified',
message='No items were specified!',
action = "./manage_main",)
if isinstance(ids, types.StringType):
ids = (ids,)
for id in ids:
self.reindexIndex(id, REQUEST)
for name in ids:
self.reindexIndex(name, REQUEST)
if REQUEST and RESPONSE:
RESPONSE.redirect(URL1 + '/manage_main?manage_tabs_message=Reindexing%20Performed')
......
......@@ -42,7 +42,7 @@ that have one or more keywords specified in a search query.
<dtml-if name="sequence-odd"><tr class="row-normal">
<dtml-else><tr class="row-hilite"></dtml-if>
<td align="right" valign="top">
<input type="checkbox" name="names:list" value="<dtml-var
<input type="checkbox" name="ids:list" value="<dtml-var
id html_quote>" />
</td>
<td width="60%" align="left" valign="top">
......@@ -61,7 +61,7 @@ that have one or more keywords specified in a search query.
</td>
<td align="left" valign="top">
<div class="form-element">
<input class="form-element" type="submit" name="manage_delIndexes:method"
<input class="form-element" type="submit" name="manage_delIndex:method"
value="Delete" />
</div>
</td>
......
......@@ -184,11 +184,8 @@ function toggleSelect() {
<td>
<div class="list-item">
<dtml-try>
<dtml-var numObjects missing="not available">
<dtml-except>n/a
</dtml-try>
</div>
<dtml-var numObjects missing="n/a">
</div>
</td>
<td>
......@@ -209,7 +206,7 @@ function toggleSelect() {
<td align="left" valign="top">
<div class="form-element">
<input class="form-element" type="submit" name="manage_deleteIndex:method" value="Remove index">
<input class="form-element" type="submit" name="manage_delIndex:method" value="Remove index">
<input class="form-element" type="submit" name="manage_reindexIndex:method" value="Reindex">
<input class="form-element" type="submit" name="manage_clearIndex:method" value="Clear index">
......
......@@ -44,7 +44,7 @@ class TestTimeIndex(TestCase):
self.app.catalogtest._setObject('catalog', zcatalog)
c = self.app.catalogtest.catalog
for x in ('title', 'to', 'from', 'date', 'raw'):
try: c.manage_delIndexes([x])
try: c.manage_delIndex([x])
except: pass
c.manage_addIndex('title', 'TextIndex')
c.manage_addIndex('to', 'TextIndex')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment