Work in progress: indexing and searching
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@1101 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
15da165f09
commit
fc6946be95
2 changed files with 16 additions and 7 deletions
|
@ -122,15 +122,23 @@ class ConceptView(BaseView):
|
||||||
return []
|
return []
|
||||||
searchTerm = request.get('searchTerm', None)
|
searchTerm = request.get('searchTerm', None)
|
||||||
searchType = request.get('searchType', None)
|
searchType = request.get('searchType', None)
|
||||||
if searchTerm or searchType:
|
result = []
|
||||||
|
if searchTerm or searchType != 'none':
|
||||||
criteria = {}
|
criteria = {}
|
||||||
if searchTerm:
|
if searchTerm:
|
||||||
criteria['loops_title'] = searchTerm
|
criteria['loops_title'] = searchTerm
|
||||||
if searchType:
|
if searchType:
|
||||||
criteria['loops_type'] = (searchType, searchType)
|
if searchType.endswith('*'):
|
||||||
|
start = searchType[:-1]
|
||||||
|
end = start + '\x7f'
|
||||||
|
else:
|
||||||
|
start = end = searchType
|
||||||
|
criteria['loops_type'] = (start, end)
|
||||||
cat = zapi.getUtility(ICatalog)
|
cat = zapi.getUtility(ICatalog)
|
||||||
result = cat.searchResults(**criteria)
|
result = cat.searchResults(**criteria)
|
||||||
else:
|
else:
|
||||||
|
result = self.loopsRoot.getConceptManager().values()
|
||||||
|
if searchType == 'none':
|
||||||
result = [r for r in result if r.conceptType is None]
|
result = [r for r in result if r.conceptType is None]
|
||||||
return self.viewIterator(result)
|
return self.viewIterator(result)
|
||||||
|
|
||||||
|
@ -159,9 +167,6 @@ class ConceptView(BaseView):
|
||||||
self.getConceptTypeTokenForSearch(t))), t.title)
|
self.getConceptTypeTokenForSearch(t))), t.title)
|
||||||
for t in types]
|
for t in types]
|
||||||
return util.KeywordVocabulary(typesItems)
|
return util.KeywordVocabulary(typesItems)
|
||||||
#terms = zapi.getMultiAdapter((types, self.request), ITerms)
|
|
||||||
#for type in types:
|
|
||||||
# yield terms.getTerm(type)
|
|
||||||
|
|
||||||
def getConceptTypeTokenForSearch(self, ct):
|
def getConceptTypeTokenForSearch(self, ct):
|
||||||
return ct is None and 'unknown' or zapi.getName(ct)
|
return ct is None and 'unknown' or zapi.getName(ct)
|
||||||
|
|
|
@ -132,7 +132,9 @@
|
||||||
tal:attributes="value searchTerm" />
|
tal:attributes="value searchTerm" />
|
||||||
<span i18n:translate="">Type</span>
|
<span i18n:translate="">Type</span>
|
||||||
<select name="searchType">
|
<select name="searchType">
|
||||||
<option value="*">Any</option>
|
<option value="loops:concept:*"
|
||||||
|
tal:attributes="selected python:
|
||||||
|
searchType == 'loops:concept:*'">Any</option>
|
||||||
<tal:types repeat="type view/conceptTypesForSearch">
|
<tal:types repeat="type view/conceptTypesForSearch">
|
||||||
<option value=".loops/concepts/topic"
|
<option value=".loops/concepts/topic"
|
||||||
i18n:translate=""
|
i18n:translate=""
|
||||||
|
@ -140,7 +142,9 @@
|
||||||
selected python: type.token == searchType"
|
selected python: type.token == searchType"
|
||||||
tal:content="type/title">Topic</option>
|
tal:content="type/title">Topic</option>
|
||||||
</tal:types>
|
</tal:types>
|
||||||
<option>None</option>
|
<option value="none"
|
||||||
|
tal:attributes="selected python:
|
||||||
|
searchType == 'none'">None</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="formControls">
|
<div class="formControls">
|
||||||
|
|
Loading…
Add table
Reference in a new issue