gnome.persist.base_schema¶
Attributes¶
Classes¶
Base class for all schema types |
|
This stores the obj_type and obj_index |
|
Fundamental building block of schemas. |
|
Only contains 2D (long, lat) positions |
|
Used to define bounds on a map |
|
Used to define reference points. 3D positions (long,lat,z) |
|
Define same schema as WorldPoint; however, the base class |
|
Only contains 2D (long, lat) positions |
Functions¶
|
Used by TimeseriesValueSchema - assume it defers the calculation of |
|
|
|
add a trailing number to the file name in case the user accidentally |
Module Contents¶
- gnome.persist.base_schema.log¶
- gnome.persist.base_schema.now(node, kw)¶
- Used by TimeseriesValueSchema - assume it defers the calculation of
datetime.datetime.now to when it is called in Schema
- class gnome.persist.base_schema.ObjType(unknown='ignore')¶
Bases:
colander.SchemaType
Base class for all schema types
- unknown = 'ignore'¶
- cstruct_children(node, cstruct)¶
- serialize(node, appstruct, options=None)¶
- deserialize(node, cstruct, refs)¶
- flatten(node, appstruct, prefix='', listitem=False)¶
- unflatten(node, paths, fstruct)¶
- set_value(node, appstruct, path, value)¶
- get_value(node, appstruct, path)¶
- save(node, appstruct, zipfile_, refs)¶
- load(node, cstruct, saveloc, refs)¶
- hydrate_json(node, cstruct, saveloc, refs)¶
- class gnome.persist.base_schema.CollectionItemMap(*arg, **kw)¶
Bases:
colander.MappingSchema
This stores the obj_type and obj_index
- obj_type¶
- id¶
- class gnome.persist.base_schema.CollectionItemsList(*args, **kw)¶
Bases:
colander.SequenceSchema
Fundamental building block of schemas.
The constructor accepts these positional arguments:
typ
: The ‘type’ for this node. It should be an instance of a class that implements thecolander.interfaces.Type
interface. Iftyp
is not passed, a call to theschema_type()
method on this class is made to get a default type. (When subclassing,schema_type()
should be overridden to provide a reasonable default type).*children
: a sequence of subnodes. If the subnodes of this node are not known at construction time, they can later be added via theadd
method.
The constructor accepts these keyword arguments:
name
: The name of this node.typ
: The ‘type’ for this node can optionally be passed in as a keyword argument. See the documentation for the positional arg above.default
: The default serialization value for this node when not set. Ifdefault
iscolander.drop
, the node will be dropped from schema serialization. If not provided, the node will be serialized tocolander.null
.missing
: The default deserialization value for this node. If it is not provided, the missing value of this node will be the special marker valuecolander.required
, indicating that it is considered ‘required’. Whenmissing
iscolander.required
, therequired
computed attribute will beTrue
. Whenmissing
iscolander.drop
, the node is dropped from the schema if it isn’t set during deserialization.missing_msg
: Optional error message to be used if the value is required and missing.preparer
: Optional preparer for this node. It should be an object that implements thecolander.interfaces.Preparer
interface.validator
: Optional validator for this node. It should be an object that implements thecolander.interfaces.Validator
interface.after_bind
: A callback which is called after a clone of this node has ‘bound’ all of its values successfully. This callback is useful for performing arbitrary actions to the cloned node, or direct children of the cloned node (such as removing or adding children) at bind time. A ‘binding’ is the result of an execution of thebind
method of the clone’s prototype node, or one of the parents of the clone’s prototype nodes. The deepest nodes in the node tree are bound first, so theafter_bind
methods of the deepest nodes are called before the shallowest. Theafter_bind
callback should accept two values:node
andkw
.node
will be a clone of the bound node object,kw
will be the set of keywords passed to thebind
method.title
: The title of this node. Defaults to a titleization of thename
(underscores replaced with empty strings and the first letter of every resulting word capitalized). The title is used by higher-level systems (not by Colander itself).description
: The description for this node. Defaults to''
(the empty string). The description is used by higher-level systems (not by Colander itself).widget
: The ‘widget’ for this node. Defaults toNone
. The widget attribute is not interpreted by Colander itself, it is only meaningful to higher-level systems such as Deform.insert_before
: if supplied, it names a sibling defined by a superclass for its parent node; the current node will be inserted before the named node. It is not useful unless a mapping schema is inherited from another mapping schema, and you need to control the ordering of the resulting nodes.
Arbitrary keyword arguments remaining will be attached to the node object unmolested.
- item¶
- class gnome.persist.base_schema.LongLat(*arg, **kw)¶
Bases:
colander.TupleSchema
Only contains 2D (long, lat) positions
- long¶
- lat¶
- class gnome.persist.base_schema.LongLatBounds(*args, **kw)¶
Bases:
colander.SequenceSchema
Used to define bounds on a map
- bounds¶
- gnome.persist.base_schema.Polygon¶
- class gnome.persist.base_schema.WorldPoint(*arg, **kw)¶
Bases:
LongLat
Used to define reference points. 3D positions (long,lat,z)
- z¶
- class gnome.persist.base_schema.WorldPointNumpy(*arg, **kw)¶
Bases:
gnome.persist.extend_colander.NumpyFixedLenSchema
Define same schema as WorldPoint; however, the base class NumpyFixedLenSchema serializes/deserializes it from/to a numpy array
- long¶
- lat¶
- z¶
- class gnome.persist.base_schema.ImageSize(*arg, **kw)¶
Bases:
colander.TupleSchema
Only contains 2D (long, lat) positions
- width¶
- height¶
- gnome.persist.base_schema.get_file_name_ext(filename_in)¶
- gnome.persist.base_schema.sanitize_string(s)¶
- gnome.persist.base_schema.gen_unique_filename(filename_in, zipfile_)¶
add a trailing number to the file name in case the user accidentally uploads multiple files with the same name for different objects. also sanitizes out illegal characters