diff --git a/README.txt b/README.txt
index fe66109..4d64333 100755
--- a/README.txt
+++ b/README.txt
@@ -183,13 +183,20 @@ predicates:
[(u'has type', '.loops/concepts/hasType'),
(u'subconcept', '.loops/concepts/standard')]
-Searchable Text Adapter
------------------------
+Index attributes adapter
+------------------------
>>> from loops.concept import IndexAttributes
>>> idx = IndexAttributes(cc2)
>>> idx.text()
u'cc2 Zope 3'
+
+ >>> idx.title()
+ u'cc2 Zope 3'
+
+ >>> idx.type()
+ 'loops:concept:unknown'
+
Resources and what they have to do with Concepts
================================================
@@ -259,6 +266,20 @@ below) via the getClients() method:
>>> conc[0] is cc1
True
+Index attributes adapter
+------------------------
+
+ >>> from loops.resource import IndexAttributes
+ >>> idx = IndexAttributes(doc1)
+ >>> idx.text()
+ u'doc1 Zope Info'
+
+ >>> idx.title()
+ u'doc1 Zope Info'
+
+ >>> idx.type()
+ 'loops:resource:Document'
+
Views/Nodes: Menus, Menu Items, Listings, Pages, etc
====================================================
diff --git a/browser/common.py b/browser/common.py
index afbe267..5aecfe3 100644
--- a/browser/common.py
+++ b/browser/common.py
@@ -71,7 +71,7 @@ class BaseView(object):
def typeTitle(self):
voc = util.KeywordVocabulary(getTargetTypes())
token = '.'.join((self.context.__module__,
- self.context.__class__.__name__))
+ self.context.__class__.__name__))
term = voc.getTermByToken(token)
return term.title
diff --git a/browser/concept.py b/browser/concept.py
index 8753751..710e4bf 100644
--- a/browser/concept.py
+++ b/browser/concept.py
@@ -120,18 +120,17 @@ class ConceptView(BaseView):
if request.get('action') != 'search':
return []
searchTerm = request.get('searchTerm', None)
- if searchTerm:
+ searchType = request.get('searchType', None)
+ if searchTerm or searchType:
+ criteria = {}
+ if searchTerm:
+ criteria['loops_title'] = searchTerm
+ if searchType:
+ criteria['loops_type'] = (searchType)
cat = zapi.getUtility(ICatalog)
- result = cat.searchResults(loops_text=searchTerm)
+ result = cat.searchResults(**criteria)
else:
- result = self.loopsRoot.getConceptManager().values()
- searchType = request.get('searchType', '*')
- # TODO: query catalog for type
- if not searchType:
- result = [r for r in result if r.conceptType is None]
- elif searchType != '*':
- type = self.loopsRoot.loopsTraverse(searchType)
- result = [r for r in result if r.conceptType == type]
+ result = [r for r in result if r.conceptType is None]
return self.viewIterator(result)
@Lazy
diff --git a/browser/node.py b/browser/node.py
index 5aea80f..4e970c8 100644
--- a/browser/node.py
+++ b/browser/node.py
@@ -37,7 +37,7 @@ from zope.security.proxy import removeSecurityProxy
from loops.interfaces import IConcept, IDocument, IMediaAsset
from loops.resource import MediaAsset
-from loops.target import getTargetTypes
+from loops.target import getTargetTypes, getTargetTypesForSearch
from loops import util
from loops.browser.common import BaseView
from loops.browser.concept import ConceptView
@@ -203,15 +203,29 @@ class ConfigureView(BaseView):
def targetTypes(self):
return util.KeywordVocabulary(getTargetTypes())
+ def targetTypesForSearch(self):
+ return util.KeywordVocabulary(getTargetTypesForSearch())
+
@Lazy
def search(self):
request = self.request
if request.get('action') != 'search':
return []
searchTerm = request.get('searchTerm', None)
- if searchTerm:
+ searchType = request.get('searchType', None)
+ if searchTerm or searchType:
+ criteria = {}
+ if searchTerm:
+ criteria['loops_title'] = searchTerm
+ if searchType:
+ if searchType.endswith('*'):
+ start = searchType[:-1]
+ end = start + '\x7f'
+ else:
+ start = end = searchType
+ criteria['loops_type'] = (start, end)
cat = zapi.getUtility(ICatalog)
- result = cat.searchResults(loops_text=searchTerm)
+ result = cat.searchResults(**criteria)
else:
result = (list(self.loopsRoot.getConceptManager().values())
+ list(self.loopsRoot.getResourceManager().values()))
diff --git a/browser/target_macros.pt b/browser/target_macros.pt
index 39a5a91..154fd1a 100644
--- a/browser/target_macros.pt
+++ b/browser/target_macros.pt
@@ -124,8 +124,8 @@
tal:attributes="value searchTerm" />
Type