Skip to content

Commit

Permalink
Merge in of some changes to the Catalog, mostly things that are appea…
Browse files Browse the repository at this point in the history
…rance

driven.
  • Loading branch information
petrilli committed Jan 15, 2001
1 parent ba02c26 commit 693664e
Show file tree
Hide file tree
Showing 11 changed files with 265 additions and 95 deletions.
2 changes: 1 addition & 1 deletion Catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ def searchResults(self, REQUEST=None, used=None,
# Perform searches with indexes and sort_index
r=[]
used=self._indexedSearch(kw, sort_index, r.append, used)
if not r: return r
if not r: return LazyCat(r)

# Sort/merge sub-results
if len(r)==1:
Expand Down
32 changes: 30 additions & 2 deletions Lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
# attributions are listed in the accompanying credits file.
#
##############################################################################
__doc__='''$Id: Lazy.py,v 1.2 2000/05/11 18:54:16 jim Exp $'''
__version__='$Revision: 1.2 $'[11:-2]
__doc__='''$Id: Lazy.py,v 1.3 2001/01/15 16:29:23 petrilli Exp $'''
__version__='$Revision: 1.3 $'[11:-2]


class Lazy:
Expand All @@ -107,6 +107,34 @@ def __len__(self):
self._len=l
return l

def __add__(self, other):
try:
for base in other.__class__.__bases__:
if base.__name__ == 'Lazy':
break
else:
raise TypeError
except:
raise TypeError, "Can not concatenate objects. Both must be lazy sequences."

if self.__class__.__name__ == 'LazyCat':
if hasattr(self, '_seq'):
seq = self._seq
else:
seq = [self._data]
else:
seq = [self]

if other.__class__.__name__ == 'LazyCat':
if hasattr(other, '_seq'):
seq = seq + other._seq
else:
seq.append(other._data)
else:
seq.append(other)

return LazyCat(seq)

def __getslice__(self,i1,i2):
r=[]
for i in range(i1,i2):
Expand Down
16 changes: 8 additions & 8 deletions ZCatalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,14 @@ class is that it is not Zope specific. You can use it in any
'action': 'manage_catalogSchema',
'target':'manage_main',
'help':('ZCatalog','ZCatalog_MetaData-Table.stx')},
{'label': 'Status', # TAB: Status
'action': 'manage_catalogStatus',
'target':'manage_main',
'help':('ZCatalog','ZCatalog_Status.stx')},
{'label': 'Find Objects', # TAB: Find Objects
'action': 'manage_catalogFind',
'target':'manage_main',
'help':('ZCatalog','ZCatalog_Find-Items-to-ZCatalog.stx')},
{'label': 'Advanced', # TAB: Advanced
'action': 'manage_catalogAdvanced',
'target':'manage_main',
'help':('ZCatalog','ZCatalog_Advanced.stx')},
{'label': 'Undo', # TAB: Undo
'action': 'manage_UndoForm',
'help': ('OFSP','Undo.stx')},
Expand All @@ -190,7 +190,7 @@ class is that it is not Zope specific. You can use it in any

'manage_catalogView', 'manage_catalogFind',
'manage_catalogSchema', 'manage_catalogIndexes',
'manage_catalogStatus',
'manage_catalogAdvanced',

'manage_catalogReindex', 'manage_catalogFoundItems',
'manage_catalogClear', 'manage_addColumn', 'manage_delColumns',
Expand All @@ -211,7 +211,7 @@ class is that it is not Zope specific. You can use it in any
manage_catalogFind = DTMLFile('dtml/catalogFind',globals())
manage_catalogSchema = DTMLFile('dtml/catalogSchema', globals())
manage_catalogIndexes = DTMLFile('dtml/catalogIndexes', globals())
manage_catalogStatus = DTMLFile('dtml/catalogStatus', globals())
manage_catalogAdvanced = DTMLFile('dtml/catalogAdvanced', globals())


threshold=10000
Expand Down Expand Up @@ -271,7 +271,7 @@ def manage_subbingToggle(self, REQUEST, RESPONSE, URL1):
else:
self.threshold = 10000

RESPONSE.redirect(URL1 + '/manage_catalogStatus?manage_tabs_message=Catalog%20Changed')
RESPONSE.redirect(URL1 + '/manage_catalogAdvanced?manage_tabs_message=Catalog%20Changed')


def manage_catalogObject(self, REQUEST, RESPONSE, URL1, urls=None):
Expand Down Expand Up @@ -445,7 +445,7 @@ def index_objects(self):
def _searchable_arguments(self):
r = {}
n={'optional':1}
for name in self._catalog.schema.keys():
for name in self._catalog.indexes.keys():
r[name]=n
return r

