def __call__(self, show_all=0, quote_logic=0, quote_logic_indexes=['SearchableText'], search_catalog=None): results = [] catalog = utils.getSearchCatalog(aq_inner(self.context), search_catalog) indexes = catalog.indexes() query = {} show_query = show_all second_pass = {} for k, v in self.request.items(): if v and k in indexes: if type(v) == str and v.strip().lower().startswith('path:'): # Searching for exact path enabled! This will return the # item on the specified path and all items in its subtree # NOTE: Multiple spaces, slashes and/or a trailing slash in # the path, while easily overlooked by users, might cause # no results to be found. Let's take care of this for the # convenience of the user. Besides, we need to strip # 'path:' from the path string. path = re.sub("/{2,}", "/", v.strip()[5:]).rstrip("/") d = {"path": {"query": path}} else: if quote_logic and k in quote_logic_indexes: v = utils.quotequery(v) d = {k: v} query.update(d) show_query = 1 elif k.endswith('_usage'): key = k[:-6] param, value = v.split(':') second_pass[key] = {param: value} elif k in ('sort_on', 'sort_order', 'sort_limit'): query.update({k: v}) for k, v in second_pass.items(): qs = query.get(k) if qs is None: continue query[k] = q = {'query': qs} q.update(v) # doesn't normal call catalog unless some field has been queried # against. if you want to call the catalog _regardless_ of whether # any items were found, then you can pass show_all=1. if show_query: try: results = catalog(**query) except ParseError: pass return results
def __call__(self, show_all=0, quote_logic=0, quote_logic_indexes=['SearchableText'], search_catalog=None): results=[] catalog = utils.getSearchCatalog(aq_inner(self.context), search_catalog) indexes = catalog.indexes() query = {} show_query = show_all second_pass = {} for k, v in self.request.items(): if v and k in indexes: if quote_logic and k in quote_logic_indexes: v = utils.quotequery(v) query.update({k: v}) show_query=1 elif k.endswith('_usage'): key = k[:-6] param, value = v.split(':') second_pass[key] = {param: value} elif k in ('sort_on', 'sort_order', 'sort_limit'): query.update({k: v}) for k, v in second_pass.items(): qs = query.get(k) if qs is None: continue query[k] = q = {'query': qs} q.update(v) if 'path' not in query: query['path'] = getNavigationRoot(self.context) # doesn't normal call catalog unless some field has been queried # against. if you want to call the catalog _regardless_ of whether # any items were found, then you can pass show_all=1. if show_query: try: results = catalog(**query) except ParseError: pass return results
def search_catalog(self): assert self._updated return utils.getSearchCatalog(aq_inner(self.context), self.widget.search_catalog)
def search_catalog(self): assert self._updated return utils.getSearchCatalog(aq_inner(self.context), self.widget.search_catalog)
def __call__(self, show_all=0, quote_logic=0, quote_logic_indexes=['SearchableText'], search_catalog=None): results = [] catalog = utils.getSearchCatalog(aq_inner(self.context), search_catalog) indexes = catalog.indexes() query = {} show_query = show_all second_pass = {} purl_tool = getToolByName(self.context, 'portal_url') portal_path = purl_tool.getPortalPath() for k, v in self.request.items(): if v and k in indexes: if type(v) == str and v.strip().lower().startswith('path:'): # Searching for exact path enabled! This will return the # item on the specified path and all items in its subtree # NOTE: Multiple spaces, slashes and/or a trailing slash in # the path, while easily overlooked by users, might cause # no results to be found. Let's take care of this for the # convenience of the user. Besides, we need to strip # 'path:' from the path string. path = re.sub("/{2,}", "/", v.strip()[5:]).rstrip("/") if not path.startswith("/"): path = "/" + path # Since we might be in a virtual-hosting environment, we # need to prepend the portal path if not present yet if not path.startswith(portal_path): path = portal_path + path d = {"path": {"query": path}} else: if quote_logic and k in quote_logic_indexes: v = utils.quotequery(v) d = {k: v} query.update(d) show_query = 1 elif k.endswith('_usage'): key = k[:-6] param, value = v.split(':') second_pass[key] = {param: value} elif k in ('sort_on', 'sort_order', 'sort_limit'): query.update({k: v}) for k, v in second_pass.items(): qs = query.get(k) if qs is None: continue query[k] = q = {'query': qs} q.update(v) # doesn't normal call catalog unless some field has been queried # against. if you want to call the catalog _regardless_ of whether # any items were found, then you can pass show_all=1. if show_query: try: results = catalog(**query) except ParseError: pass return results