示例#1
0
    def describe(resource, controller, path, verbose=False):
        if controller:
            version = controller.version
        else:
            version = (resource.version, 0)

        description = {
            '__subject__': 'resource',
            'id': '%s/%s' % ('/'.join(path), resource.name),
            'classname': resource.__name__,
            'composite_key': resource.composite_key,
            'controller': identify_class(controller),
            'name': resource.name,
            'title': resource.title,
            'description': resource.description,
            'resource': identify_class(resource),
            'version': version,
        }

        description['schema'] = {}
        for name, field in resource.schema.iteritems():
            description['schema'][name] = field.describe(verbose=verbose)

        prefix = '/%s/' % '/'.join(path)

        description['requests'] = {}
        for name, request in resource.requests.iteritems():
            description['requests'][name] = request.describe(prefix, verbose)

        return description
示例#2
0
    def describe(resource, controller, path_prefix=None):
        if controller:
            version = controller.version
        else:
            version = (resource.version, 0)

        description = {
            'controller': identify_class(controller),
            'name': resource.name,
            'title': resource.title,
            'description': resource.description,
            'resource': identify_class(resource),
            'version': version,
        }

        description['schema'] = {}
        for name, field in resource.schema.iteritems():
            description['schema'][name] = field.describe(FIELD_PARAMETERS)

        path = '/%d.%d/' % version
        if path_prefix:
            path = path_prefix.rstrip('/') + path

        description['requests'] = {}
        for name, request in resource.requests.iteritems():
            description['requests'][name] = request.describe(path)

        return description
示例#3
0
    def describe(resource, controller, path, verbose=False):
        if controller:
            version = controller.version
        else:
            version = (resource.version, 0)

        description = {
            '__subject__': 'resource',
            'id': '%s/%s' % ('/'.join(path), resource.name),
            'classname': resource.__name__,
            'composite_key': resource.composite_key,
            'controller': identify_class(controller),
            'name': resource.name,
            'title': resource.title,
            'description': resource.description,
            'resource': identify_class(resource),
            'version': version,
        }

        description['schema'] = {}
        for name, field in resource.schema.iteritems():
            description['schema'][name] = field.describe(verbose=verbose)

        prefix = '/%s/' % '/'.join(path)

        description['requests'] = {}
        for name, request in resource.requests.iteritems():
            description['requests'][name] = request.describe(prefix, verbose)

        return description
示例#4
0
    def describe(resource, controller, path_prefix=None):
        if controller:
            version = controller.version
        else:
            version = (resource.version, 0)
        description = {
            'controller': identify_class(controller),
            'name': resource.name,
            'title': resource.title,
            'description': resource.description,
            'resource': identify_class(resource),
            'version': version,
        }

        description['schema'] = {}
        for name, field in resource.schema.iteritems():
            description['schema'][name] = field.describe(FIELD_PARAMETERS)

        description['requests'] = {}
        for name, request in resource.requests.iteritems():
            description['requests'][name] = request.describe(path_prefix)

        return description