def getConfig(self): """get the config""" registry = getUtility(IRegistry) # First grab the base config, so we can use the operations registryreader = IQuerystringRegistryReader(registry) registryreader.prefix = "plone.app.querystring.operation" op_config = registryreader.parseRegistry() # Then combine our fields registryreader = IQuerystringRegistryReader(registry) registryreader.prefix = "bika.lims.bika_catalog_query" config = registryreader.parseRegistry() config = registryreader.getVocabularyValues(config) config.update(op_config) registryreader.mapOperations(config) registryreader.mapSortableIndexes(config) config = { 'indexes': config.get('bika.lims.bika_catalog_query.field'), 'sortable_indexes': config.get('sortable'), } # Group indices by "group", order alphabetically groupedIndexes = {} for indexName in config['indexes']: index = config['indexes'][indexName] if index['enabled']: group = index['group'] if group not in groupedIndexes: groupedIndexes[group] = [] groupedIndexes[group].append((index['title'], indexName)) # Sort each index list [a.sort() for a in groupedIndexes.values()] config['groupedIndexes'] = groupedIndexes return config
def getConfig(self): """get the config""" registry = getUtility(IRegistry) prefix = self.registry_prefix if prefix is not None: # First grab the base config's operations registryreader = IQuerystringRegistryReader(registry) registryreader.prefix = "plone.app.querystring.operation" plone_config = registryreader.parseRegistry() # then merge custom fields registryreader = IQuerystringRegistryReader(registry) registryreader.prefix = prefix config = registryreader.parseRegistry() config = registryreader.getVocabularyValues(config) config.update(plone_config) config = registryreader.mapOperations(config) config = registryreader.mapSortableIndexes(config) config = { 'indexes': config.get(prefix + '.field'), 'sortable_indexes': config.get('sortable'), } else: # First grab the base config's operations registryreader = IQuerystringRegistryReader(registry) registryreader.prefix = "plone.app.querystring" config = registryreader() # Group indices by "group", order alphabetically groupedIndexes = {} for indexName in config['indexes']: index = config['indexes'][indexName] if index['enabled']: group = index['group'] if group not in groupedIndexes: groupedIndexes[group] = [] groupedIndexes[group].append((index['title'], indexName)) # Sort each index list [a.sort() for a in groupedIndexes.values()] config['groupedIndexes'] = groupedIndexes return config
def __call__(self): """Return the registry configuration in JSON format""" registry = getUtility(IRegistry) # First grab the base config, so we can use the operations registryreader = IQuerystringRegistryReader(registry) registryreader.prefix = "plone.app.querystring.operation" op_config = registryreader.parseRegistry() # Then combine our fields registryreader = IQuerystringRegistryReader(registry) registryreader.prefix = self.prefix config = registryreader.parseRegistry() config = registryreader.getVocabularyValues(config) config.update(op_config) registryreader.mapOperations(config) registryreader.mapSortableIndexes(config) return { 'indexes': config.get(self.prefix + '.field'), 'sortable_indexes': config.get('sortable'), }