Expand Down
124 changes: 124 additions & 0 deletions dtml/catalogAdvanced.dtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<dtml-var manage_page_header>
<dtml-var manage_tabs>

<br />
<table width="100%" cellspacing="0" cellpadding="2" border="0">
<tr class="section-bar">
<td colspan="2" align="left">
<div class="form-label">
Catalog Maintenance
</div>
</td>
</tr>
<tr>
<td align="left" valign="top">
<p class="form-help"> Updating the catalog will update all catalog
records and remove invalid records. It does this by deleting all
indexes and re-cataloging all currently indexed objects.
</p>
</td>
<td align="right" valign="top">
<form action="<dtml-var URL1>">
<input class="form-element" type="submit"
name="manage_catalogReindex:method" value=" Update Catalog ">
</form>
</td>
</tr>
<tr>
<td align="left" valign="top">
<p class="form-help">Clearing the catalog will remove all entries.
</p>
</td>
<td align="right" valign="top">
<form action="<dtml-var URL1>">
<input class="form-element" type="submit"
name="manage_catalogClear:method" value=" Clear Catalog ">
</form>
</td>
</tr>
<tr>
<td>

</td>
</tr>
<tr class="section-bar">
<td colspan="2" align="left">
<div class="form-label">
Subtransactions
</div>
</td>
</tr>
<tr>
<td colspan="2" align="left" valign="top">

<p class="form-help"> Subtransactions allow Zope to commit small
parts of a transaction over a period of time instead of all at
once. For ZCatalog, this means using subtransactions can
signficantly reduce the memory requirements needed to index huge
amounts of text all at once. Currently, subtransactions are only
applied to text indexes.</p>

<p class="form-help"> If enabled, subtransactions will reduce the memory
requirements of ZCatalog, but <em>at the expense of speed</em>.
If you choose to enable subtransactions, you can adjust how often
ZCatalog commits a subtransactions by adjusting the
<em>threshold</em> below.</p>

<p class="form-help"> If you are using ZCatalog and ZSQL Methods
in the same transaction, you <em>must</em> disable
subtransactions, they are not compatible with ZSQL Methods.</p>
<br />
</td>
</tr>
<tr>
<td align="left" valign="top">
<p>Subtransactions are
<dtml-if threshold>
<font color="green"><b>Enabled</b></font>
<dtml-else>
<font color="red"><b>Disabled</b></font>
</dtml-if></p>
</td>
<td align="right" valign="top">
<form action="<dtml-var URL1>" method="POST">
<div class="form-element">
<dtml-if threshold>
<input class="form-element" type="submit"
name="manage_subbingToggle:method"
value="Disable" />
<dtml-else>
<input class="form-element" type="submit"
name="manage_subbingToggle:method"
value="Enable" />
</dtml-if>
</div>
</form>
</td>
</tr>
<dtml-if threshold>
<tr>
<td align="left" valign="top">
<p class="form-help">The Subtransaction threshold is the number of words 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
quickly but consume much more memory.</p>
</td>
<td align="right" valign="top">
<form action="manage_edit" method=POST>
<div class="form-element">
<input name="threshold:int" value="<dtml-var
threshold html_quote>" />
<input type="submit" name="submit" value="Set Threshold">
</div>
</form>
</dtml-if>
</td>
</tr>
</table>
<dtml-var manage_page_footer>





31 changes: 24 additions & 7 deletions dtml/catalogIndexes.dtml
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,34 @@ that have one or more keywords specified in a search query.
</p>

<form action="<dtml-var URL1>" method="post">
<table cellspacing="0" cellpadding="2" border="0">
<dtml-in index_objects sort=id>
<tr>
<td align="left" valign="top">
<dtml-if name="sequence-start">
<table width="100%" cellspacing="0" cellpadding="2" border="0">
<tr class="list-header">
<td width="1%" align="right" valign="top">&nbsp;</td>
<td width="64%" align="left" valign="top">
<div class="list-item">Index Name</div></td>
<td width="20%" align="right" valign="top">
<div class="list-item">Index Type</div></td>
<td width="15%" align="right" valign="top">
<div class="list-item">Objects Indexed</div></td>
</tr>
</dtml-if>
<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
id html_quote>" />
</td>
<td align="left" valign="top">
<div class="form-text">
<dtml-var id> (<em><dtml-var meta_type></em>)
</div>
<td width="60%" align="left" valign="top">
<div class="list-item">
<a href="">&dtml-id;</a></div></td>
<td width="20%" align="right" valign="top">
<div class="list-item">&dtml-meta_type;</div></td>
<td width="15%" align="right" valign="top">
<div class="list-item">
<dtml-var expr="_.len(_['sequence-item'])" thousands_commas>
</div>
</td>
</tr>
</dtml-in>
Expand Down
75 changes: 27 additions & 48 deletions dtml/catalogView.dtml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,13 @@

