Commit fcf6d870 authored by Christopher Petrilli's avatar Christopher Petrilli

Merge for debugging information.

parent 3579b3ab
...@@ -372,8 +372,6 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -372,8 +372,6 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
LOG('Catalog', ERROR, ('catalogObject was passed ' LOG('Catalog', ERROR, ('catalogObject was passed '
'bad index object %s.' % str(x))) 'bad index object %s.' % str(x)))
self.data = data
return total return total
def uncatalogObject(self, uid): def uncatalogObject(self, uid):
...@@ -453,12 +451,24 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base): ...@@ -453,12 +451,24 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
return tuple(record) return tuple(record)
def instantiate(self, record): def instantiate(self, record):
r=self._v_result_class(record[1]) r=self._v_result_class(record[1])
r.data_record_id_ = record[0] r.data_record_id_ = record[0]
return r.__of__(self) return r.__of__(self)
def getMetadataForRID(self, rid):
record = self.data[rid]
result = {}
for (key, pos) in self.schema.items():
result[key] = record[pos]
return result
def getIndexDataForRID(self, rid):
result = {}
for (id, index) in self.indexes.items():
result[id] = index.__of__(self).getEntryForObject(rid, "")
return result
## Searching engine. You don't really have to worry about what goes ## Searching engine. You don't really have to worry about what goes
## on below here... Most of this stuff came from ZTables with tweaks. ## on below here... Most of this stuff came from ZTables with tweaks.
......
...@@ -106,14 +106,22 @@ class AbstractCatalogBrain(Record.Record, Acquisition.Implicit): ...@@ -106,14 +106,22 @@ class AbstractCatalogBrain(Record.Record, Acquisition.Implicit):
except: except:
return self.getPath() return self.getPath()
def getObject(self): def getObject(self, REQUEST=None):
"""Try to return the object for this record""" """Try to return the object for this record"""
try: try:
return self.aq_parent.restrictedTraverse(self.getPath()) obj = self.aq_parent.restrictedTraverse(self.getPath())
if not obj:
if REQUEST is None:
REQUEST = self.REQUEST
obj = self.aq_parent.resolve_url(self.getPath(), REQUEST)
return obj
except: except:
pass pass
def getRID(self):
"""Return the record ID for this object."""
return self.data_record_id_
class NoBrainer: class NoBrainer:
""" This is an empty class to use when no brain is specified. """ """ This is an empty class to use when no brain is specified. """
pass pass
...@@ -190,7 +190,7 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -190,7 +190,7 @@ class ZCatalog(Folder, Persistent, Implicit):
'manage_catalogView', 'manage_catalogFind', 'manage_catalogView', 'manage_catalogFind',
'manage_catalogSchema', 'manage_catalogIndexes', 'manage_catalogSchema', 'manage_catalogIndexes',
'manage_catalogAdvanced', 'manage_catalogAdvanced', 'manage_objectInformation',
'manage_catalogReindex', 'manage_catalogFoundItems', 'manage_catalogReindex', 'manage_catalogFoundItems',
'manage_catalogClear', 'manage_addColumn', 'manage_delColumns', 'manage_catalogClear', 'manage_addColumn', 'manage_delColumns',
...@@ -212,7 +212,8 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -212,7 +212,8 @@ class ZCatalog(Folder, Persistent, Implicit):
manage_catalogSchema = DTMLFile('dtml/catalogSchema', globals()) manage_catalogSchema = DTMLFile('dtml/catalogSchema', globals())
manage_catalogIndexes = DTMLFile('dtml/catalogIndexes', globals()) manage_catalogIndexes = DTMLFile('dtml/catalogIndexes', globals())
manage_catalogAdvanced = DTMLFile('dtml/catalogAdvanced', globals()) manage_catalogAdvanced = DTMLFile('dtml/catalogAdvanced', globals())
manage_objectInformation = DTMLFile('dtml/catalogObjectInformation',
globals())
threshold=10000 threshold=10000
_v_total=0 _v_total=0
...@@ -397,7 +398,7 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -397,7 +398,7 @@ class ZCatalog(Folder, Persistent, Implicit):
if REQUEST and RESPONSE: if REQUEST and RESPONSE:
RESPONSE.redirect(URL1 + '/manage_catalogIndexes?manage_tabs_message=Index%20Deleted') RESPONSE.redirect(URL1 + '/manage_catalogIndexes?manage_tabs_message=Index%20Deleted')
def catalog_object(self, obj, uid): def catalog_object(self, obj, uid):
""" wrapper around catalog """ """ wrapper around catalog """
self._v_total = (self._v_total + self._v_total = (self._v_total +
...@@ -429,10 +430,24 @@ class ZCatalog(Folder, Persistent, Implicit): ...@@ -429,10 +430,24 @@ class ZCatalog(Folder, Persistent, Implicit):
""" """
Return a cataloged object given a 'data_record_id_' Return a cataloged object given a 'data_record_id_'
""" """
if REQUEST is None: try:
REQUEST=self.REQUEST obj = self.aq_parent.restrictedTraverse(self.getpath(rid))
return self.resolve_url(self.getpath(rid), REQUEST) if not obj:
if REQUEST is None:
REQUEST=self.REQUEST
obj = self.sq_parent.resolve_url(self.getpath(rid), REQUEST)
return obj
except:
pass
def getMetadataForRID(self, rid):
"""return the correct metadata for the cataloged record id"""
return self._catalog.getMetadataForRID(int(rid))
def getIndexDataForRID(self, rid):
"""return the current index contents for the specific rid"""
return self._catalog.getIndexDataForRID(rid)
def schema(self): def schema(self):
return self._catalog.schema.keys() return self._catalog.schema.keys()
......
...@@ -35,10 +35,10 @@ that have one or more keywords specified in a search query. ...@@ -35,10 +35,10 @@ that have one or more keywords specified in a search query.
<td width="1%" align="right" valign="top">&nbsp;</td> <td width="1%" align="right" valign="top">&nbsp;</td>
<td width="64%" align="left" valign="top"> <td width="64%" align="left" valign="top">
<div class="list-item">Index Name</div></td> <div class="list-item">Index Name</div></td>
<td width="20%" align="right" valign="top"> <td width="20%" align="left" valign="top">
<div class="list-item">Index Type</div></td> <div class="list-item">Index Type</div></td>
<td width="15%" align="right" valign="top"> <td width="15%" align="left" valign="top">
<div class="list-item">Objects Indexed</div></td> <div class="list-item">Size</div></td>
</tr> </tr>
</dtml-if> </dtml-if>
<dtml-if name="sequence-odd"><tr class="row-normal"> <dtml-if name="sequence-odd"><tr class="row-normal">
...@@ -49,12 +49,11 @@ that have one or more keywords specified in a search query. ...@@ -49,12 +49,11 @@ that have one or more keywords specified in a search query.
</td> </td>
<td width="60%" align="left" valign="top"> <td width="60%" align="left" valign="top">
<div class="list-item"> <div class="list-item">
<a href="">&dtml-id;</a></div></td> <a href="" target="_index_info_&dtml-id;">&dtml-id;</a></div></td>
<td width="20%" align="right" valign="top"> <td width="20%" align="left" valign="top">
<div class="list-item">&dtml-meta_type;</div></td> <div class="list-item">&dtml-meta_type;</div></td>
<td width="15%" align="right" valign="top"> <td width="15%" align="left" valign="top"><div class="list-item"
<div class="list-item"> ><dtml-var expr="_.len(_['sequence-item'])" thousands_commas>
<dtml-var expr="_.len(_['sequence-item'])" thousands_commas>
</div> </div>
</td> </td>
</tr> </tr>
......
<dtml-var manage_page_header>
<table width="100%" borders="0" cellspacing="2" cellpadding="0">
<tr bgcolor="#000000">
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr class="location-bar">
<td colspan="2" align="left">
<div class="std-text">
Object Information <dtml-var expr="getpath(_.int(rid))">
</div>
</td>
</tr>
<tr>
<td colspan="2" align="left">
<p class="form-help">
The goal of this page is to provide basic debugging information
about what is in the Catalog on a specific object. Listed below is
all the information that the Catalog currently contains for the
above specified object. This information should match what is
currently in the instance of that object.
</td>
</tr>
</table>
<br />
<table width="100%" borders="0" cellspacing="2" cellpadding="0">
<tr class="section-bar">
<td colspan="3" align="left">
<div class="form-label">Metadata Contents</div>
</td>
</tr>
<tr>
<td colspan="3" align="left">
<p class="form-help">Metadata is the information that the Catalog
keeps inside of its internal structure so that it can answer
questions quickly. This is then returned in the "brain" that the
Catalog gives back during searches.</p><br />
</td>
</tr>
<dtml-in expr="getMetadataForRID(_.int(rid)).items()">
<dtml-if name="sequence-start">
<tr class="list-header">
<td align="left" width="5%" bgcolor="#ffffff">&nbsp;</td>
<td align="left" width="25%" valign="top" class="list-item">Key</td>
<td align="left" width="70%" valign="top" class="list-item">Value</td>
</dtml-if>
<dtml-if name="sequence-odd"><tr class="row-hilite">
<dtml-else><tr></dtml-if>
<td width="32" bgcolor="#ffffff">&nbsp;</td>
<td align="left" valign="top" class="form-element">
&dtml-sequence-key;
</td>
<Td align="left" valign="top" class="form-element">
&dtml-sequence-item;
</td>
</tr>
</dtml-in>
</table>
<br />
<table width="100%" borders="0" cellspacing="2" cellpadding="0">
<tr class="section-bar">
<td colspan="3" align="left">
<div class="form-label">Index Contents</div>
</td>
</tr>
<tr>
<td colspan="3" align="left">
<p class="form-help">The following table gives information that is
contained in the various indexes of the Catalog. In the case of
Keyword or Text indexes, the results are returned as a tuple, and will
be shows a '(one, two, three)', rather than in a more normal way.</p><br />
</td>
</tr>
<dtml-in expr="getIndexDataForRID(_.int(rid)).items()">
<dtml-if name="sequence-start">
<tr class="list-header">
<td align="left" width="5%" bgcolor="#ffffff">&nbsp;</td>
<td align="left" width="25%" valign="top" class="list-item">Key</td>
<td align="left" width="70%" valign="top" class="list-item">Value</td>
</dtml-if>
<dtml-if name="sequence-odd"><tr class="row-hilite">
<dtml-else><tr></dtml-if>
<td width="32" bgcolor="#ffffff">&nbsp;</td>
<td align="left" valign="top" class="form-element">
&dtml-sequence-key;
</td>
<td align="left" valign="top" class="form-element">
&dtml-sequence-item;
</td>
</tr>
</dtml-in>
</table>
<dtml-var manage_page_footer>
...@@ -40,8 +40,8 @@ ...@@ -40,8 +40,8 @@
<td align="left" valign="top">&nbsp;</td> <td align="left" valign="top">&nbsp;</td>
<td align="left" valign="top"> <td align="left" valign="top">
<div class="form-text"> <div class="form-text">
<a href="<dtml-var <a href="&dtml-URL1;/manage_objectInformation?rid=&dtml-getRID;"
"getURL" url_quote>/manage_workspace">&dtml-getPath;</a> target="_objectinfo_&dtml-getRID;">&dtml-getPath;</a>
</div> </div>
</td> </td>
<td align="left" valign="top"> <td align="left" valign="top">
......
...@@ -6,7 +6,9 @@ ZCatalog - Cataloged Objects: Manage catalog entries ...@@ -6,7 +6,9 @@ ZCatalog - Cataloged Objects: Manage catalog entries
The catalog holds records which refer to Zope objects. If the The catalog holds records which refer to Zope objects. If the
catalog currently contains records they will be listed in this catalog currently contains records they will be listed in this
view. view. For debugging purposes, you may click on the link to
the item in the Catalog and it will open a debugging view of
that entry in the Catalog.
Controls Controls
......
...@@ -150,22 +150,27 @@ class Lexicon(Persistent, Implicit): ...@@ -150,22 +150,27 @@ class Lexicon(Persistent, Implicit):
self.counter = self.counter + 1 self.counter = self.counter + 1
return self.counter - 1 return self.counter - 1
def get(self, key, default=None): def get(self, key, default=None):
""" """ """ """
return [self._lexicon.get(key, default)] return [self._lexicon.get(key, default)]
def __getitem__(self, key): def __getitem__(self, key):
return self.get(key) return self.get(key)
def __len__(self): def __len__(self):
return len(self._lexicon) return len(self._lexicon)
def Splitter(self, astring, words=None): def Splitter(self, astring, words=None):
""" wrap the splitter """ """ wrap the splitter """
if words is None: if words is None:
words = self.stop_syn words = self.stop_syn
return Splitter(astring, words) return Splitter(astring, words)
def grep(self, query): def grep(self, query):
""" """
regular expression search through the lexicon regular expression search through the lexicon
...@@ -180,6 +185,7 @@ class Lexicon(Persistent, Implicit): ...@@ -180,6 +185,7 @@ class Lexicon(Persistent, Implicit):
hits.append(x) hits.append(x)
return hits return hits
def query_hook(self, q): def query_hook(self, q):
""" we don't want to modify the query cuz we're dumb """ """ we don't want to modify the query cuz we're dumb """
return q return q
......
...@@ -85,7 +85,8 @@ ...@@ -85,7 +85,8 @@
"""Simple column indices""" """Simple column indices"""
__version__='$Revision: 1.21 $'[11:-2] __version__='$Revision: 1.22 $'[11:-2]
from Globals import Persistent from Globals import Persistent
...@@ -154,6 +155,7 @@ class UnIndex(Persistent, Implicit): ...@@ -154,6 +155,7 @@ class UnIndex(Persistent, Implicit):
def __len__(self): def __len__(self):
return len(self._unindex) return len(self._unindex)
def histogram(self): def histogram(self):
"""Return a mapping which provides a histogram of the number of """Return a mapping which provides a histogram of the number of
elements found at each point in the index.""" elements found at each point in the index."""
...@@ -165,6 +167,21 @@ class UnIndex(Persistent, Implicit): ...@@ -165,6 +167,21 @@ class UnIndex(Persistent, Implicit):
return histogram return histogram
def referencedObjects(self):
"""Generate a list of IDs for which we have referenced objects."""
return self._unindex.keys()
def getEntryForObject(self, documentId, default=None):
"""Takes a document ID and returns all the information we have
on that specific object."""
if default is None:
return self._unindex.get(documentId, default)
else:
return self._unindex.get(documentId)
def removeForwardIndexEntry(self, entry, documentId): def removeForwardIndexEntry(self, entry, documentId):
"""Take the entry provided and remove any reference to documentId """Take the entry provided and remove any reference to documentId
in its entry in the index.""" in its entry in the index."""
...@@ -173,6 +190,8 @@ class UnIndex(Persistent, Implicit): ...@@ -173,6 +190,8 @@ class UnIndex(Persistent, Implicit):
if indexRow is not MV: if indexRow is not MV:
try: try:
indexRow.remove(documentId) indexRow.remove(documentId)
if len(indexRow) == 0:
del self._index[entry]
except: except:
LOG(self.__class__.__name__, ERROR, LOG(self.__class__.__name__, ERROR,
('unindex_object could not remove ' ('unindex_object could not remove '
...@@ -184,6 +203,7 @@ class UnIndex(Persistent, Implicit): ...@@ -184,6 +203,7 @@ class UnIndex(Persistent, Implicit):
('unindex_object tried to retrieve set %s ' ('unindex_object tried to retrieve set %s '
'from index %s but couldn\'t. This ' 'from index %s but couldn\'t. This '
'should not happen.' % (repr(set),str(k)))) 'should not happen.' % (repr(set),str(k))))
def insertForwardIndexEntry(self, entry, documentId): def insertForwardIndexEntry(self, entry, documentId):
"""Take the entry provided and put it in the correct place """Take the entry provided and put it in the correct place
...@@ -200,6 +220,7 @@ class UnIndex(Persistent, Implicit): ...@@ -200,6 +220,7 @@ class UnIndex(Persistent, Implicit):
indexRow = self._index[entry] indexRow = self._index[entry]
indexRow.insert(documentId) indexRow.insert(documentId)
def index_object(self, documentId, obj, threshold=None): def index_object(self, documentId, obj, threshold=None):
""" index and object 'obj' with integer id 'documentId'""" """ index and object 'obj' with integer id 'documentId'"""
...@@ -309,7 +330,7 @@ class UnIndex(Persistent, Implicit): ...@@ -309,7 +330,7 @@ class UnIndex(Persistent, Implicit):
else: #not a range else: #not a range
get = index.get get = index.get
for key in keys: for key in keys:
if key: if nonempty(key):
anyTrue = 1 anyTrue = 1
set=get(key) set=get(key)
if set is not None: if set is not None:
......
...@@ -119,7 +119,7 @@ class UnKeywordIndex(UnIndex): ...@@ -119,7 +119,7 @@ class UnKeywordIndex(UnIndex):
newKeywords = MV newKeywords = MV
if type(newKeywords) is StringType: if type(newKeywords) is StringType:
newKeywords = (keywords, ) newKeywords = (newKeywords, )
# Now comes the fun part, we need to figure out what's changed # Now comes the fun part, we need to figure out what's changed
# if anything from the previous record. # if anything from the previous record.
......
...@@ -92,7 +92,7 @@ is no longer known. ...@@ -92,7 +92,7 @@ is no longer known.
""" """
__version__='$Revision: 1.32 $'[11:-2] __version__='$Revision: 1.33 $'[11:-2]
from Globals import Persistent from Globals import Persistent
...@@ -195,6 +195,7 @@ class UnTextIndex(Persistent, Implicit): ...@@ -195,6 +195,7 @@ class UnTextIndex(Persistent, Implicit):
def __len__(self): def __len__(self):
return len(self._unindex) return len(self._unindex)
def clear(self): def clear(self):
self._index = IOBTree() self._index = IOBTree()
self._unindex = IOBTree() self._unindex = IOBTree()
...@@ -211,7 +212,23 @@ class UnTextIndex(Persistent, Implicit): ...@@ -211,7 +212,23 @@ class UnTextIndex(Persistent, Implicit):
return histogram return histogram
def getEntryForObject(self, rid, default=None):
wordMap = self.getLexicon(self._lexicon)._lexicon.items()
results = self._unindex.get(rid, None)
if results is None:
return default
else:
# Now that we've got them, let's resolve out the word
# references
resolved = []
for (word, wordId) in wordMap:
if wordId in results:
resolved.append(word)
return tuple(resolved)
def insertForwardIndexEntry(self, entry, documentId, score=1): def insertForwardIndexEntry(self, entry, documentId, score=1):
"""Uses the information provided to update the indexes. """Uses the information provided to update the indexes.
...@@ -256,12 +273,14 @@ class UnTextIndex(Persistent, Implicit): ...@@ -256,12 +273,14 @@ class UnTextIndex(Persistent, Implicit):
self._index[entry] = (documentId, score) self._index[entry] = (documentId, score)
return 1 return 1
def insertReverseIndexEntry(self, entry, documentId): def insertReverseIndexEntry(self, entry, documentId):
"""Insert the correct entry into the reverse indexes for future """Insert the correct entry into the reverse indexes for future
unindexing.""" unindexing."""
newEntry = self._unindex.get(documentId, []) newEntry = self._unindex.get(documentId, [])
newEntry.append(entry) newEntry.append(entry)
self._unindex[documentId] = newEntry self._unindex[documentId] = newEntry
def index_object(self, documentId, obj, threshold=None): def index_object(self, documentId, obj, threshold=None):
...@@ -325,6 +344,7 @@ class UnTextIndex(Persistent, Implicit): ...@@ -325,6 +344,7 @@ class UnTextIndex(Persistent, Implicit):
## return the number of words you indexed ## return the number of words you indexed
return wordCount return wordCount
def unindex_object(self, i): def unindex_object(self, i):
""" carefully unindex document with integer id 'i' from the text """ carefully unindex document with integer id 'i' from the text
index and do not fail if it does not exist """ index and do not fail if it does not exist """
...@@ -345,6 +365,7 @@ class UnTextIndex(Persistent, Implicit): ...@@ -345,6 +365,7 @@ class UnTextIndex(Persistent, Implicit):
' document %s' % str(i)) ' document %s' % str(i))
del unindex[i] del unindex[i]
def __getitem__(self, word): def __getitem__(self, word):
"""Return an InvertedIndex-style result "list" """Return an InvertedIndex-style result "list"
""" """
......
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