Beispiel #1
0
    def dashboard_organizations(self):
        context = {
            "model": model,
            "session": model.Session,
            "for_view": True,
            "user": c.user or c.author,
            "auth_user_obj": c.userobj,
        }

        data_dict = {"user_obj": c.userobj}
        self._setup_template_variables(context, data_dict)
        (user_orgs, usr_suborgs) = get_user_toporgs(c.userobj.id)

        facets = OrderedDict()

        # Add the organization facet to get the number of records for each organization
        facets["organization"] = _("Organizations")

        data_dict = {"facet.field": facets.keys()}

        query = get_action("package_search")(context, data_dict)
        c.org_pkg_count = query["facets"].get("organization")
        c.top_orgs_items = user_orgs
        c.suborgs_items = usr_suborgs

        return render("user/dashboard_organizations.html")
    def index(self):
        # FIXME: index copied from GroupController and modified to
        # show only parent groups
        context = {
            "model": model,
            "session": model.Session,
            "user": c.user or c.author,
            "for_view": True,
            "with_private": False,
        }

        data_dict = {"all_fields": False}
        try:
            self._check_access("site_read", context)
        except NotAuthorized:
            abort(401, _("Not authorized to see this page"))

        # pass user info to context as needed to view private datasets of
        # orgs correctly
        if c.userobj:
            context["user_id"] = c.userobj.id
            context["user_is_admin"] = c.userobj.sysadmin

        search_result = self._action("organization_list")(context, data_dict)

        org_model = context["model"]

        # Get the list of all groups of type "organization" that have no parents.
        top_level_orgs = org_model.Group.get_top_level_groups(type="organization")
        top_results = [org for org in top_level_orgs if org.name in search_result]

        facets = OrderedDict()

        facets["organization"] = _("Organizations")

        data_dict = {"facet.field": facets.keys()}

        query = get_action("package_search")(context, data_dict)
        c.org_pkg_count = query["facets"].get("organization")

        c.top_orgs_items = top_results
        return render("organization/index.html")
Beispiel #3
0
    def _read(self, id, limit, group_type):
        """ This is common code used by both read and bulk_process"""
        context = {
            "model": model,
            "session": model.Session,
            "user": c.user or c.author,
            "schema": self._db_to_form_schema(group_type=group_type),
            "for_view": True,
            "extras_as_string": True,
        }

        q = c.q = request.params.get("q", "")
        # Search within group
        if c.group_dict.get("is_organization"):
            q += ' owner_org:"%s"' % c.group_dict.get("id")
        else:
            q += ' groups:"%s"' % c.group_dict.get("name")

        c.description_formatted = h.render_markdown(c.group_dict.get("description"))

        context["return_query"] = True

        # c.group_admins is used by CKAN's legacy (Genshi) templates only,
        # if we drop support for those then we can delete this line.
        c.group_admins = authz.get_group_or_org_admin_ids(c.group.id)

        page = self._get_page_number(request.params)

        # most search operations should reset the page counter:
        params_nopage = [(k, v) for k, v in request.params.items() if k != "page"]
        sort_by = request.params.get("sort", None)

        def search_url(params):
            controller = lookup_group_controller(group_type)
            action = "bulk_process" if c.action == "bulk_process" else "read"
            url = h.url_for(controller=controller, action=action, id=id)
            params = [(k, v.encode("utf-8") if isinstance(v, basestring) else str(v)) for k, v in params]
            return url + u"?" + urlencode(params)

        def drill_down_url(**by):
            return h.add_url_param(
                alternative_url=None,
                controller="group",
                action="read",
                extras=dict(id=c.group_dict.get("name")),
                new_params=by,
            )

        c.drill_down_url = drill_down_url

        def remove_field(key, value=None, replace=None):
            return h.remove_url_param(
                key,
                value=value,
                replace=replace,
                controller="group",
                action="read",
                extras=dict(id=c.group_dict.get("name")),
            )

        c.remove_field = remove_field

        def pager_url(q=None, page=None):
            params = list(params_nopage)
            params.append(("page", page))
            return search_url(params)

        try:
            c.fields = []
            search_extras = {}
            for (param, value) in request.params.items():
                if not param in ["q", "page", "sort"] and len(value) and not param.startswith("_"):
                    if not param.startswith("ext_"):
                        c.fields.append((param, value))
                        q += ' %s: "%s"' % (param, value)
                    else:
                        search_extras[param] = value

            fq = 'capacity:"public"'
            user_member_of_orgs = [org["id"] for org in h.organizations_available("read")]

            if c.group and c.group.id in user_member_of_orgs:
                fq = ""
                context["ignore_capacity_check"] = True

            facets = OrderedDict()

            default_facet_titles = {
                "organization": _("Organizations"),
                "groups": _("Groups"),
                "tags": _("Tags"),
                "res_format": _("Formats"),
                "license_id": _("Licenses"),
            }

            for facet in g.facets:
                if facet in default_facet_titles:
                    facets[facet] = default_facet_titles[facet]
                else:
                    facets[facet] = facet

            # Facet titles
            self._update_facet_titles(facets, group_type)

            if "capacity" in facets and (group_type != "organization" or not user_member_of_orgs):
                del facets["capacity"]

            c.facet_titles = facets

            data_dict = {
                "q": q,
                "fq": fq,
                "facet.field": facets.keys(),
                "rows": limit,
                "sort": sort_by,
                "start": (page - 1) * limit,
                "extras": search_extras,
            }

            context_ = dict((k, v) for (k, v) in context.items() if k != "schema")
            query = get_action("package_search")(context_, data_dict)

            c.page = h.Page(
                collection=query["results"], page=page, url=pager_url, item_count=query["count"], items_per_page=limit
            )

            c.group_dict["package_count"] = query["count"]
            c.facets = query["facets"]
            maintain.deprecate_context_item("facets", "Use `c.search_facets` instead.")

            c.search_facets = query["search_facets"]
            c.search_facets_limits = {}
            for facet in c.facets.keys():
                limit = int(request.params.get("_%s_limit" % facet, g.facets_default_number))
                c.search_facets_limits[facet] = limit
            c.page.items = query["results"]

            c.sort_by_selected = sort_by

        except search.SearchError, se:
            log.error("Group search error: %r", se.args)
            c.query_error = True
            c.facets = {}
            c.page = h.Page(collection=[])
