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)
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)
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)
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={})
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={})
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='')
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
def _add_node(schema: MappingSchema, node: SchemaNode, name: str): node = node.bind(**schema.bindings) node.name = name schema.add(node)
class POSTLocationMapping(MappingSchema): """Overview of POST request/response data structure.""" request_body = SchemaNode(POSTResourceRequestSchemaList(), default=[]) response_body = ResourceResponseSchema()
class GETLocationMapping(MappingSchema): """Overview of GET request/response data structure.""" request_querystring = SchemaNode(MappingType(), default={}) request_body = SchemaNode(MappingType(), default={}) response_body = GETResourceResponseSchema()
class ServerNotification(MappingSchema): """Notification sent to the server from the Pyramid WS client.""" event = Event() resource = SchemaNode(ResourceObjectType(serialization_form='path'))