metadata_registration_api package¶
Subpackages¶
- metadata_registration_api.api package
- Submodules
- metadata_registration_api.api.api_ctrl_voc module
- metadata_registration_api.api.api_form module
- metadata_registration_api.api.api_props module
- metadata_registration_api.api.api_study module
- metadata_registration_api.api.api_user module
- metadata_registration_api.api.api_utils module
- metadata_registration_api.api.decorators module
- Module contents
Submodules¶
metadata_registration_api.app module¶
- metadata_registration_api.app.config_app(app)¶
- metadata_registration_api.app.create_app()¶
metadata_registration_api.errors module¶
- exception metadata_registration_api.errors.ApiBaseException¶
Bases:
Exception
- exception metadata_registration_api.errors.IdenticalPropertyException¶
- exception metadata_registration_api.errors.RequestBodyException¶
- exception metadata_registration_api.errors.TokenException¶
metadata_registration_api.model module¶
- class metadata_registration_api.model.ControlledVocabulary(*args, **values)¶
Bases:
metadata_registration_api.model.TopLevelDocument
Model for a controlled vocabulary.
A controlled vocabulary contains a list of possible items. See
Property
.- exception DoesNotExist¶
Bases:
mongoengine.errors.DoesNotExist
- exception MultipleObjectsReturned¶
Bases:
mongoengine.errors.MultipleObjectsReturned
- description¶
A unicode string field.
- id¶
A field wrapper around MongoDB’s ObjectIds.
- items¶
A list field that wraps a standard field, allowing multiple instances of the field to be used as a list in the database.
If using with ReferenceFields see: many-to-many-with-listfields
Note
Required means it cannot be empty - as the default for ListFields is []
- objects¶
The default QuerySet Manager.
Custom QuerySet Manager functions can extend this class and users can add extra queryset functionality. Any custom manager methods must accept a
Document
class as its first argument, and aQuerySet
as its second argument.The method function should return a
QuerySet
, probably the same one that was passed in, but modified in some way.
- validate(*args, **kwargs)¶
Enforce unicity of CV item synonyms
- class metadata_registration_api.model.CvItem(*args, **kwargs)¶
Bases:
mongoengine.document.EmbeddedDocument
An item in the list of controlled vocabularies
- description¶
A unicode string field.
- label¶
A unicode string field.
- name¶
A unicode string field.
- synonyms¶
A list field that wraps a standard field, allowing multiple instances of the field to be used as a list in the database.
If using with ReferenceFields see: many-to-many-with-listfields
Note
Required means it cannot be empty - as the default for ListFields is []
- class metadata_registration_api.model.DataObject(*args, **kwargs)¶
Bases:
mongoengine.document.EmbeddedDocument
- args¶
A dictionary field that wraps a standard Python dictionary. This is similar to an embedded document, but the structure is not defined.
Note
Required means it cannot be empty - as the default for DictFields is {}
- class_name¶
A unicode string field.
- fields¶
A list field that wraps a standard field, allowing multiple instances of the field to be used as a list in the database.
If using with ReferenceFields see: many-to-many-with-listfields
Note
Required means it cannot be empty - as the default for ListFields is []
- kwargs¶
A dictionary field that wraps a standard Python dictionary. This is similar to an embedded document, but the structure is not defined.
Note
Required means it cannot be empty - as the default for DictFields is {}
- property¶
A reference to a document that will be automatically dereferenced on access (lazily).
Note this means you will get a database I/O access everytime you access this field. This is necessary because the field returns a
Document
which precise type can depend of the value of the _cls field present in the document in database. In short, using this type of field can lead to poor performances (especially if you access this field only to retrieve it pk field which is already known before dereference). To solve this you should consider using theLazyReferenceField
.Use the reverse_delete_rule to handle what should happen if the document the field is referencing is deleted. EmbeddedDocuments, DictFields and MapFields does not support reverse_delete_rule and an InvalidDocumentError will be raised if trying to set on one of these Document / Field types.
The options are:
DO_NOTHING (0) - don’t do anything (default).
NULLIFY (1) - Updates the reference to null.
CASCADE (2) - Deletes the documents associated with the reference.
DENY (3) - Prevent the deletion of the reference object.
PULL (4) - Pull the reference from a
ListField
of references
Alternative syntax for registering delete rules (useful when implementing bi-directional delete rules)
class Org(Document): owner = ReferenceField('User') class User(Document): org = ReferenceField('Org', reverse_delete_rule=CASCADE) User.register_delete_rule(Org, 'owner', DENY)
- class metadata_registration_api.model.DataObjects(*args, **kwargs)¶
Bases:
mongoengine.document.EmbeddedDocument
- objects¶
A
ListField
designed specially to hold a list of embedded documents to provide additional query helpers.Note
The only valid list values are subclasses of
EmbeddedDocument
.
- class metadata_registration_api.model.Form(*args, **values)¶
Bases:
metadata_registration_api.model.TopLevelDocument
MongoDB representation of a FlaskForm
The form contains multiple fields.
- exception DoesNotExist¶
Bases:
mongoengine.errors.DoesNotExist
- exception MultipleObjectsReturned¶
Bases:
mongoengine.errors.MultipleObjectsReturned
- description¶
A unicode string field.
- fields¶
A
ListField
designed specially to hold a list of embedded documents to provide additional query helpers.Note
The only valid list values are subclasses of
EmbeddedDocument
.
- id¶
A field wrapper around MongoDB’s ObjectIds.
- objects¶
The default QuerySet Manager.
Custom QuerySet Manager functions can extend this class and users can add extra queryset functionality. Any custom manager methods must accept a
Document
class as its first argument, and aQuerySet
as its second argument.The method function should return a
QuerySet
, probably the same one that was passed in, but modified in some way.
- class metadata_registration_api.model.FormField(*args, **kwargs)¶
Bases:
mongoengine.document.EmbeddedDocument
- args¶
A generic embedded document field - allows any
EmbeddedDocument
to be stored.Only valid values are subclasses of
EmbeddedDocument
.Note
You can use the choices param to limit the acceptable EmbeddedDocument types
- class_name¶
A unicode string field.
- clean()¶
Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
- description¶
A unicode string field.
- fields¶
A list field that wraps a standard field, allowing multiple instances of the field to be used as a list in the database.
If using with ReferenceFields see: many-to-many-with-listfields
Note
Required means it cannot be empty - as the default for ListFields is []
- kwargs¶
A dictionary field that wraps a standard Python dictionary. This is similar to an embedded document, but the structure is not defined.
Note
Required means it cannot be empty - as the default for DictFields is {}
- label¶
A unicode string field.
- name¶
A unicode string field.
- property¶
A reference to a document that will be automatically dereferenced on access (lazily).
Note this means you will get a database I/O access everytime you access this field. This is necessary because the field returns a
Document
which precise type can depend of the value of the _cls field present in the document in database. In short, using this type of field can lead to poor performances (especially if you access this field only to retrieve it pk field which is already known before dereference). To solve this you should consider using theLazyReferenceField
.Use the reverse_delete_rule to handle what should happen if the document the field is referencing is deleted. EmbeddedDocuments, DictFields and MapFields does not support reverse_delete_rule and an InvalidDocumentError will be raised if trying to set on one of these Document / Field types.
The options are:
DO_NOTHING (0) - don’t do anything (default).
NULLIFY (1) - Updates the reference to null.
CASCADE (2) - Deletes the documents associated with the reference.
DENY (3) - Prevent the deletion of the reference object.
PULL (4) - Pull the reference from a
ListField
of references
Alternative syntax for registering delete rules (useful when implementing bi-directional delete rules)
class Org(Document): owner = ReferenceField('User') class User(Document): org = ReferenceField('Org', reverse_delete_rule=CASCADE) User.register_delete_rule(Org, 'owner', DENY)
- class metadata_registration_api.model.History(*args, **kwargs)¶
Bases:
mongoengine.document.EmbeddedDocument
- action¶
A unicode string field.
- manual_user¶
A unicode string field.
- timestamp¶
Datetime field.
Uses the python-dateutil library if available alternatively use time.strptime to parse the dates. Note: python-dateutil’s parser is fully featured and when installed you can utilise it to convert varying types of date formats into valid python datetime objects.
Note: To default the field to the current datetime, use: DateTimeField(default=datetime.utcnow)
- Note: Microseconds are rounded to the nearest millisecond.
Pre UTC microsecond support is effectively broken. Use
ComplexDateTimeField
if you need accurate microsecond support.
- user_id¶
A reference to a document that will be automatically dereferenced on access (lazily).
Note this means you will get a database I/O access everytime you access this field. This is necessary because the field returns a
Document
which precise type can depend of the value of the _cls field present in the document in database. In short, using this type of field can lead to poor performances (especially if you access this field only to retrieve it pk field which is already known before dereference). To solve this you should consider using theLazyReferenceField
.Use the reverse_delete_rule to handle what should happen if the document the field is referencing is deleted. EmbeddedDocuments, DictFields and MapFields does not support reverse_delete_rule and an InvalidDocumentError will be raised if trying to set on one of these Document / Field types.
The options are:
DO_NOTHING (0) - don’t do anything (default).
NULLIFY (1) - Updates the reference to null.
CASCADE (2) - Deletes the documents associated with the reference.
DENY (3) - Prevent the deletion of the reference object.
PULL (4) - Pull the reference from a
ListField
of references
Alternative syntax for registering delete rules (useful when implementing bi-directional delete rules)
class Org(Document): owner = ReferenceField('User') class User(Document): org = ReferenceField('Org', reverse_delete_rule=CASCADE) User.register_delete_rule(Org, 'owner', DENY)
- class metadata_registration_api.model.MetaInformation(*args, **kwargs)¶
Bases:
mongoengine.document.EmbeddedDocument
- change_log¶
A
ListField
designed specially to hold a list of embedded documents to provide additional query helpers.Note
The only valid list values are subclasses of
EmbeddedDocument
.
- deprecated¶
Boolean field type.
- state¶
A unicode string field.
- class metadata_registration_api.model.Property(*args, **values)¶
Bases:
metadata_registration_api.model.TopLevelDocument
Model for a property
A property is assigned to a level.
- exception DoesNotExist¶
Bases:
mongoengine.errors.DoesNotExist
- exception MultipleObjectsReturned¶
Bases:
mongoengine.errors.MultipleObjectsReturned
- clean()¶
Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
- description¶
A unicode string field.
- id¶
A field wrapper around MongoDB’s ObjectIds.
- level¶
A unicode string field.
- objects¶
The default QuerySet Manager.
Custom QuerySet Manager functions can extend this class and users can add extra queryset functionality. Any custom manager methods must accept a
Document
class as its first argument, and aQuerySet
as its second argument.The method function should return a
QuerySet
, probably the same one that was passed in, but modified in some way.
- synonyms¶
A list field that wraps a standard field, allowing multiple instances of the field to be used as a list in the database.
If using with ReferenceFields see: many-to-many-with-listfields
Note
Required means it cannot be empty - as the default for ListFields is []
- value_type¶
An embedded document field - with a declared document_type. Only valid values are subclasses of
EmbeddedDocument
.
- class metadata_registration_api.model.Study(*args, **values)¶
Bases:
mongoengine.document.Document
- exception DoesNotExist¶
Bases:
mongoengine.errors.DoesNotExist
- exception MultipleObjectsReturned¶
Bases:
mongoengine.errors.MultipleObjectsReturned
- entries¶
A
ListField
designed specially to hold a list of embedded documents to provide additional query helpers.Note
The only valid list values are subclasses of
EmbeddedDocument
.
- id¶
A field wrapper around MongoDB’s ObjectIds.
- meta_information¶
An embedded document field - with a declared document_type. Only valid values are subclasses of
EmbeddedDocument
.
- objects¶
The default QuerySet Manager.
Custom QuerySet Manager functions can extend this class and users can add extra queryset functionality. Any custom manager methods must accept a
Document
class as its first argument, and aQuerySet
as its second argument.The method function should return a
QuerySet
, probably the same one that was passed in, but modified in some way.
- class metadata_registration_api.model.StudyEntry(*args, **kwargs)¶
Bases:
mongoengine.document.EmbeddedDocument
- property¶
A reference to a document that will be automatically dereferenced on access (lazily).
Note this means you will get a database I/O access everytime you access this field. This is necessary because the field returns a
Document
which precise type can depend of the value of the _cls field present in the document in database. In short, using this type of field can lead to poor performances (especially if you access this field only to retrieve it pk field which is already known before dereference). To solve this you should consider using theLazyReferenceField
.Use the reverse_delete_rule to handle what should happen if the document the field is referencing is deleted. EmbeddedDocuments, DictFields and MapFields does not support reverse_delete_rule and an InvalidDocumentError will be raised if trying to set on one of these Document / Field types.
The options are:
DO_NOTHING (0) - don’t do anything (default).
NULLIFY (1) - Updates the reference to null.
CASCADE (2) - Deletes the documents associated with the reference.
DENY (3) - Prevent the deletion of the reference object.
PULL (4) - Pull the reference from a
ListField
of references
Alternative syntax for registering delete rules (useful when implementing bi-directional delete rules)
class Org(Document): owner = ReferenceField('User') class User(Document): org = ReferenceField('Org', reverse_delete_rule=CASCADE) User.register_delete_rule(Org, 'owner', DENY)
- value¶
A truly dynamic field type capable of handling different and varying types of data.
Used by
DynamicDocument
to handle dynamic data
- class metadata_registration_api.model.TopLevelDocument(*args, **values)¶
Bases:
mongoengine.document.Document
Base class for all top level documents
All top level documents have a label, a name and a deprecated flag. The label is for displaying to the end user (external representation) and the name is used by the machine (internal representation). The name is expected to be unique for the model. To ensures that the name is converted to snake case before it is inserted into the database. The deprecated flag indicates if a document is no longer needed (alternative to delete it)
- clean()¶
Hook for doing document level data cleaning (usually validation or assignment) before validation is run.
Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
- deprecated¶
Boolean field type.
- label¶
A unicode string field.
- name¶
A unicode string field.
- class metadata_registration_api.model.User(*args, **values)¶
Bases:
mongoengine.document.Document
- exception DoesNotExist¶
Bases:
mongoengine.errors.DoesNotExist
- exception MultipleObjectsReturned¶
Bases:
mongoengine.errors.MultipleObjectsReturned
- clean()¶
Called before data is inserted into the database
- email¶
A field that validates input as an email address.
- firstname¶
A unicode string field.
- id¶
A field wrapper around MongoDB’s ObjectIds.
- is_active¶
Boolean field type.
- lastname¶
A unicode string field.
- objects¶
The default QuerySet Manager.
Custom QuerySet Manager functions can extend this class and users can add extra queryset functionality. Any custom manager methods must accept a
Document
class as its first argument, and aQuerySet
as its second argument.The method function should return a
QuerySet
, probably the same one that was passed in, but modified in some way.
- password¶
A unicode string field.
- class metadata_registration_api.model.VocabularyType(*args, **kwargs)¶
Bases:
mongoengine.document.EmbeddedDocument
Model which defines the allowed vocabulary.
It is used to validate user input. If the data type is ctrl_voc, only the items of
ControlledVocabulary
are allowed.- controlled_vocabulary¶
A reference to a document that will be automatically dereferenced on access (lazily).
Note this means you will get a database I/O access everytime you access this field. This is necessary because the field returns a
Document
which precise type can depend of the value of the _cls field present in the document in database. In short, using this type of field can lead to poor performances (especially if you access this field only to retrieve it pk field which is already known before dereference). To solve this you should consider using theLazyReferenceField
.Use the reverse_delete_rule to handle what should happen if the document the field is referencing is deleted. EmbeddedDocuments, DictFields and MapFields does not support reverse_delete_rule and an InvalidDocumentError will be raised if trying to set on one of these Document / Field types.
The options are:
DO_NOTHING (0) - don’t do anything (default).
NULLIFY (1) - Updates the reference to null.
CASCADE (2) - Deletes the documents associated with the reference.
DENY (3) - Prevent the deletion of the reference object.
PULL (4) - Pull the reference from a
ListField
of references
Alternative syntax for registering delete rules (useful when implementing bi-directional delete rules)
class Org(Document): owner = ReferenceField('User') class User(Document): org = ReferenceField('Org', reverse_delete_rule=CASCADE) User.register_delete_rule(Org, 'owner', DENY)
- data_type¶
A unicode string field.
- metadata_registration_api.model.to_snake_case(name)¶
Convert a string into an internal representation (no leading and trailing whitespace, and intermediate whitespace replaced with underscore)
- Parameters
name – a given name
- Returns
name in snake_case or None