def __call__(self): """ Return a JSON response """ request = self.request response = '' plugin = self.plugin entity = self.entity if plugin: if entity: subpath = self._subpath() data = entity(request, subpath=subpath) response = plugin.json(data) if data else '{}' else: response = plugin.json(plugin.entities()) else: data = [] plugins = utils.plugins() for plugin in plugins: tmp = { 'name': plugin.name, 'title': plugin.title, 'uri': plugin.uri } data.append(plugin.json(tmp)) response = '[{0}]'.format(', '.join(data)) request.response.setHeader('Content-Type', 'application/json;charset=utf-8') return response
def plugins(self): """ Open Data Plugins""" registered = utils.plugins() plugins = [self._p(p) for p in registered] return plugins