pydent.marshaller.fields.Alias¶
-
class
pydent.marshaller.fields.Alias(field_name)[source]¶ Bases:
pydent.marshaller.fields.CallbackA shallow alias to another field.
Alias field initialize. Exposes a shallow alias to another field that can be accessed by a different attribute key.
- Parameters
field_name (basestring) – the key of the other field
-
__init__(field_name)[source]¶ Alias field initialize. Exposes a shallow alias to another field that can be accessed by a different attribute key.
- Parameters
field_name (basestring) – the key of the other field
Methods
__init__(field_name)Alias field initialize.
alias_callback(m, field_name)- rtype
Any
cache_result(owner, val)deserialize(*args, **kwargs)fullfill(owner[, cache, extra_args, …])Calls the callback function using the owner object.
get_callback_args(owner[, extra_args])Processes the callback args.
get_callback_kwargs(owner, extra_kwargs)Processes the callback kwargs.
register(name, objtype)Registers the field to a nested class.
serialize(owner, data)- rtype
Union[dict,None,List]
set_data_key(key)Attributes
SELF-
ACCESSOR¶
-
_Callback__FLAGS¶ alias of
Callback.__FLAGS
-
fullfill(owner, cache=None, extra_args=None, extra_kwargs=None)¶ Calls the callback function using the owner object. A Callback.SELF arg value will be replaced to be equivalent to the owner instance model.
- Parameters
owner – the owning object
cache (
Optional[bool]) – if True, will cache the return in the deserialized data. On next call, the cached result will be returned.extra_args (
Optional[tuple]) – extra args to pass to the callback functionextra_kwargs (
Optional[dict]) – extra kwargs to pass to the callback function
- Returns
function result
- Return type
any
-
get_callback_args(owner, extra_args=None)¶ Processes the callback args.
- Return type
List[Any]
-
get_callback_kwargs(owner, extra_kwargs)¶ Processes the callback kwargs.
- Return type
dict
-
register(name, objtype)¶ Registers the field to a nested class. Instantiates the corresponding descriptor (i.e. accessor)
- Parameters
name (
str) – name of the fieldobjtype (
Type) – the nested class to register the field to
- Returns
None
- Return type
None