A Link field type is provided to offer a way to store and retrieve well-formed URI (URL) while optionally restricting the allowable schemes, or protocols. Internally these values are stored as strings after normalization through the URI datatype, and on access provide that URI instance.


from marrow.mongo.field import Link




This field type inherits all Field attributes and represents a singular, scalar text value.


Instantiate and assign an instance of this class during construction of a new Document subclass. Accessing as a class attribute will return a Queryable allowing filtering operations, and access as an instance attribute will return a URI cast value.

Assignment of any value matched by the truthy iterable (via in comparison) will store True, and likewise with the falsy iterable storing False. Additionally, if an attempt is made to assign a non-boolean, non-string value, the value will be passed through bool() conversion prior to storage, allowing use of objects which define their own __nonzero__/__bool__ methods.

Last updated