Пример #1
0
 def search(self, query_string):
     query = self.base_query.copy()
     if query_string == '':
         if self.default_query is not None:
             query.update(parse_query(self.default_query, self.portal_path))
         else:
             return []
     else:
         query.update(parse_query(query_string, self.portal_path))
     try:
         results = (x.getPath()[len(self.portal_path):]
                    for x in self.catalog(**query))
     except ParseError:
         return []
     return results
Пример #2
0
    def __call__(self):
        query = self.request.get('q', None)

        # Vamos a crear nuestro propio filtro y a ignorar el funcionamiento
        # de AutocompleteSearch
        if query:
            # Si hay una query, actualizamos el valor para filtrar solo
            # en la carpeta 'articulos'
            query += ' path:/articulos'
        else:
            return ''

        portal_tool = getToolByName(self.context.form.context, "portal_url")
        portal_path = portal_tool.getPortalPath()

        custom_query = parse_query(query, portal_path)
        custom_query.update({'portal_type': ['collective.nitf.content'],
                             'sort_on': 'modified',
                             'sort_order': 'reverse',
                             'review_state': 'published'})

        portal_catalog = getToolByName(self.context.form.context,
                                       "portal_catalog")

        brains = portal_catalog(**custom_query)

        source = self.context.bound_source
        results = (source.getTermByBrain(brain, real_value=False)
                   for brain in brains)

        return '\n'.join(["%s|%s" % (t.token, t.title or t.token)
                            for t in results])
Пример #3
0
 def getRelated(self, query='', limit=None):
     portal_tool = getToolByName(self.context, "portal_url")
     portal_path = portal_tool.getPortalPath()
     source = self.bound_source
     catalog_query = source.selectable_filter.criteria.copy()
     catalog_query.update(parse_query(query, portal_path))
     catalog_query['sort_on'] = 'created'
     catalog_query['sort_order'] = 'descending'
     if limit and 'sort_limit' not in catalog_query:
         catalog_query['sort_limit'] = limit
     results = source.catalog(**catalog_query)
     return results
Пример #4
0
    def search(self, query, limit=20):
        catalog_query = self.selectable_filter.criteria.copy()
        catalog_query.update(parse_query(query, self.portal_path))

        if limit and 'sort_limit' not in catalog_query:
            catalog_query['sort_limit'] = limit

        try:
            for brain in self.catalog(**catalog_query)[:limit]:
                yield self.getTermByBrain(brain, real_value=False)
        except ParseError:
            pass
 def getRelated(self, query='', limit=None):
     portal_tool = getToolByName(self.context, "portal_url")
     portal_path = portal_tool.getPortalPath()
     source = self.bound_source
     catalog_query = source.selectable_filter.criteria.copy()
     catalog_query.update(parse_query(query, portal_path))
     catalog_query['sort_on'] = 'created'
     catalog_query['sort_order'] = 'descending'
     if limit and 'sort_limit' not in catalog_query:
         catalog_query['sort_limit'] = limit
     results = source.catalog(**catalog_query)
     return results
    def search(self, query, limit=20):
        catalog_query = self.selectable_filter.criteria.copy()
        catalog_query.update(parse_query(query, self.portal_path))

        if limit and 'sort_limit' not in catalog_query:
            catalog_query['sort_limit'] = limit

        try:
            for brain in self.catalog(**catalog_query)[:limit]:
                yield self.getTermByBrain(brain, real_value=False)
        except ParseError:
            pass
    def search(self, query='', limit=None):
        portal_tool = getToolByName(self.context, "portal_url")
        self.portal_path = portal_tool.getPortalPath()
        source = self.context.bound_source
        catalog_query = source.selectable_filter.criteria.copy()
        catalog_query.update(parse_query(query, self.portal_path))

        if limit and 'sort_limit' not in catalog_query:
            catalog_query['sort_limit'] = limit

        results =  source.catalog(**catalog_query)
        return results
    def search(self, query_string):
        results = super(GallerySearchableTextSource, self).search(query_string)
        utils = getToolByName(self.context, "plone_utils")
        query = self.base_query.copy()
        if query_string == "":
            if self.default_query is not None:
                query.update(parse_query(self.default_query, self.portal_path))
        else:
            query.update(parse_query(query_string, self.portal_path))
        try:
            results = self.catalog(**query)
        except:
            results = []

        utils = getToolByName(self.context, "plone_utils")
        for result in results:
            try:
                if utils.browserDefault(result.getObject())[1][0] == "galleryview":
                    yield result.getPath()[len(self.portal_path) :]
            except:
                pass
    def search(self, query_string):
        results = super(GallerySearchableTextSource, self).search(query_string)
        utils = getToolByName(self.context, 'plone_utils')
        query = self.base_query.copy()
        if query_string == '':
            if self.default_query is not None:
                query.update(parse_query(self.default_query, self.portal_path))
        else:
            query.update(parse_query(query_string, self.portal_path))
        try:
            results = self.catalog(**query)
        except:
            results = []

        utils = getToolByName(self.context, 'plone_utils')
        for result in results:
            try:
                if utils.browserDefault(result.getObject())[1][0] ==\
                                                        "galleryview":
                    yield result.getPath()[len(self.portal_path):]
            except:
                pass
