search.shtml revision 2662
0N/A## You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
0N/A## file and include the License file at usr/src/OPENSOLARIS.LICENSE.
263N/A import pkg.actions as actions
263N/A import pkg.query_parser as qp
263N/A import pkg.server.api_errors as api_errors
263N/A import pkg.version as version
1190N/A<%inherit file="layout.shtml"/>\
542N/A "token": request.params.get("token", ""),
542N/A "query_error": request.params.get("qe", ""),
212N/A show = request.params.get("show", "p")
0N/A criteria["return_type"] = qp.Query.RETURN_PACKAGES
criteria["return_type"] = qp.Query.RETURN_ACTIONS
val = request.params.get(name, default)
mver = criteria.get("selected_ver", None)
results = catalog.search(token,
except qp.QueryException, e:
query_error = e.html()
query_error = urllib.quote(str(e))
result = results.next()
if result and result[1] == qp.Query.RETURN_PACKAGES:
results = itertools.chain([result], results)
elif result and result[1] == qp.Query.RETURN_ACTIONS:
results = itertools.chain([result], results)
return_type = qp.Query.RETURN_PACKAGES
request.log("Unsupported return_type '%s' "
search_uri = "advanced_search.shtml"
<form class="search" action="search.shtml">
scheme, netloc, path, params, query, fragment = urlparse.urlparse(uri)
for name, val in request.params.iteritems():
nparams.append((name, val))
nparams.append(("start", start))
qs = urllib.urlencode(nparams)
uri = urlparse.urlunparse((scheme, netloc, path, params, qs, fragment))
scheme, netloc, path, params, query, fragment = urlparse.urlparse(uri)
for name, val in request.params.iteritems():
nparams.append((name, val))
nparams.append(("start", (start + result_count - 1)))
qs = urllib.urlencode(nparams)
uri = urlparse.urlunparse((scheme, netloc, path, params, qs, fragment))
<a href="${self.get_prev_page_uri(criteria, request) | h}">
<a href="${self.get_next_page_uri(criteria, request,
% if not catalog.search_available:
criteria = self.get_search_criteria(request)
query_error = re.sub(pat1, '""', query_error)
query_error = re.sub(pat2, "", query_error)
query_error = re.sub(pat3, "", query_error)
query_error = re.sub(pat4, "", query_error)
return_type, results, query_error = self.search(
fragment = urlparse.urlparse(uri)
for name, val in request.params.iteritems():
nparams.append((name, val))
nparams.append(("failed", 1))
nparams.append(("qe", query_error))
qs = urllib.urlencode(nparams)
uri = urlparse.urlunparse((scheme, netloc, path, params,
raise api_errors.RedirectException(uri)
${self.display_search_form(criteria, request)}
<kbd>/usr/bin/vim</kbd></li>
<kbd>/usr/bin/[ca]t</kbd></li>
% if searched and return_type == qp.Query.RETURN_PACKAGES:
stem = pfmri.pkg_name
pfmri_str = pfmri.get_fmri(anarchy=True,
phref = self.shared.rpath(g_vars, "info/0/%s" % (
urllib.quote(pfmri_str, "")))
urllib.quote(stem, "")))
mhref = self.shared.rpath(g_vars, "manifest/0/%s" % (
urllib.quote(pfmri_str, "")))
% elif searched and return_type == qp.Query.RETURN_ACTIONS:
action = a.name
if isinstance(a, actions.attribute.AttributeAction):
pfmri_str = pfmri.get_fmri(anarchy=True,
phref = self.shared.rpath(g_vars, "info/0/%s" % (
urllib.quote(pfmri_str, "")))