Exemplo n.º 1
0
    def __init__(self, **kwargs):
        from ckan.lib.search import DEFAULT_OPTIONS

        # set values according to the defaults
        for option_name, default_value in DEFAULT_OPTIONS.items():
            if not option_name in self:
                self[option_name] = default_value

        super(QueryOptions, self).__init__(**kwargs)
Exemplo n.º 2
0
 def __init__(self, **kwargs):
     from ckan.lib.search import DEFAULT_OPTIONS
     
     # set values according to the defaults
     for option_name, default_value in DEFAULT_OPTIONS.items():
         if not option_name in self:
             self[option_name] = default_value
     
     super(QueryOptions, self).__init__(**kwargs)
Exemplo n.º 3
0
                return self._finish_bad_request(
                    gettext('Could not read parameters: %r' % e))

            # if using API v2, default to returning the package ID if
            # no field list is specified
            if register in ['dataset', 'package'] and not params.get('fl'):
                params['fl'] = 'id' if ver == '2' else 'name'

            try:
                if register == 'resource': 
                    query = query_for(model.Resource)

                    # resource search still uses ckan query parser
                    options = QueryOptions()
                    for k, v in params.items():
                        if (k in DEFAULT_OPTIONS.keys()):
                            options[k] = v
                    options.update(params)
                    options.username = c.user
                    options.search_tags = False
                    options.return_objects = False
                    query_fields = MultiDict()
                    for field, value in params.items():
                        field = field.strip()
                        if field in DEFAULT_OPTIONS.keys() or \
                           field in IGNORE_FIELDS:
                            continue
                        values = [value]
                        if isinstance(value, list):
                            values = value
                        for v in values:
Exemplo n.º 4
0
                return self._finish_bad_request(
                    gettext('Could not read parameters: %r' % e))

            # if using API v2, default to returning the package ID if
            # no field list is specified
            if register in ['dataset', 'package'] and not params.get('fl'):
                params['fl'] = 'id' if ver == '2' else 'name'

            try:
                if register == 'resource':
                    query = query_for(model.Resource)

                    # resource search still uses ckan query parser
                    options = QueryOptions()
                    for k, v in params.items():
                        if (k in DEFAULT_OPTIONS.keys()):
                            options[k] = v
                    options.update(params)
                    options.username = c.user
                    options.search_tags = False
                    options.return_objects = False
                    query_fields = MultiDict()
                    for field, value in params.items():
                        field = field.strip()
                        if field in DEFAULT_OPTIONS.keys() or \
                           field in IGNORE_FIELDS:
                            continue
                        values = [value]
                        if isinstance(value, list):
                            values = value
                        for v in values:
Exemplo n.º 5
0
            except ValueError, e:
                return self._finish_bad_request(gettext("Could not read parameters: %r" % e))

            # if using API v2, default to returning the package ID if
            # no field list is specified
            if register in ["dataset", "package"] and not params.get("fl"):
                params["fl"] = "id" if ver == "2" else "name"

            try:
                if register == "resource":
                    query = query_for(model.Resource)

                    # resource search still uses ckan query parser
                    options = QueryOptions()
                    for k, v in params.items():
                        if k in DEFAULT_OPTIONS.keys():
                            options[k] = v
                    options.update(params)
                    options.username = c.user
                    options.search_tags = False
                    options.return_objects = False
                    query_fields = MultiDict()
                    for field, value in params.items():
                        field = field.strip()
                        if field in DEFAULT_OPTIONS.keys() or field in IGNORE_FIELDS:
                            continue
                        values = [value]
                        if isinstance(value, list):
                            values = value
                        for v in values:
                            query_fields.add(field, v)