<dtml-if searchResults>

<p class="form-help">
Updating the catalog will update all catalog records and remove
invalid records. Clearing the catalog will remove all entries.
You can also remove or update individual catalog records.
</p>

<form action="<dtml-var URL1>">
<div class="form-element">
<input class="form-element" type="submit"
name="manage_catalogReindex:method" value=" Update Catalog ">
<input class="form-element" type="submit"
name="manage_catalogClear:method" value=" Clear Catalog ">
</form>
<form action="<dtml-var name="URL1">">

<p class="form-text">
<dtml-var id> contains <dtml-var
searchResults fmt=collection-length thousands_commas> record(s).
</p>

<div class="form-text">
<dtml-in searchResults previous size=20 start=query_start >
<a href="<dtml-var URL>?query_start=<dtml-var previous-sequence-start-number>">
[Previous <dtml-var previous-sequence-size> entries]
Expand All @@ -32,35 +20,39 @@ You can also remove or update individual catalog records.
[Next <dtml-var next-sequence-size> entries]
</a>
</dtml-in>

<form action="<dtml-var URL1>">
<input type="hidden" name="individual" value="1">

<div class="form-element">
<input class="form-element" type="submit" value=" Remove "
name="manage_uncatalogObject:method">
<input class="form-element" type="submit" value=" Update "
name="manage_catalogObject:method">
</div>

<table cellspacing="0" cellpadding="2" border="0">
</div>
<table width="100%" cellspacing="0" cellpadding="2" border="0">
<dtml-in searchResults size=20 start=query_start >
<tr>
<td align="left" valign="top">
<input type="checkbox" NAME="urls:list" VALUE="<dtml-var
"getpath(data_record_id_)" html_quote>">
<dtml-if name="sequence-start">
<tr class="list-header">
<td width="5%" align="right" colspan="2" valign="top">&nbsp;</td>
<td width="80%" align="left" valign="top">
<div class="list-item">Object Identifier</div></td>
<td width="15%" align="left" valign="top">
<div class="list-item">Type</div></td>
</tr>
</dtml-if>
<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="urls:list" VALUE="&dtml-getPath;">
</td>
<td align="left" valign="top">&nbsp;</td>
<td align="left" valign="top">
<div class="form-text">
<dtml-var meta_type>
<a href="<dtml-var
"getURL" url_quote>/manage_workspace">&dtml-getPath;</a>
</div>
</td>
<td align="left" valign="top">
<div class="form-text">
<a href="<dtml-var
"getpath(data_record_id_)" url_quote>/manage_workspace"><dtml-var
"getpath(data_record_id_)"><dtml-if title> (<dtml-var
title>)</dtml-if></a>
<dtml-with name="aq_self" only>
<dtml-if name="meta_type">
<dtml-var name="meta_type" size="15">
<dtml-else>
<i>Unknown</i>
</dtml-if>
</dtml-with>
</div>
</td>
</tr>
Expand All @@ -74,19 +66,6 @@ You can also remove or update individual catalog records.
name="manage_catalogObject:method">
</div>
</form>

<dtml-in searchResults previous size=20 start=query_start >
<a href="<dtml-var URL>?query_start=<dtml-var previous-sequence-start-number>">
[Previous <dtml-var previous-sequence-size> entries]
</a>
</dtml-in>

<dtml-in searchResults next size=20 start=query_start >
<a href="<dtml-var URL>?query_start=<dtml-var next-sequence-start-number>">
[Next <dtml-var next-sequence-size> entries]
</a>
</dtml-in>

<dtml-else>
<p class="form-text">
There are no objects in the Catalog.
Expand Down
4 changes: 3 additions & 1 deletion help/Vocabulary.stx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Vocabulary

Vocabularies display a list of all the unique words that are
indexed by a Catalog or Catalogs that use this Vocabulary object.
This view allows you to browse all of the words in the Vocabulary
This view allows you to browse all of the words in the Vocabulary.

Currently, Vocabularies are only used by TextIndexes.


Loading

0 comments on commit 693664e

Please sign in to comment.