user_objects¶
UserObject¶
-
class
wysdom.UserObject(value: Optional[Mapping[str, Any]] = None, json_dom_info: Optional[wysdom.dom.DOMElement.DOMInfo] = None, **kwargs)¶ Bases:
wysdom.dom.DOMObject.DOMObjectBase class for user-defined DOM objects.
Parameters: - value – A dict-like object to populate the underlying data object’s keys. May be provided alone or in conjunction with keyword arguments.
- json_dom_info – A named tuple with parameters (element, document, parent, element_key) which specify this object’s position in a larger document object model. This is only required if you need to set these values when creating an object manually: when objects are created as part of a DOM specification, these values are populated automatically.
- kwargs – Keyword arguments to be used to populate the underlying data object’s keys. May be provided alone or in conjunction with value.
UserProperties¶
-
class
wysdom.user_objects.UserProperties(user_class: Type[wysdom.user_objects.UserObject.UserObject], additional_properties: Union[bool, wysdom.base_schema.Schema.Schema] = False)¶ Bases:
wysdom.dom.DOMProperties.DOMPropertiesA container for property information for a
UserObjectsubclass.Parameters: - user_class – The subclass of
UserObjectto extract properties from. Properties will be extracted from the class’sUserPropertydescriptors. - additional_properties – Defines whether a
DOMObjectpermits additional dynamically-named properties. Can be True or False, or can be set to a specificSchemato restrict the permitted types of any additional properties.
- user_class – The subclass of
UserProperty¶
-
class
wysdom.UserProperty(property_type: Union[Type[CT_co], wysdom.base_schema.Schema.Schema], optional: Optional[bool] = None, name: Optional[str] = None, default: Optional[Any] = None, default_function: Optional[Callable] = None, persist_defaults: Optional[bool] = None)¶ Bases:
objectA data descriptor for creating attributes in user-defined subclasses of
UserObjectwhich are mapped to keys in the underlying data object and to the properties key in the object’s JSON schema.Parameters: - property_type –
The data type or schema for this property. Must be one of:
- A primitive Python type (
str,int,bool,float) - A subclass of
UserObject - An instance of
Schema
- A primitive Python type (
- optional – Determines whether this property is optional in the underlying data object. If default or default_function are set, this will default to True, otherwise False.
- name – The name of this property in the underlying
data object. If not provided, this defaults to
the name of the attribute on the
UserObjectinstance that owns the property. - default – A static value which provides a default value for this property. Cannot be set in conjunction with default_function.
- default_function – A function which provides a default value
for this property. The function must have a
single positional argument, self, which is
passed the
UserObjectinstance that owns the property. Cannot be set in conjunction with default. - persist_defaults – If this property is set to True and a UserProperty has either the default or default_function property, when the UserProperty returns a default value that value will also be explicitly stored in the underlying data object. This is often desirable behavior if the UserProperty returns another object and your code expects it to return the same object instance each time it is accessed.
- property_type –