def search_results(self):
        """Search the registry.
        """
        inspector = RegistryInspector(getSiteManager().adapters)

        iface_name = self.request.get('interface')
        provided = resolve(iface_name)
        name = self.request.get('name')

        descriminators = []
        desc_keys = filter(lambda x: x.startswith('descriminator:'),
                           self.request.form.keys())
        desc_keys.sort()
        any_positive = False
        for key in desc_keys:
            value = self.request.form.get(key, None)
            if value:
                descriminators.append(resolve(value))
                any_positive = True
            else:
                descriminators.append(None)

        if not any_positive:
            descriminators = ()

        adapters = inspector.get_adapters(provided, descriminators, name)

        renderer = TableRenderer(self.context, self.request)
        return renderer(adapters, show_descriminators=True)
 def search_interface(self):
     """Search an interface dotted name with autocomplete.
     """
     inspector = RegistryInspector(getSiteManager().utilities)
     query = self.request.get('q')
     names = inspector.get_provided_names(0)
     results = utils.ac_search(query, names)
     return '\n'.join(results)
    def search_name(self):
        """Search the name of a utility.
        """
        inspector = RegistryInspector(getSiteManager().utilities)

        iface_name = self.request.get('iface', None)
        query = self.request.get('q')
        provided = resolve(iface_name)

        names = inspector.get_names(provided, 0)
        results = utils.ac_search(query, names)
        return '\n'.join(results)
    def search_results(self):
        """Search the registry.
        """
        inspector = RegistryInspector(getSiteManager().utilities)

        iface_name = self.request.get('interface')
        provided = resolve(iface_name)
        name = self.request.get('name')

        adapters = inspector.get_adapters(provided, (), name)

        renderer = TableRenderer(self.context, self.request)
        return renderer(adapters, show_descriminators=False)
    def search_for(self):
        """Search for interface name.
        """
        inspector = RegistryInspector(getSiteManager().adapters)

        iface_name = self.request.get('iface', None)
        provided = resolve(iface_name)
        name = self.request.get('name')
        level = int(self.request.get('level'))
        query = self.request.get('q')

        names = inspector.get_keys_at_level(level, provided, name)
        results = utils.ac_search(query, names)
        return '\n'.join(results)
    def _list_components(self, registry, name=None, provided_name=None,
                         format='as_dict'):
        inspector = RegistryInspector(registry)
        components = inspector.get_adapters(
            name=name,
            provided=resolve(provided_name))

        data = []
        for comp in components:
            data.append(getattr(comp, format)())

        if format == 'as_dict':
            return json.dumps(data)

        elif format == 'as_text':
            return '\n\n'.join(data)
 def utility_provided_names(self):
     """Returns a list of utility provided interface names as string.
     """
     inspector = RegistryInspector(getSiteManager().utilities)
     return json.dumps(list(sorted(inspector.get_provided_names())))
 def utility_names(self):
     """Returns a list of utility names.
     """
     inspector = RegistryInspector(getSiteManager().utilities)
     return json.dumps(list(sorted(inspector.get_names())))
 def adapter_provided_names(self):
     """Returns a list of adapter provided interface names as string.
     """
     inspector = RegistryInspector(getSiteManager().adapters)
     return json.dumps(list(sorted(inspector.get_provided_names())))
 def adapter_names(self):
     """Returns a list of adapter names.
     """
     inspector = RegistryInspector(getSiteManager().adapters)
     return json.dumps(list(sorted(inspector.get_names())))