Commit a93df48e authored by Christopher Petrilli's avatar Christopher Petrilli

Merge of lexicon cleanup and text index merge along with some misc stuff.

parent 41eb6fe8
......@@ -101,6 +101,7 @@ from zLOG import LOG, ERROR
from Lazy import LazyMap, LazyFilter, LazyCat
from CatalogBrains import AbstractCatalogBrain, NoBrainer
import time
class KWMultiMapping(MultiMapping):
def has_key(self, name):
try:
......@@ -347,18 +348,30 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
data = self.data
if self.uids.has_key(uid):
i = self.uids[uid]
index = self.uids[uid]
elif data:
i = data.keys()[-1] + 1 # find the next available unique id
index = data.keys()[-1] + 1 # find the next available unique id
self.uids[uid] = index
self.paths[index] = uid
else:
i = 0
index = 0
self.uids[uid] = index
self.paths[index] = uid
self.uids[uid] = i
self.paths[i] = uid
# meta_data is stored as a tuple for efficiency
data[i] = self.recordify(object)
newDataRecord = self.recordify(object)
oldDataRecord = data.get(index, None)
# Now we need to compare the tuples before we update them!
if oldDataRecord is not None:
for i in range(len(newDataRecord)):
if newDataRecord[i] != oldDataRecord[i]:
data[index] = newDataRecord
break
else:
data[index] = newDataRecord
total = 0
for x in self.indexes.values():
## tricky! indexes need to acquire now, and because they
......@@ -366,7 +379,7 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
## 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)
blah = x.index_object(index, object, threshold)
total = total + blah
else:
LOG('Catalog', ERROR, ('catalogObject was passed '
......@@ -480,11 +493,6 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
handling intSets and IIBuckets.
"""
## import pdb
## pdb.set_trace()
## I use this so much I'm just leaving it commented out -michel
rs=None
data=self.data
......@@ -570,8 +578,6 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
type(''): Query.String,
}, **kw):
# Get search arguments:
if REQUEST is None and not kw:
try: REQUEST=self.REQUEST
......@@ -605,7 +611,8 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
# Perform searches with indexes and sort_index
r=[]
used=self._indexedSearch(kw, sort_index, r.append, used)
if not r: return LazyCat(r)
if not r:
return LazyCat(r)
# Sort/merge sub-results
if len(r)==1:
......
......@@ -318,8 +318,11 @@ class ZCatalog(Folder, Persistent, Implicit):
elapse = time.time() - elapse
c_elapse = time.clock() - c_elapse
RESPONSE.redirect(URL1 + '/manage_catalogView?manage_tabs_message=' +
urllib.quote('Catalog Updated<br>Total time: %s<br>Total CPU time: %s' % (`elapse`, `c_elapse`)))
RESPONSE.redirect(URL1 +
'/manage_catalogAdvanced?manage_tabs_message=' +
urllib.quote('Catalog Updated<br>'
'Total time: %s<br>'
'Total CPU time: %s' % (`elapse`, `c_elapse`)))
def manage_catalogClear(self, REQUEST=None, RESPONSE=None, URL1=None):
......@@ -327,7 +330,7 @@ class ZCatalog(Folder, Persistent, Implicit):
self._catalog.clear()
if REQUEST and RESPONSE:
RESPONSE.redirect(URL1 + '/manage_catalogView?manage_tabs_message=Catalog%20Cleared')
RESPONSE.redirect(URL1 + '/manage_catalogAdvanced?manage_tabs_message=Catalog%20Cleared')
def manage_catalogFoundItems(self, REQUEST, RESPONSE, URL2, URL1,
......
......@@ -98,7 +98,9 @@
<dtml-if threshold>
<tr>
<td align="left" valign="top">
<p class="form-help">The Subtransaction threshold is the number of words the catalog
<p class="form-help">The Subtransaction threshold is the number of
objects cataloged
in the context of a single transaction that the catalog
will index before it commits a subtransaction. If this number
is low, the Catalog will take longer to index but consume less
memory. If this number is higher, the Catalog will index
......
......@@ -9,48 +9,58 @@
word(s).
</p>
<dtml-in words previous size=20 start=query_start >
<div class="list-nav">
<a href="<dtml-var URL>?query_start=<dtml-var previous-sequence-start-number>">
[Previous <dtml-var previous-sequence-size> entries]
</a>
</div>
</dtml-in>
<dtml-in words next size=20 start=query_start >
<div class="list-nav">
<a href="<dtml-var URL>?query_start=<dtml-var next-sequence-start-number>">
[Next <dtml-var next-sequence-size> entries]
</a>
</div>
</dtml-in>
<table>
<dtml-in words size=20 start=query_start >
<tr valign=top>
<td valign="top" align="left">
<div class="form-text">
<dtml-var sequence-item> (<dtml-var sequence-key>)
</div>
</td>
</tr>
</dtml-in>
</table>
<dtml-in words previous size=20 start=query_start >
<div class="list-nav">
<a href="<dtml-var URL>?query_start=<dtml-var previous-sequence-start-number>">
[Previous <dtml-var previous-sequence-size> entries]
</a>
</div>
</dtml-in>
<dtml-in words next size=20 start=query_start >
<div class="list-nav">
<a href="<dtml-var URL>?query_start=<dtml-var next-sequence-start-number>">
[Next <dtml-var next-sequence-size> entries]
</a>
</div>
<dtml-in words previous size=20 start=query_start >
<span class="list-nav">
<a href="<dtml-var URL>?query_start=<dtml-var previous-sequence-start-number>">
[Previous <dtml-var previous-sequence-size> entries]
</a>
</span>
</dtml-in>
<dtml-in words next size=20 start=query_start >
<span class="list-nav">
<a href="<dtml-var URL>?query_start=<dtml-var next-sequence-start-number>">
[Next <dtml-var next-sequence-size> entries]
</a>
</span>
</dtml-in>
<table width="100%" cellspacing="0" cellpadding="2" border="0">
<dtml-in words size=20 start=query_start >
<dtml-if name="sequence-start">
<tr class="list-header">
<td width="80%" align="left" valign="top">
<div class="list-item">Word</div></td>
<td width="20%" align="left" valign="top">
<div class="list-item">Word ID</div></td>
</tr>
</dtml-if>
<dtml-if name="sequence-odd"><tr class="row-normal">
<dtml-else><tr class="row-hilite"></dtml-if>
<td valign="top" align="left">
<div class="form-text">&dtml-sequence-key;</div>
</td>
<td valign="top" align="left">
<div class="form-text">&dtml-sequence-item;</div>
</td>
</tr>
</dtml-in>
</table>
<dtml-in words previous size=20 start=query_start >
<div class="list-nav">
<a href="<dtml-var URL>?query_start=<dtml-var previous-sequence-start-number>">
[Previous <dtml-var previous-sequence-size> entries]
</a>
</div>
</dtml-in>
<dtml-in words next size=20 start=query_start >
<div class="list-nav">
<a href="<dtml-var URL>?query_start=<dtml-var next-sequence-start-number>">
[Next <dtml-var next-sequence-size> entries]
</a>
</div>
</dtml-in>
<dtml-else>
......
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