search.shtml revision 3171
742N/A## You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
742N/A## file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1116N/A import pkg.actions as actions
1116N/A import pkg.query_parser as qp
1116N/A import pkg.server.api_errors as api_errors
1116N/A import pkg.version as version
742N/A<%inherit file="layout.shtml"/>\
1116N/A "token": request.params.get("token", ""),
1116N/A "query_error": request.params.get("qe", ""),
1116N/A show = request.params.get("show", "p")
1116N/A criteria["return_type"] = qp.Query.RETURN_PACKAGES
1116N/A criteria["return_type"] = qp.Query.RETURN_ACTIONS
1116N/A val = request.params.get(name, default)
1116N/A mver = criteria.get("selected_ver", None)
1116N/A results = catalog.search(token,
3171N/A except qp.QueryLengthExceeded as e:
3171N/A except qp.QueryException as e:
2028N/A query_error = urllib.quote(str(e))
1116N/A result = results.next()
1116N/A if result and result[1] == qp.Query.RETURN_PACKAGES:
1116N/A results = itertools.chain([result], results)
1116N/A elif result and result[1] == qp.Query.RETURN_ACTIONS:
1116N/A results = itertools.chain([result], results)
1116N/A return_type = qp.Query.RETURN_PACKAGES
3158N/A request.log("Unsupported return_type '{0}' "
1116N/A search_uri = "advanced_search.shtml"
1116N/A<form class="search" action="search.shtml">
1116N/A scheme, netloc, path, params, query, fragment = urlparse.urlparse(uri)
1116N/A for name, val in request.params.iteritems():
1116N/A nparams.append((name, val))
1116N/A nparams.append(("start", start))
1116N/A qs = urllib.urlencode(nparams)
1116N/A uri = urlparse.urlunparse((scheme, netloc, path, params, qs, fragment))
1116N/A scheme, netloc, path, params, query, fragment = urlparse.urlparse(uri)
1116N/A for name, val in request.params.iteritems():
1116N/A nparams.append((name, val))
1116N/A nparams.append(("start", (start + result_count - 1)))
1116N/A qs = urllib.urlencode(nparams)
1116N/A uri = urlparse.urlunparse((scheme, netloc, path, params, qs, fragment))
1116N/A <a href="${self.get_prev_page_uri(criteria, request) | h}">
1116N/A <a href="${self.get_next_page_uri(criteria, request,
742N/A% if not catalog.search_available:
1116N/A criteria = self.get_search_criteria(request)
2946N/A lines = cgi.escape(query_error, True).splitlines(True)
2946N/A if l.startswith("\t"):
1116N/A return_type, results, query_error = self.search(
2852N/A lang = request.path_info.split("/")[1]
1116N/A fragment = urlparse.urlparse(uri)
1116N/A for name, val in request.params.iteritems():
1116N/A nparams.append((name, val))
1116N/A nparams.append(("failed", 1))
1116N/A nparams.append(("qe", query_error))
1116N/A qs = urllib.urlencode(nparams)
1116N/A uri = urlparse.urlunparse((scheme, netloc, path, params,
1116N/A raise api_errors.RedirectException(uri)
1116N/A ${self.display_search_form(criteria, request)}
742N/A<kbd>/usr/bin/vim</kbd></li>
1116N/A% if searched and return_type == qp.Query.RETURN_PACKAGES:
1850N/A stem = pfmri.pkg_name
1850N/A pfmri_str = pfmri.get_fmri(anarchy=True,
2989N/A pfmri_uri = pfmri.get_fmri(anarchy=True,
3158N/A phref = self.shared.rpath(g_vars, "info/0/{0}".format(
2989N/A urllib.quote(pfmri_uri, "")))
3158N/A p5ihref = self.shared.rpath(g_vars,
3158N/A "p5i/0/{0}.p5i".format(urllib.quote(stem, "")))
2852N/A mhref = self.shared.rpath(g_vars,
3158N/A "manifest/0/{0}".format(pfmri.get_url_path()))
1116N/A% elif searched and return_type == qp.Query.RETURN_ACTIONS:
1116N/A if isinstance(a, actions.attribute.AttributeAction):
1850N/A pfmri_str = pfmri.get_fmri(anarchy=True,
3158N/A phref = self.shared.rpath(g_vars, "info/0/{0}".format(
1850N/A urllib.quote(pfmri_str, "")))