コード例 #1
0
    def getCriterias(self, locales, q=None):
        '''
        @see: QueryCriteriaService.getCriterias
        '''
        locales = self._localesOf(locales)

        queryCriterias = list()

        for key, metaInfos in self.queryIndexer.metaInfoByCriteria.items():
            types = ''.join([
                (self.queryIndexer.typesByMetaInfo[metaInfo.__name__] + '-')
                for metaInfo in metaInfos
            ])
            criteria = self.queryIndexer.infoCriterias[key]
            queryCriterias.append(
                QueryCriteria('qi.' + key, criteria.__name__, types, key))

        for key, metaDatas in self.queryIndexer.metaDataByCriteria.items():
            types = ''.join([
                (self.queryIndexer.typesByMetaData[metaData.__name__] + '-')
                for metaData in metaDatas
            ])
            criteria = self.queryIndexer.dataCriterias[key]
            queryCriterias.append(
                QueryCriteria('qd.' + key, criteria.__name__, types, key))

        if q:
            queryCriterias = processQuery(queryCriterias, q, QueryCriteria)

        return queryCriterias
コード例 #2
0
ファイル: component.py プロジェクト: AtomLaw/Ally-Py
    def getComponents(self, offset=None, limit=None, q=None):
        '''
        @see: IComponentService.getComponents
        '''
        modules = modulesIn('%s.*' % self.package).asList()
        modules.sort()
        components = (self.componentFor(module) for module in modules)
        length = len(modules)
        if q:
            assert isinstance(q, QComponent), 'Invalid query %s' % q
            components = processQuery(components, q, Component)
            length = len(components)

        return IterPart(trimIter(components, length, offset, limit), length, offset, limit)
コード例 #3
0
ファイル: country.py プロジェクト: adityaathalye/Superdesk
 def getAllAvailable(self, locales, offset=None, limit=None, q=None):
     '''
     @see: ILanguageService.getAllAvailable
     '''
     locales = self._localesOf(locales)
     if q:
         countries = (Country(code, self._translate(code, locales)) for code in self.countries)
         countries = processQuery(countries, q, Country)
         length = len(countries)
         countries = trimIter(countries, length, offset, limit)
     else:
         length = len(self.countries)
         countries = trimIter(self.countries, length, offset, limit)
         countries = (Country(code, self._translate(code, locales)) for code in countries)
     return IterPart(countries, length, offset, limit)
コード例 #4
0
    def getComponents(self, offset=None, limit=None, q=None):
        '''
        @see: IComponentService.getComponents
        '''
        modules = modulesIn('%s.*' % self.package).asList()
        modules.sort()
        components = (self.componentFor(module) for module in modules)
        length = len(modules)
        if q:
            assert isinstance(q, QComponent), 'Invalid query %s' % q
            components = processQuery(components, q, Component)
            length = len(components)

        return IterPart(trimIter(components, length, offset, limit), length,
                        offset, limit)
コード例 #5
0
ファイル: language.py プロジェクト: ahilles107/Superdesk
 def getAllAvailable(self, locales, offset=None, limit=None, q=None):
     '''
     @see: ILanguageService.getAllAvailable
     '''
     locales = self._localesOf(locales)
     if q:
         languages = (self._populate(Language(code), self._translator(locale, locales))
                      for code, locale in self._locales.items())
         languages = processQuery(languages, q, Language)
         length = len(languages)
         languages = trimIter(languages, length, offset, limit)
     else:
         length = len(self._locales)
         languages = trimIter(self._locales.items(), length, offset, limit)
         languages = (self._populate(Language(code), self._translator(locale, locales))
                      for code, locale in languages)
     return IterPart(languages, length, offset, limit)
コード例 #6
0
 def getAllAvailable(self, locales, offset=None, limit=None, q=None):
     '''
     @see: ILanguageService.getAllAvailable
     '''
     locales = self._localesOf(locales)
     if q:
         countries = (Country(code, self._translate(code, locales))
                      for code in self.countries)
         countries = processQuery(countries, q, Country)
         length = len(countries)
         countries = trimIter(countries, length, offset, limit)
     else:
         length = len(self.countries)
         countries = trimIter(self.countries, length, offset, limit)
         countries = (Country(code, self._translate(code, locales))
                      for code in countries)
     return IterPart(countries, length, offset, limit)
コード例 #7
0
ファイル: language.py プロジェクト: patriciagarcia/Live-Blog
 def getAllAvailable(self, locales, offset=None, limit=None, q=None):
     '''
     @see: ILanguageService.getAllAvailable
     '''
     locales = self._localesOf(locales)
     if q:
         languages = (self._populate(Language(code), self._translator(locale, locales))
                      for code, locale in self._locales.items())
         languages = processQuery(languages, q, Language)
         length = len(languages)
         languages = trimIter(languages, length, offset, limit)
     else:
         length = len(self._locales)
         languages = trimIter(self._locales.items(), length, offset, limit)
         languages = (self._populate(Language(code), self._translator(locale, locales))
                      for code, locale in languages)
     return IterPart(languages, length, offset, limit)
コード例 #8
0
    def getCriterias(self, locales, q=None):
        '''
        @see: QueryCriteriaService.getCriterias
        '''
        locales = self._localesOf(locales)

        queryCriterias = list()

        for key, criteria in self.queryIndexer.infoCriterias.items():
            queryCriterias.append(QueryCriteria(key, criteria.__name__, key))#TODO: self._translate(key, locales)))

        for key, criteria in self.queryIndexer.dataCriterias.items():
            queryCriterias.append(QueryCriteria('qd.' + key, criteria.__name__, key))#TODO: self._translate(key, locales)))

        if q:
            queryCriterias = processQuery(queryCriterias, q, QueryCriteria)

        return queryCriterias
コード例 #9
0
ファイル: query_criteria.py プロジェクト: AtomLaw/Superdesk
    def getCriterias(self, locales, q=None):
        '''
        @see: QueryCriteriaService.getCriterias
        '''
        locales = self._localesOf(locales)

        queryCriterias = list()

        for key, metaInfos in self.queryIndexer.metaInfoByCriteria.items():
            types = ''.join([(self.queryIndexer.typesByMetaInfo[metaInfo.__name__] + '-') for metaInfo in metaInfos])
            criteria = self.queryIndexer.infoCriterias[key]
            queryCriterias.append(QueryCriteria('qi.' + key, criteria.__name__, types, key))

        for key, metaDatas in self.queryIndexer.metaDataByCriteria.items():
            types = ''.join([(self.queryIndexer.typesByMetaData[metaData.__name__] + '-') for metaData in metaDatas])
            criteria = self.queryIndexer.dataCriterias[key]
            queryCriterias.append(QueryCriteria('qd.' + key, criteria.__name__, types, key))

        if q:
            queryCriterias = processQuery(queryCriterias, q, QueryCriteria)

        return queryCriterias
コード例 #10
0
    def getCriterias(self, locales, q=None):
        '''
        @see: QueryCriteriaService.getCriterias
        '''
        locales = self._localesOf(locales)

        queryCriterias = list()

        for key, criteria in self.queryIndexer.infoCriterias.items():
            queryCriterias.append(
                QueryCriteria(key, criteria.__name__,
                              key))  #TODO: self._translate(key, locales)))

        for key, criteria in self.queryIndexer.dataCriterias.items():
            queryCriterias.append(
                QueryCriteria('qd.' + key, criteria.__name__,
                              key))  #TODO: self._translate(key, locales)))

        if q:
            queryCriterias = processQuery(queryCriterias, q, QueryCriteria)

        return queryCriterias