Пример #10
0
def search(self, query_string):
    query = self.base_query.copy()
    if query_string == '':
        if self.default_query is not None:
            query.update(parse_query(self.default_query, self.portal_path))
        else:
            return []
    else:
        query.update(parse_query(query_string, self.portal_path))

    # Fix :
    query['Language'] = 'all'

    try:
        results = (x.getPath()[len(self.portal_path):] for x in self.catalog(**query))
    except ParseError:
        return []

    if query.has_key('path'):
        path = query['path']['query'][len(self.portal_path):]
        if path != '':
            return itertools.chain((path, ), results)
    return results
    def search(self, query_string):
        results = super(GallerySearchableTextSource, self).search(query_string)
        nav_root = api.portal.get_navigation_root(self.context)
        nav_root_path = '/'.join(nav_root.getPhysicalPath())
        query = self.base_query.copy()
        if query_string == '':
            if self.default_query is not None:
                query.update(parse_query(self.default_query, nav_root_path))
        else:
            query.update(parse_query(query_string, nav_root_path))
        try:
            results = self.catalog(**query)
        except:
            results = []

        utils = getToolByName(self.context, 'plone_utils')
        for result in results:
            try:
                if utils.browserDefault(result.getObject())[1][0] ==\
                        "galleryview":
                    yield result.getPath()[len(self.portal_path):]
            except:
                pass
Пример #12
0
    def __call__(self, query=None, offset=0):
        base_query = {'portal_type': 'collective.nitf.content',
                      'sort_on': 'modified',
                      'sort_order': 'reverse',
                      'review_state': 'published'}

        if query:
            base_query.update(parse_query(query))

        result = self.context.render_tree(relPath='articulos',
                                          query=base_query,
                                          limit=10,
                                          offset=int(offset))

        return result.strip()
    def search(self, query, limit=20):
        catalog_query = self.selectable_filter.criteria.copy()
        catalog_query.update(parse_query(query, self.portal_path))

        if limit and 'sort_limit' not in catalog_query:
            catalog_query['sort_limit'] = limit

        try:
            results = []
            for brain in self.catalog(**catalog_query):
                if brain.portal_type not in COMPILATION_TYPES:
                    results.append(self.getTermByBrain(brain, real_value=False))
        except ParseError:
            return []

        return results
Пример #14
0
    def search(self, query, limit=20):
        catalog_query = self.selectable_filter.criteria.copy()
        catalog_query.update(parse_query(query, self.portal_path))

        if limit and 'sort_limit' not in catalog_query:
            catalog_query['sort_limit'] = limit

        try:
            results = []
            for brain in self.catalog(**catalog_query):
                if brain.portal_type not in COMPILATION_TYPES:
                    results.append(self.getTermByBrain(brain,
                                                       real_value=False))
        except ParseError:
            return []

        return results
Пример #15
0
    def search(self, query='', limit=None, offset=0):
        portal_tool = getToolByName(self.context, "portal_url")
        self.portal_path = portal_tool.getPortalPath()
        source = self.context.bound_source
        catalog_query = source.selectable_filter.criteria.copy()
        catalog_query.update(parse_query(query, self.portal_path))
        catalog_query['sort_on'] = 'created'
        catalog_query['sort_order'] = 'descending'

        if limit and 'sort_limit' not in catalog_query and offset == 0:
            catalog_query['sort_limit'] = limit
        elif limit and 'sort_limit' not in catalog_query:
            catalog_query['sort_limit'] = offset + limit

        results = source.catalog(**catalog_query)
        if offset != 0:
            results = results[offset:(offset + limit)]
        return results
    def search(self, query='', limit=None, offset=0):
        portal_tool = getToolByName(self.context, "portal_url")
        self.portal_path = portal_tool.getPortalPath()
        source = self.context.bound_source
        catalog_query = source.selectable_filter.criteria.copy()
        catalog_query.update(parse_query(query, self.portal_path))
        catalog_query['sort_on'] = 'created'
        catalog_query['sort_order'] = 'descending'

        if limit and 'sort_limit' not in catalog_query and offset == 0:
            catalog_query['sort_limit'] = limit
        elif limit and 'sort_limit' not in catalog_query:
            catalog_query['sort_limit'] = offset + limit

        results = source.catalog(**catalog_query)
        if offset != 0:
            results = results[offset:(offset + limit)]
        return results