示例#1
0
class WorkflowMeta(MappingSchema):
    """Data structure to define a workflow (finite state machine)."""

    initial_state = SingleLine(missing=drop)
    defaults = SingleLine(missing=drop)
    add_local_role_participant_to_default_group = Boolean(missing=drop,
                                                          default=False)
    auto_transition = Boolean(missing=drop)
    states = SchemaNode(MappingType(unknown='preserve'), missing=drop)
    transitions = SchemaNode(MappingType(unknown='preserve'), missing=drop)
示例#2
0
def add_post_data_subschemas(node: SchemaNode, kw: dict):
    """Add the resource sheet schemas that are 'creatable'."""
    context = kw['context']
    request = kw['request']
    content_type = _get_resource_type_based_on_request_type(request)
    try:
        iresource = ContentType().deserialize(content_type)
    except Invalid:
        return  # the content type is validated later, so we just ignore errors
    creates = request.registry.content.get_sheets_create(
        context, request, iresource)
    for sheet in creates:
        schema = sheet.get_schema_with_bindings()
        node.add(schema)
示例#3
0
def add_post_data_subschemas(node: SchemaNode, kw: dict):
    """Add the resource sheet schemas that are 'creatable'."""
    context = kw['context']
    request = kw['request']
    content_type = _get_resource_type_based_on_request_type(request)
    try:
        iresource = ContentType().deserialize(content_type)
    except Invalid:
        return  # the content type is validated later, so we just ignore errors
    creates = request.registry.content.get_sheets_create(context,
                                                         request,
                                                         iresource)
    for sheet in creates:
        schema = sheet.get_schema_with_bindings()
        node.add(schema)
示例#4
0
class POSTResourceRequestSchema(PUTResourceRequestSchema):
    """Data structure for Resource POST requests."""

    content_type = ContentType(validator=deferred_validate_post_content_type,
                               missing=required)

    data = SchemaNode(MappingType(unknown='raise'),
                      after_bind=add_post_data_subschemas,
                      default={})
示例#5
0
class PUTResourceRequestSchema(MappingSchema):
    """Data structure for Resource PUT requests.

    The subschemas for the Resource Sheets
    """

    data = SchemaNode(MappingType(unknown='raise'),
                      after_bind=add_put_data_subschemas,
                      default={})
示例#6
0
class POSTBatchRequestItem(MappingSchema):
    """A single item in a batch request, encoding a single request."""

    method = BatchHTTPMethod()
    path = BatchRequestPath()
    """A single item in a batch request, encoding a single request."""

    method = BatchHTTPMethod()
    path = BatchRequestPath()
    body = SchemaNode(MappingType(unknown='preserve'), missing={})
    result_path = BatchRequestPath(missing='')
    result_first_version_path = BatchRequestPath(missing='')
示例#7
0
 def _add_additional_nodes(self, schema: MappingSchema, params: dict):
     if params.get('serialization_form', False) == 'content':
         elements = schema['elements']
         typ_copy = deepcopy(elements.children[0].typ)
         typ_copy.serialization_form = 'content'
         elements.children[0].typ = typ_copy
     if params.get('show_count', True):  # pragma: no branch
         child = Integer(default=0, missing=drop, name='count')
         schema.add(child)
     if params.get('show_frequency', False):
         child = SchemaNode(MappingType(unknown='preserve'),
                            default={},
                            missing=drop,
                            name='aggregateby')
         schema.add(child)
     return schema
示例#8
0
def _add_node(schema: MappingSchema, node: SchemaNode, name: str):
    node = node.bind(**schema.bindings)
    node.name = name
    schema.add(node)
示例#9
0
def _add_node(schema: MappingSchema, node: SchemaNode, name: str):
    node = node.bind(**schema.bindings)
    node.name = name
    schema.add(node)
示例#10
0
class POSTLocationMapping(MappingSchema):
    """Overview of POST request/response data structure."""

    request_body = SchemaNode(POSTResourceRequestSchemaList(), default=[])
    response_body = ResourceResponseSchema()
示例#11
0
class GETLocationMapping(MappingSchema):
    """Overview of GET request/response data structure."""

    request_querystring = SchemaNode(MappingType(), default={})
    request_body = SchemaNode(MappingType(), default={})
    response_body = GETResourceResponseSchema()
示例#12
0
class ServerNotification(MappingSchema):
    """Notification sent to the server from the Pyramid WS client."""

    event = Event()
    resource = SchemaNode(ResourceObjectType(serialization_form='path'))