Commit 2ef1dd35 authored by Ivan Tyagov's avatar Ivan Tyagov

Search for documents which reference us only if our reference itself is

following format defined in system preference level.
parent a4011582
......@@ -58,7 +58,8 @@ and make sure we get latest/most relevant version\n
should be reimplemented in SQL some sunny day.\n
"""\n
reference = context.getReference()\n
if reference is None:\n
if reference is None or not context.isSearchableReference():\n
# empty or not following format preference\n
return ()\n
\n
return context.Base_zGetImplicitPredecessorValueList(reference=reference)\n
......
1269
\ No newline at end of file
1270
\ No newline at end of file
......@@ -317,6 +317,22 @@ class Document(DocumentExtensibleTraversableMixin, XMLObject, UrlMixin,
preferences.
"""
text = self.getSearchableText() # XXX getSearchableText or asText ?
return self._getSearchableReferenceList(text)
security.declareProtected(Permissions.AccessContentsInformation, 'getSearchableReferenceList')
def isSearchableReference(self):
"""
Determine if current document's reference can be used for searching - i.e. follows
certain defined at system level preferences format.
"""
reference = self.getReference()
return len(self._getSearchableReferenceList(reference))
def _getSearchableReferenceList(self, text):
"""
Extract all reference alike strings from text using for that a
regular expression defined at system level preferences.
"""
regexp = self.portal_preferences.getPreferredDocumentReferenceRegularExpression()
try:
rx_search = re.compile(regexp)
......@@ -334,7 +350,7 @@ class Document(DocumentExtensibleTraversableMixin, XMLObject, UrlMixin,
tmp[key] = None
for group, group_item_tuple in tmp.keys():
result.append((group, dict(group_item_tuple)))
return result
return result
security.declareProtected(Permissions.AccessContentsInformation, 'getImplicitSuccessorValueList')
def getImplicitSuccessorValueList(self):
......
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