Beispiel #4
0
            if not asbool(config.get("ckan.search.show_all_types", "False")):
                fq += " +dataset_type:dataset"

            facets = OrderedDict()

            default_facet_titles = {
                "organization": _("Organizations"),
                "groups": _("Groups"),
                "tags": _("Tags"),
                "res_format": _("Formats"),
                "license_id": _("License"),
            }

            for facet in g.facets:
                if facet in default_facet_titles:
                    facets[facet] = default_facet_titles[facet]
                else:
                    facets[facet] = facet

            # Facet titles
            for plugin in p.PluginImplementations(p.IFacets):
                facets = plugin.dataset_facets(facets, package_type)

            c.facet_titles = facets

            data_dict = {
                "q": q,
                "fq": fq.strip(),
                "facet.field": facets.keys(),
                "rows": limit,
                "start": (page - 1) * limit,
                "sort": sort_by,
    def get_pkg_dict(cls, resource, ldr):
        from ckan import model

        pkg_dict = OrderedDict()
        extras = OrderedDict()
        uri = str(resource.identifier)
        pkg_dict["title"] = unicode(resource[RDFS.label].next())
        extras["registry_uri"] = uri

        # Create or update?
        pkg = (
            model.Session.query(model.Package)
            .filter_by(state="active")
            .join(model.PackageExtra)
            .filter_by(state="active")
            .filter_by(key="registry_uri")
            .filter_by(value=uri)
            .first()
        )
        if pkg:
            pkg_dict["id"] = pkg.id
            pkg_dict["name"] = pkg.name
            action = "update"
        else:
            pkg_dict["id"] = unicode(uuid.uuid4())
            pkg_dict["name"] = cls._gen_new_name(pkg_dict["title"])
            action = "new"

        dgu_type = cls.get_dgu_type(resource)
        extras["data_standard_type"] = dgu_type

        resources = []
        for format_display, format_extension, format_dgu in (
            ("RDF ttl", "ttl", "RDF"),
            ("RDF/XML", "rdf", "RDF"),
            ("JSON-LD", "jsonld", "JSON"),
        ):
            url = uri + "?_format=%s" % format_extension
            resources.append(
                {
                    "description": "%s as %s" % (dgu_type, format_display),
                    "url": url,
                    "format": format_dgu,
                    "resource_type": "file",
                }
            )
            resources.append(
                {
                    "description": "%s and metadata as %s" % (dgu_type, format_display),
                    "url": url + METADATA_PARAM,
                    "format": format_dgu,
                    "resource_type": "file",
                }
            )

        pkg_dict["notes"] = unicode(resource[DCT.description].next())
        licence_url = str(resource[DCT.license].next())
        if "open-government-licence" in licence_url:
            pkg_dict["licence_id"] = "uk-ogl"
        else:
            extras["licence_url"] = licence_url
            # not sure how this will display as just as URL
        pkg_dict["owner_org"] = cls.get_publisher(resource).id
        resources.append(
            {
                "description": "Web page for this %s on a Linked Data Registry" % dgu_type,
                "url": uri,
                "format": "HTML",
                "resource_type": "documentation",
            }
        )
        metadata = cls.get_resource_metadata(uri)
        status = metadata[REG.status].next()
        extras["status"] = str(status).split("#")[-1]
        extras["harvested_version"] = str(metadata[OWL.versionInfo].next())
        extras["data_standard_type"] = dgu_type
        pkg_dict["type"] = "data-standard"

        pkg_dict["extras"] = [{"key": k, "value": v} for k, v in extras.items()]
        pkg_dict["resources"] = resources
        return pkg_dict, action
    def search(self):
        package_type = self._guess_package_type()

        try:
            context = {"model": model, "user": c.user or c.author, "auth_user_obj": c.userobj}
            check_access("site_read", context)
        except NotAuthorized:
            abort(401, _("Not authorized to see this page"))

        q = c.q = request.params.get("q", u"")
        c.query_error = False
        page = self._get_page_number(request.params)
        limit = g.datasets_per_page
        params_nopage = [(k, v) for k, v in request.params.items() if k != "page"]

        def drill_down_url(alternative_url=None, **by):
            return h.add_url_param(
                alternative_url=alternative_url, controller="package", action="search", new_params=by
            )

        c.drill_down_url = drill_down_url

        def remove_field(key, value=None, replace=None):
            return h.remove_url_param(key, value=value, replace=replace, controller="package", action="search")

        c.remove_field = remove_field

        sort_by = request.params.get("sort", None)
        params_nosort = [(k, v) for k, v in params_nopage if k != "sort"]

        def _sort_by(fields):
            params = params_nosort[:]
            if fields:
                sort_string = ", ".join("%s %s" % f for f in fields)
                params.append(("sort", sort_string))
            return search_url(params, package_type)

        c.sort_by = _sort_by
        if not sort_by:
            c.sort_by_fields = []
        else:
            c.sort_by_fields = [field.split()[0] for field in sort_by.split(",")]

        def pager_url(q=None, page=None):
            params = list(params_nopage)
            params.append(("page", page))
            return search_url(params, package_type)

        c.search_url_params = urlencode(_encode_params(params_nopage))

        try:
            c.fields = []
            c.fields_grouped = {}
            search_extras = {}
            fq = ""
            for (param, value) in request.params.items():
                if param not in ["q", "page", "sort"] and len(value) and not param.startswith("_"):
                    if not param.startswith("ext_"):
                        c.fields.append((param, value))
                        if param != "organization":
                            fq += ' %s:"%s"' % (param, value)
                        else:
                            fq += custom_organization_filter(value)
                        if param not in c.fields_grouped:
                            c.fields_grouped[param] = [value]
                        else:
                            c.fields_grouped[param].append(value)
                    else:
                        search_extras[param] = value

            context = {
                "model": model,
                "session": model.Session,
                "user": c.user or c.author,
                "for_view": True,
                "auth_user_obj": c.userobj,
            }

            if package_type and package_type != "dataset":
                fq += " +dataset_type:{type}".format(type=package_type)
            elif not asbool(config.get("ckan.search.show_all_types", "False")):
                fq += " +dataset_type:dataset"

            facets = OrderedDict()

            default_facet_titles = {
                "organization": _("Organizations"),
                "groups": _("Groups"),
                "tags": _("Tags"),
                "res_format": _("Formats"),
                "license_id": _("Licenses"),
            }

            for facet in g.facets:
                if facet in default_facet_titles:
                    facets[facet] = default_facet_titles[facet]
                else:
                    facets[facet] = facet

            for plugin in p.PluginImplementations(p.IFacets):
                facets = plugin.dataset_facets(facets, package_type)

            c.facet_titles = facets

            data_dict = {
                "q": q,
                "fq": fq.strip(),
                "facet.field": facets.keys(),
                "rows": limit,
                "start": (page - 1) * limit,
                "sort": sort_by,
                "extras": search_extras,
            }

            query = get_action("package_search")(context, data_dict)
            c.sort_by_selected = query["sort"]

            c.page = h.Page(
                collection=query["results"], page=page, url=pager_url, item_count=query["count"], items_per_page=limit
            )
            c.facets = query["facets"]
            c.search_facets = query["search_facets"]
            c.page.items = query["results"]
        except SearchError, se:
            log.error("Dataset search error: %r", se.args)
            c.query_error = True
            c.facets = {}
            c.search_facets = {}
            c.page = h.Page(collection=[])
    def show(self):
        # This is based on the CKAN package search controller
        # There are probably still some pieces we don't need
        # And using the facets to get the info we need is not ideal
        # because normal facet limits are then not applied on the page
        from ckan.lib.search import SearchError

        # unicode format (decoded from utf8)
        q = c.q = request.params.get("q", u"")
        c.query_error = False

        def remove_field(key, value=None, replace=None):
            return h.remove_url_param(key, value=value, replace=replace, controller="package", action="search")

        c.remove_field = remove_field

        params_nopage = [(k, v) for k, v in request.params.items()]

        def pager_url(q=None, page=None):
            params = list(params_nopage)
            return self.search_url(params, "dataset")

        c.search_url_params = urlencode(self._encode_params(params_nopage))

        try:
            c.fields = []
            # c.fields_grouped will contain a dict of params containing
            # a list of values eg {'tags':['tag1', 'tag2']}
            c.fields_grouped = {}
            search_extras = {}
            fq = ""
            for (param, value) in request.params.items():
                if param not in ["q", "page", "sort"] and len(value) and not param.startswith("_"):
                    if not param.startswith("ext_"):
                        c.fields.append((param, value))
                        fq += ' %s:"%s"' % (param, value)
                        if param not in c.fields_grouped:
                            c.fields_grouped[param] = [value]
                        else:
                            c.fields_grouped[param].append(value)
                    else:
                        search_extras[param] = value

            context = {
                "model": model,
                "session": model.Session,
                "user": c.user or c.author,
                "for_view": True,
                "auth_user_obj": c.userobj,
            }

            facets = OrderedDict()

            default_facet_titles = {
                "organization": _("Organizations"),
                "groups": _("Groups"),
                "tags": _("Tags"),
                "res_format": _("Formats"),
                "license_id": _("Licenses"),
            }

            for facet in g.facets:
                if facet in default_facet_titles:
                    facets[facet] = default_facet_titles[facet]
                else:
                    facets[facet] = facet

            # Facet titles
            for plugin in p.PluginImplementations(p.IFacets):
                facets = plugin.dataset_facets(facets, "dataset")

            c.facet_titles = facets

            # We use the organization facet to get the list of organizations detected for this query
            # The actual data is irrelevant
            data_dict = {
                "q": q,
                "fq": fq.strip(),
                "facet.field": facets.keys(),
                "facet.limit": -1,
                "extras": search_extras,
                "rows": 1,
            }

            query = get_action("package_search")(context, data_dict)

            orglist = query["facets"]["organization"].keys()

            # Now get the data concerning the orgs
            q = Session.query(Group).filter(Group.name.in_(orglist))

            values = []
            qres = q.all()

            # Combine in extras, add counts
            # Make the data look like what we get with a org search
            for d in qres:
                dobj = d.as_dict()
                dobj["extras"] = d.extras
                dobj["package_count"] = query["facets"]["organization"][dobj["name"]]
                values.append(dobj)

            c.page = h.Page(collection=query["results"], url=pager_url, item_count=query["count"])
            c.facets = query["facets"]
            c.search_facets = query["search_facets"]
            c.page.items = query["results"]
        except SearchError, se:
            log.error("Dataset search (map) error: %r", se.args)
            c.query_error = True
            c.facets = {}
            c.search_facets = {}
    def search(self):
        from ckan.lib.search import SearchError

        package_type = self._guess_package_type()

        try:
            context = {"model": model, "user": c.user or c.author, "auth_user_obj": c.userobj}
            check_access("site_read", context)
        except NotAuthorized:
            abort(401, _("Not authorized to see this page"))

        # unicode format (decoded from utf8)
        q = c.q = request.params.get("q", u"")
        c.query_error = False
        page = self._get_page_number(request.params)

        limit = g.datasets_per_page

        # most search operations should reset the page counter:
        params_nopage = [(k, v) for k, v in request.params.items() if k != "page"]

        def drill_down_url(alternative_url=None, **by):
            return h.add_url_param(
                alternative_url=alternative_url, controller="package", action="search", new_params=by
            )

        c.drill_down_url = drill_down_url

        def remove_field(key, value=None, replace=None):
            return h.remove_url_param(key, value=value, replace=replace, controller="package", action="search")

        c.remove_field = remove_field

        sort_by = request.params.get("sort", None)
        params_nosort = [(k, v) for k, v in params_nopage if k != "sort"]

        def _sort_by(fields):
            """
            Sort by the given list of fields.

            Each entry in the list is a 2-tuple: (fieldname, sort_order)

            eg - [('metadata_modified', 'desc'), ('name', 'asc')]

            If fields is empty, then the default ordering is used.
            """
            params = params_nosort[:]

            if fields:
                sort_string = ", ".join("%s %s" % f for f in fields)
                params.append(("sort", sort_string))
            return search_url(params, package_type)

        c.sort_by = _sort_by
        if sort_by is None:
            c.sort_by_fields = []
        else:
            c.sort_by_fields = [field.split()[0] for field in sort_by.split(",")]

        def pager_url(q=None, page=None):
            params = list(params_nopage)
            params.append(("page", page))
            return search_url(params, package_type)

        c.search_url_params = urlencode(_encode_params(params_nopage))
        api_search_url_params = None

        try:
            c.fields = []
            # c.fields_grouped will contain a dict of params containing
            # a list of values eg {'tags':['tag1', 'tag2']}
            c.fields_grouped = {}
            search_extras = {}
            fq = ""
            for (param, value) in request.params.items():
                if param not in ["q", "page", "sort"] and len(value) and not param.startswith("_"):
                    if not param.startswith("ext_"):
                        c.fields.append((param, value))
                        fq += ' %s:"%s"' % (param, value)
                        if param not in c.fields_grouped:
                            c.fields_grouped[param] = [value]
                        else:
                            c.fields_grouped[param].append(value)
                    else:
                        search_extras[param] = value

            context = {
                "model": model,
                "session": model.Session,
                "user": c.user or c.author,
                "for_view": True,
                "auth_user_obj": c.userobj,
            }

            if package_type and package_type != "dataset":
                # Only show datasets of this particular type
                fq += " +dataset_type:{type}".format(type=package_type)
            else:
                # Unless changed via config options, don't show non standard
                # dataset types on the default search page
                if not asbool(config.get("ckan.search.show_all_types", "False")):
                    fq += " +dataset_type:dataset"

            facets = OrderedDict()

            default_facet_titles = {
                "organization": _("Organizations"),
                "groups": _("Groups"),
                "tags": _("Tags"),
                "res_format": _("Formats"),
                "license_id": _("Licenses"),
            }

            for facet in g.facets:
                if facet in default_facet_titles:
                    facets[facet] = default_facet_titles[facet]
                else:
                    facets[facet] = facet

            # Facet titles
            for plugin in p.PluginImplementations(p.IFacets):
                facets = plugin.dataset_facets(facets, package_type)

            c.facet_titles = facets

            data_dict = {
                "q": q,
                "fq": fq.strip(),
                "facet.field": facets.keys(),
                "rows": limit,
                "start": (page - 1) * limit,
                "sort": sort_by,
                "extras": search_extras,
            }

            ##### EXTENDING ORIGINAL <<<<<<<<<<
            # API Params
            api_url_params = {"q": q, "fq": fq.strip(), "rows": limit, "start": (page - 1) * limit}
            if sort_by:
                api_url_params["sort"] = sort_by
            if facets.keys():
                api_url_params["facet.field"] = json.dumps(facets.keys())
            # if search_extras:
            #      api_url_params['extras'] = ','.join(search_extras)

            api_search_url_params = urlencode(_encode_params(api_url_params.items()))
            ##### EXTENDING ORIGINAL >>>>>>>>>>>>>>

            query = get_action("package_search")(context, data_dict)
            c.sort_by_selected = query["sort"]

            c.page = h.Page(
                collection=query["results"], page=page, url=pager_url, item_count=query["count"], items_per_page=limit
            )
            c.facets = query["facets"]
            c.search_facets = query["search_facets"]
            c.page.items = query["results"]
        except SearchError, se:
            log.error("Dataset search error: %r", se.args)
            c.query_error = True
            c.facets = {}
            c.search_facets = {}
            c.page = h.Page(collection=[])
    def search(self):
        from ckan.lib.search import SearchError

        package_type = self._guess_package_type()

        if package_type == "search":
            package_type = "dataset"

        try:
            context = {"model": model, "user": c.user or c.author, "auth_user_obj": c.userobj}
            check_access("site_read", context)
        except NotAuthorized:
            abort(401, _("Not authorized to see this page"))

        # unicode format (decoded from utf8)
        q = c.q = request.params.get("q", u"")
        c.query_error = False

        page = self._page_number()

        params_nopage = self._params_nopage()

        # Commenting below parts as it doesn't seem to be used
        # def drill_down_url(alternative_url=None, **by):
        #     return h.add_url_param(alternative_url=alternative_url,
        #                            controller='package', action='search',
        #                            new_params=by)
        #
        # c.drill_down_url = drill_down_url

        self._set_remove_field_function()

        sort_by = request.params.get("sort", None)
        params_nosort = [(k, v) for k, v in params_nopage if k != "sort"]

        def _sort_by(fields):
            """
            Sort by the given list of fields.

            Each entry in the list is a 2-tuple: (fieldname, sort_order)

            eg - [('metadata_modified', 'desc'), ('name', 'asc')]

            If fields is empty, then the default ordering is used.
            """
            params = params_nosort[:]

            if fields:
                sort_string = ", ".join("%s %s" % f for f in fields)
                params.append(("sort", sort_string))
            return self._search_url(params, package_type)

        c.sort_by = _sort_by
        if not sort_by:
            c.sort_by_fields = []
        else:
            c.sort_by_fields = [field.split()[0] for field in sort_by.split(",")]

        def pager_url(q=None, page=None):
            params = list(params_nopage)
            params.append(("page", page))
            return self._search_url(params, package_type)

        c.search_url_params = urlencode(_encode_params(params_nopage))
        self._set_other_links()

        try:
            c.fields = []
            # c.fields_grouped will contain a dict of params containing
            # a list of values eg {'tags':['tag1', 'tag2']}
            c.fields_grouped = {}
            search_extras = {}
            # limit = g.datasets_per_page

            fq = ""
            for (param, value) in request.params.items():
                if param not in ["q", "page", "sort"] and len(value) and not param.startswith("_"):
                    if not param.startswith("ext_"):
                        c.fields.append((param, value))
                        fq += ' %s:"%s"' % (param, value)
                        if param not in c.fields_grouped:
                            c.fields_grouped[param] = [value]
                        else:
                            c.fields_grouped[param].append(value)
                    else:
                        search_extras[param] = value

            self._set_filters_are_selected_flag()

            limit = self._allowed_num_of_items(search_extras)

            context = {
                "model": model,
                "session": model.Session,
                "user": c.user or c.author,
                "for_view": True,
                "auth_user_obj": c.userobj,
            }

            if package_type and package_type != "dataset":
                # Only show datasets of this particular type
                fq += " +dataset_type:{type}".format(type=package_type)
            else:
                # Unless changed via config options, don't show non standard
                # dataset types on the default search page
                if not asbool(config.get("ckan.search.show_all_types", "False")):
                    fq += " +dataset_type:dataset"

            facets = OrderedDict()

            default_facet_titles = {
                "organization": _("Organizations"),
                "groups": _("Groups"),
                "tags": _("Tags"),
                "res_format": _("Formats"),
                "license_id": _("Licenses"),
            }

            for facet in g.facets:
                if facet in default_facet_titles:
                    facets[facet] = default_facet_titles[facet]
                else:
                    facets[facet] = facet

            # Facet titles
            for plugin in p.PluginImplementations(p.IFacets):
                facets = plugin.dataset_facets(facets, package_type)

            c.facet_titles = facets

            self._which_tab_is_selected(search_extras)
            self._performing_search(q, fq, facets.keys(), limit, page, sort_by, search_extras, pager_url, context)

        except SearchError, se:
            log.error("Dataset search error: %r", se.args)
            c.query_error = True
            c.facets = {}
            c.search_facets = {}
            c.page = h.Page(collection=[])