How to use the guillotina.utils.get_dotted_name function in guillotina

To help you get started, we’ve selected a few guillotina examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github plone / guillotina / guillotina / documentation / _generate.py View on Github external
dotted = get_dotted_name(iface)
    data = {
        'path': path,
        'path_scheme': path_scheme,
        'method': method,
        'options': kwargs,
        'request': dump_request(response.request),
        'response': dump_response(response),
        'service': {
            'name': service.get('name'),
            'title': service.get('title'),
            'description': service.get('description'),
            'payload': service.get('payload'),
            'query_params': service.get('query_params'),
            'method': service.get('method', 'GET'),
            'context': get_dotted_name(iface),
            'permission': service.get('permission')
        }
    }

    if file_type_name is None:
        file_type_name = dotted.split('.')[-1][1:].lower()

    filepath = '{}/{}-{}'.format(DIR, file_type_name, method.lower())

    if path_scheme != name:
        # use special name here...
        name, _, rest = path_scheme.partition('/')
        filepath += '-{}:{}'.format(
            name.replace('@', ''),
            ''.join([l for l in rest.split(':')[0] if l not in '[]():-'])
        )
github plone / guillotina / guillotina / documentation / generate.py View on Github external
parameters = self._function_swagger_param(service.get('parameters'), url)
        data = {
            'path': path,
            'path_scheme': path_scheme,
            'method': method,
            'options': kwargs,
            'request': self.dump_request(response.request),
            'response': self.dump_response(response),
            'service': {
                'name': service.get('name'),
                'title': service.get('title'),
                'summary': service.get('summary'),
                'parameters': parameters,
                'responses': responses,
                'method': service.get('method', 'GET'),
                'context': get_dotted_name(iface),
                'permission': service.get('permission')
            }
        }

        if file_type_name is None:
            file_type_name = dotted.split('.')[-1][1:].lower()

        filepath = '{}/{}-{}'.format(self._output_dir, file_type_name, method.lower())

        if path_scheme != name:
            # use special name here...
            name, _, rest = path_scheme.partition('/')
            filepath += '-{}:{}'.format(
                name.replace('@', ''),
                ''.join([l for l in rest.split(':')[0] if l not in '[]():-'])
            )
github plone / guillotina / guillotina / documentation / _generate.py View on Github external
# container root
    container_explorer = APIExplorer('/db/container')
    container_explorer.get().get('@types').post(jsond={
        '@type': 'Folder',
        'id': 'folder',
        'title': 'My Folder'
    })
    container_explorer.post('@addons', jsond={
        'id': 'myaddon'
    }).get('@addons').delete('@addons', jsond={
        'id': 'myaddon'
    })
    container_explorer.get('@registry').post(
        '@registry',
        jsond={
            'interface': get_dotted_name(testmodule.ISchema),
            'initial_values': {
                'foo': 'bar'
            }
        }
    ).patch('@registry/guillotina.documentation.testmodule.ISchema.foo',
            jsond={
                'value': 'New foobar value'
            },
            path_scheme='@registry/[dotted-name:string]').get(
        '@registry/guillotina.documentation.testmodule.ISchema.foo',
        path_scheme='@registry/[dotted-name:string]')

    # folder
    folder_explorer = APIExplorer('/db/container/folder', type_name='folder')
    folder_explorer.resource_api_basics().\
        patch(jsond={'title': 'My Folder Updated'}).\
github plone / guillotina / guillotina / documentation / _generate.py View on Github external
path = path.rstrip('/')

    service = get_service_def(path, method.upper())
    # path scheme used for things like traversing to registry value...
    name = service.get('name')
    path_scheme = kwargs.pop('path_scheme', name)

    print('Getting {} {}'.format(method, path))
    kwargs['auth'] = ('root', 'root')
    kwargs['headers'] = DEFAULT_HEADERS.copy()
    kwargs['headers'].update(kwargs.get('headers', {}))

    response = getattr(requests, method)(URL + path, **kwargs)

    iface = resolve_dotted_name(get_service_type_name(path)[-1])
    dotted = get_dotted_name(iface)
    data = {
        'path': path,
        'path_scheme': path_scheme,
        'method': method,
        'options': kwargs,
        'request': dump_request(response.request),
        'response': dump_response(response),
        'service': {
            'name': service.get('name'),
            'title': service.get('title'),
            'description': service.get('description'),
            'payload': service.get('payload'),
            'query_params': service.get('query_params'),
            'method': service.get('method', 'GET'),
            'context': get_dotted_name(iface),
            'permission': service.get('permission')
github plone / guillotina / guillotina / documentation / generate.py View on Github external
print('Getting {} {}'.format(method, path))
        kwargs['auth'] = ('root', 'root')
        kwargs['headers'] = DEFAULT_HEADERS.copy()
        kwargs['headers'].update(kwargs.get('headers', {}))

        url = self._base_url + path
        response = getattr(requests, method)(url, **kwargs)
        self._store_type_name(response, url, kwargs)

        service = self.get_service_def(path, method.upper())
        # path scheme used for things like traversing to registry value...
        name = service.get('name')
        path_scheme = kwargs.pop('path_scheme', name)

        iface = resolve_dotted_name(self.get_service_type_name(path)[-1])
        dotted = get_dotted_name(iface)
        responses = self._function_swagger_param(service.get('responses'), url)
        parameters = self._function_swagger_param(service.get('parameters'), url)
        data = {
            'path': path,
            'path_scheme': path_scheme,
            'method': method,
            'options': kwargs,
            'request': self.dump_request(response.request),
            'response': self.dump_response(response),
            'service': {
                'name': service.get('name'),
                'title': service.get('title'),
                'summary': service.get('summary'),
                'parameters': parameters,
                'responses': responses,
                'method': service.get('method', 'GET'),
github plone / guillotina / guillotina / documentation / _generate.py View on Github external
services = get_type_services(path_type_name)
    try:
        if '@' in path:
            return services['endpoints']['@' + subpath][method.upper()]
        else:
            return services[method]
    except (KeyError, TypeError):
        if type_name is not None:
            raise
        # this shouldn't happen, so we lookup other interfaces that this inherits
        # from to find service we're looking for
        iface = resolve_dotted_name(path_type_name)
        service = None
        for other_iface in iface.__bases__:
            try:
                service = get_service_def(path, method, get_dotted_name(other_iface))
            except (KeyError, TypeError):
                pass
            if service is not None:
                return service
github plone / guillotina / guillotina / documentation / generate.py View on Github external
services = self.get_type_services(path_type_name)
        try:
            if '@' in path:
                return services['endpoints']['@' + subpath][method.upper()]
            else:
                return services[method]
        except (KeyError, TypeError):
            if type_name is not None:
                raise
            # this shouldn't happen, so we lookup other interfaces that this inherits
            # from to find service we're looking for
            iface = resolve_dotted_name(path_type_name)
            service = None
            for other_iface in iface.__bases__:
                try:
                    service = self.get_service_def(path, method, get_dotted_name(other_iface))
                except (KeyError, TypeError):
                    pass
                if service is not None:
                    return service