adhocracy_core.schema package¶
Basic data structures and validation.
-
class
SchemaNode(*arg, **kw)[source]¶ Bases:
colander.SchemaNodeSubclass of :class: SchemaNode with extended keyword support.
The constructor accepts these additional keyword arguments:
- readonly:
- Disable deserialization. Default: False
-
readonly= False¶
-
class
SequenceSchema(*args, **kw)[source]¶ Bases:
colander.SequenceSchema,adhocracy_core.schema.SchemaNodeSubclass of :class: SchemaNode with Sequence type.
The default value is a deferred returning [] to prevent modify it.
-
class
SequenceOptionalJsonInSchema(*args, **kw)[source]¶ Bases:
adhocracy_core.schema.SequenceSchemaSequence type that allows a JSON string deserialization input.
-
class
MappingSchema(*arg, **kw)[source]¶ Bases:
colander.Schema,adhocracy_core.schema.SchemaNodeSubclass of :class: SchemaNode with dictionary type.
-
class
TupleSchema(*arg, **kw)[source]¶ Bases:
colander.TupleSchema,adhocracy_core.schema.SchemaNodeSubclass of :class: SchemaNode with tuple type.
-
raise_attribute_error_if_not_location_aware(context) → None[source]¶ Ensure that the argument is location-aware.
Raises: AttributeError – if it isn’t
-
deferred_validate_name_is_unique(node: adhocracy_core.schema.SchemaNode, kw: dict)[source]¶ Validate if value is name that does not exists in the parent object.
Raises: Invalid – if name already exists in the parent or parent is None.
-
class
Identifier(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.SchemaNodeLike
Name, but doesn’t check uniqueness..Example value: blu.ABC_12-3
-
schema_type¶ alias of
String
-
default= ''¶
-
missing= <colander._drop object>¶
-
relative_regex= '[a-zA-Z0-9\\_\\-\\.]+'¶
-
validator= <colander.All object>¶
-
-
class
Name(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.SchemaNodeThe unique name of a resource inside the parent pool.
Allowed characters are: “alpha” “numeric” “_” “-” ”.” The maximal length is 100 characters, the minimal length 1.
Example value: blu.ABC_12-3
This node needs a parent_pool binding to validate.
-
schema_type¶ alias of
String
-
default= ''¶
-
missing= <colander._drop object>¶
-
validator= <colander.deferred object>¶
-
-
class
Email(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.SchemaNodeString with email address.
Example value: test@test.de
-
schema_type¶ alias of
String
-
default= ''¶
-
missing= <colander._drop object>¶
-
static
preparer(email)¶
-
validator= <colander.Email object>¶
-
-
class
URL(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.SchemaNodeString with a URL.
Example value: http://colander.readthedocs.org/en/latest/
-
schema_type¶ alias of
String
-
default= ''¶
-
missing= <colander._drop object>¶
-
regex= re.compile('^(http|ftp)s?://(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\\.)+(?:[A-Z]{2,6}\\.?|[A-Z0-9-]{2,}(?<!-)\\.?)|localhost|\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|\\[?[A-F0-9]*:[A-F0-9:]+\\]?)(?::\\d+)?(?, re.IGNORECASE)¶
-
validator= <colander.Regex object>¶
-
-
class
TimeZoneName(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.SchemaNodeString with time zone.
Example value: UTC
-
schema_type¶ alias of
String
-
default= 'UTC'¶
-
missing= <colander._drop object>¶
-
validator= <colander.OneOf object>¶
-
-
class
Role(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.SchemaNodePermission role name.
Example value: ‘reader’
-
schema_type¶ alias of
String
-
default= 'creator'¶
-
missing= <colander._drop object>¶
-
validator= <colander.OneOf object>¶
-
-
class
Roles(*args, **kw)[source]¶ Bases:
adhocracy_core.schema.SequenceSchemaList of Permssion role names.
Example value: [‘initiator’]
-
missing= <colander._drop object>¶
-
validator= <colander.Length object>¶
-
-
class
InterfaceType[source]¶ Bases:
colander.SchemaTypeA ZOPE interface in dotted name notation.
Example value: adhocracy_core.sheets.name.IName
-
class
Interface(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.SchemaNode-
schema_type¶ alias of
InterfaceType
-
-
class
AbsolutePath(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.SchemaNodeAbsolute path made with Identifier Strings.
Example value: /bluaABC/_123/3
-
schema_type¶ alias of
String
-
relative_regex= '/[a-zA-Z0-9\\_\\-\\.\\/]+'¶
-
validator= <colander.Regex object>¶
-
-
class
SingleLine(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.SchemaNodeUTF-8 encoded String without line breaks.
Disallowed characters are linebreaks like: n, r. Example value: This is a something.
-
schema_type¶ alias of
String
-
default= ''¶
-
missing= <colander._drop object>¶
-
validator= <colander.Function object>¶
-
-
class
Boolean(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.SchemaNodeSchemaNode for boolean values.
Example value: false
-
default= False¶
-
missing= False¶
-
-
class
ContentType(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.SchemaNodeContentType schema.
-
schema_type¶ alias of
InterfaceType
-
default= <colander.deferred object>¶
-
-
get_sheet_cstructs(context: <InterfaceClass adhocracy_core.interfaces.IResource>, registry, request) → dict[source]¶ Serialize and return the `viewable`resource sheet data.
-
class
CurrencyAmount(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.SchemaNodeSchemaNode for currency amounts.
Values are stored precisely with 2 fractional digits. The used currency (e.g. EUR, USD) is not stored as part of the value, it is assumed to be known or to be stored in a different field.
Example value: 1.99
-
default= Decimal('0')¶
-
missing= <colander._drop object>¶
-
-
class
ISOCountryCode(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.SchemaNodeAn ISO 3166-1 alpha-2 country code (two uppercase ASCII letters).
Example value: US
-
schema_type¶ alias of
String
-
default= ''¶
-
missing= <colander._drop object>¶
-
validator= <colander.Regex object>¶
-
-
class
ResourceObjectType(serialization_form='url')[source]¶ Bases:
colander.SchemaTypeSchema type that de/serialized a location-aware object.
Example values: ‘http://a.org/bluaABC/_123/3‘ ‘/blua/ABC/’
If the value is an url with fqdn the the request binding is used to deserialize the resource.
If the value is an absolute path the context binding is used to deserialize the resource.
The default serialization is the resource url.
Initialize self.
-
serialization_form= None¶ Parameters: serialization_form – - If ‘url` the request binding is used to serialize to the resource url.
- If path the context binding is used to serialize to the Resource Location path.
- If content the request and ‘context’ binding is used to serialize the complete resource content and metadata.
Default url.
-
serialize(node, value)[source]¶ Serialize object to url or path.
Parameters: - node – the Colander node.
- value – the resource to serialize
Returns: the url or path of that resource
-
deserialize(node, value)[source]¶ Deserialize url or path to object.
Parameters: - node – the Colander node.
- value – the url or path Resource Location to deserialize
Returns: the resource registered under that path
Raises: Invalid – if the object does not exist.
-
-
class
Resource(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.SchemaNodeA resource SchemaNode.
Example value: ‘http://a.org/bluaABC/_123/3‘
-
default= None¶
-
missing= <colander._drop object>¶
-
schema_type¶ alias of
ResourceObjectType
-
-
class
ResourcePathSchema(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.MappingSchemaResource Path schema.
-
class
ResourcePathAndContentSchema(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.ResourcePathSchemaResource Path with content schema.
-
validate_reftype(node: adhocracy_core.schema.SchemaNode, value: <InterfaceClass adhocracy_core.interfaces.IResource>)[source]¶ Raise if value doesn`t provide the ISheet set by node.reftype.
-
class
Reference(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.ResourceSchema Node to reference a resource that implements a specific sheet.
The constructor accepts these additional keyword arguments:
reftype: :class:` adhocracy_core.interfaces.SheetReference`.The target_isheet attribute of the reftype specifies the sheet that accepted resources must implement. Storing another kind of resource will trigger a validation error.
backref: marks this Reference as a back reference.adhocracy_core.sheet.ResourceSheetcan use this information to autogenerate the appstruct/cstruct. Default: False.
-
reftype= <SheetReferenceClass adhocracy_core.interfaces.SheetReference>¶
-
backref= False¶
-
validator= <colander.All object>¶
-
multiple= False¶
-
widget= <colander.deferred object>¶
-
class
Resources(*args, **kw)[source]¶ Bases:
adhocracy_core.schema.SequenceSchema-
missing= []¶
-
-
class
References(*args, **kw)[source]¶ Bases:
adhocracy_core.schema.ResourcesSchema Node to reference resources that implements a specific sheet.
The constructor accepts these additional keyword arguments:
reftype:adhocracy_core.interfaces.SheetReference.The target_isheet attribute of the reftype specifies the sheet that accepted resources must implement. Storing another kind of resource will trigger a validation error.
backref: marks this Reference as a back reference.adhocracy_core.sheet.ResourceSheetcan use this information to autogenerate the appstruct/cstruct. Default: False.
-
reftype= <SheetReferenceClass adhocracy_core.interfaces.SheetReference>¶
-
backref= False¶
-
validator= <colander.All object>¶
-
multiple= True¶
-
widget= <colander.deferred object>¶
-
class
UniqueReferences(*args, **kw)[source]¶ Bases:
adhocracy_core.schema.ReferencesSchema Node to reference resources that implements a specific sheet.
The order is preserved, duplicates are removed.
Example value: [“http:a.org/bluaABC“]
-
class
Text(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.SchemaNodeUTF-8 encoded String with line breaks.
- Example value: This is a something
- with new lines.
-
schema_type¶ alias of
String
-
default= ''¶
-
missing= <colander._drop object>¶
-
widget= <deform_markdown.MarkdownTextAreaWidget object>¶
-
class
Password(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.SchemaNodeUTF-8 encoded text.
Minimal length=6, maximal length=100 characters. Example value: secret password?
-
schema_type¶ alias of
String
-
default= <colander.deferred object>¶
-
missing= <colander._drop object>¶
-
validator= <colander.Length object>¶
-
widget= <deform.widget.PasswordWidget object>¶
-
-
class
DateTime(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.SchemaNodeDateTime object.
This type serializes python
datetime.datetimeobjects to a ISO8601 string format. The format includes the date, the time, and the timezone of the datetime.Example values: 2014-07-21, 2014-07-21T09:10:37, 2014-07-21T09:10:37+00:00
The default/missing value is the current datetime.
Constructor arguments:
Parameters: tzinfo – This timezone is used if the cstruct is missing the tzinfo. Defaults to UTC -
default= <colander.deferred object>¶
-
missing= <colander.deferred object>¶
-
-
class
PostPool(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.ReferenceReference to the common place to post resources used by the this sheet.
Constructor arguments:
Parameters: iresource_or_service_name – The resource interface/service name of this post_pool. If it is a interface the lineage of the context is searched for the first matching interface. If it is a string the lineage and the lineage children are search for a service with this name. Defaults to adhocracy_core.interfaces.IPool.-
readonly= True¶
-
default= <colander.deferred object>¶
-
missing= <colander._drop object>¶
-
schema_type¶ alias of
ResourceObjectType
-
iresource_or_service_name= <InterfaceClass adhocracy_core.interfaces.IPool>¶
-
-
create_post_pool_validator(child_node: adhocracy_core.schema.Reference, kw: dict) → <built-in function callable>[source]¶ Create validator to check kw[‘context’] is inside post_pool.
Parameters:
-
class
Integer(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.SchemaNodeSchemaNode for Integer values.
Example value: 1
-
default= 0¶
-
missing= <colander._drop object>¶
-
-
class
Integers(*args, **kw)[source]¶ Bases:
adhocracy_core.schema.SequenceSchemaSchemaNode for a list of Integer values.
Example value: [1,2]
-
class
Float(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.SchemaNodeSchemaNode for Float values.
Example value: 1.234
-
default= 0.0¶
-
missing= <colander._drop object>¶
-
-
class
Floats(*args, **kw)[source]¶ Bases:
adhocracy_core.schema.SequenceSchemaSchemaNode for a list of Float values.
Example value: [1.003, 2.0]
-
class
FileStoreType[source]¶ Bases:
colander.SchemaTypeAccepts raw file data or filedict.
- raw file data: used to make ‘multipart/form-data’ upload in
adhocracy_core.rest.views.AssetsServiceRESTViewwork.- filedict: dictionary with html5 file data, as used for
adhocracy_core.sdi.
-
SIZE_LIMIT= 16777216¶
-
class
FileStore(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.SchemaNodeSchemaNode wrapping
FileStoreType.-
schema_type¶ alias of
FileStoreType
-
default= None¶
-
missing= <colander._drop object>¶
-
-
class
SingleLines(*args, **kw)[source]¶ Bases:
adhocracy_core.schema.SequenceSchemaList of SingleLines.
-
class
ACEPrincipalType[source]¶ Bases:
colander.SchemaTypeAdhocracy role or pyramid system principal.
-
valid_principals= ['participant', 'moderator', 'creator', 'initiator', 'admin', 'god', 'everyone', 'authenticated']¶ Valid principal strings.
-
serialize(node, value) → str[source]¶ Serialize principal and remove prefix (“system.” or “role:”).
Raises: ValueError – if value has no ‘.’ or ‘:’ char
-
-
class
ACEPrincipal(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.SchemaNodeAdhocracy role or pyramid system principal.
-
schema_type¶ alias of
ACEPrincipalType
-
-
class
ACEPrincipals(*args, **kw)[source]¶ Bases:
adhocracy_core.schema.SequenceSchemaList of Adhocracy role or pyramid system principal.
-
class
ACMCell(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.SchemaNodeACM Cell.
-
schema_type¶ alias of
String
-
missing= None¶
-
-
class
ACMRow(*args, **kw)[source]¶ Bases:
adhocracy_core.schema.SequenceSchemaACM Row.
-
class
ACMPrincipals(*args, **kw)[source]¶ Bases:
adhocracy_core.schema.SequenceSchemaACM Principals.
-
default= []¶
-
missing= []¶
-
-
class
ACMPermissions(*args, **kw)[source]¶ Bases:
adhocracy_core.schema.SequenceSchemaACM Permissions.
-
default= []¶
-
missing= []¶
-
-
class
ACM(*arg, **kw)[source]¶ Bases:
adhocracy_core.schema.MappingSchemaAccess Control Matrix.
-
default= {'principals': [], 'permissions': []}¶
-
missing= {'principals': [], 'permissions': []}¶
-