New schema for attachments, using propertyschema/valueschema.

This commit is contained in:
Sybren A. Stüvel 2016-10-25 12:22:44 +02:00
parent fa3406b7d0
commit 590d075735
4 changed files with 26 additions and 63 deletions

View File

@ -6,3 +6,23 @@ _file_embedded_schema = {
'embeddable': True
}
}
_attachments_embedded_schema = {
'type': 'dict',
# TODO: will be renamed to 'keyschema' in Cerberus 1.0
'propertyschema': {
'type': 'string',
'regex': '^[a-zA-Z0-9_ ]+$',
},
'valueschema': {
'type': 'dict',
'schema': {
'oid': 'objectid',
'collection': {
'type': 'string',
'allowed': ['files'],
'default': 'files',
},
},
},
}

View File

@ -1,4 +1,4 @@
from pillar.api.node_types import _file_embedded_schema
from pillar.api.node_types import _file_embedded_schema, _attachments_embedded_schema
node_type_asset = {
'name': 'asset',
@ -27,26 +27,7 @@ node_type_asset = {
# We point to the original file (and use it to extract any relevant
# variation useful for our scope).
'file': _file_embedded_schema,
'attachments': {
'type': 'list',
'schema': {
'type': 'dict',
'schema': {
'field': {'type': 'string'},
'files': {
'type': 'list',
'schema': {
'type': 'dict',
'schema': {
'file': _file_embedded_schema,
'slug': {'type': 'string', 'minlength': 1},
'size': {'type': 'string'}
}
}
}
}
}
},
'attachments': _attachments_embedded_schema,
# Tags for search
'tags': {
'type': 'list',

View File

@ -1,4 +1,4 @@
from pillar.api.node_types import _file_embedded_schema
from pillar.api.node_types import _attachments_embedded_schema
node_type_page = {
'name': 'page',
@ -22,26 +22,7 @@ node_type_page = {
'url': {
'type': 'string'
},
'attachments': {
'type': 'list',
'schema': {
'type': 'dict',
'schema': {
'field': {'type': 'string'},
'files': {
'type': 'list',
'schema': {
'type': 'dict',
'schema': {
'file': _file_embedded_schema,
'slug': {'type': 'string', 'minlength': 1},
'size': {'type': 'string'}
}
}
}
}
}
}
'attachments': _attachments_embedded_schema,
},
'form_schema': {
'attachments': {'visible': False},

View File

@ -1,4 +1,4 @@
from pillar.api.node_types import _file_embedded_schema
from pillar.api.node_types import _attachments_embedded_schema
node_type_post = {
'name': 'post',
@ -26,26 +26,7 @@ node_type_post = {
'url': {
'type': 'string'
},
'attachments': {
'type': 'list',
'schema': {
'type': 'dict',
'schema': {
'field': {'type': 'string'},
'files': {
'type': 'list',
'schema': {
'type': 'dict',
'schema': {
'file': _file_embedded_schema,
'slug': {'type': 'string', 'minlength': 1},
'size': {'type': 'string'}
}
}
}
}
}
}
'attachments': _attachments_embedded_schema,
},
'form_schema': {
'attachments': {'visible': False},