pytilities.delegation.profile

class pytilities.delegation.profile.Profile

States what attributes to delegate, and to which target attributes.

add_mappings(modifiers, *names, **mapped_names)

Map source to target attribute names, for delegation.

Parameters:
  • modifiers (string) –

    the types of delegation access to the target. Valid modifiers are combinations of:

    • ‘r’: read
    • ‘w’: write
    • ‘d’: delete
  • names ((string...)) – source names of the attribute names to delegate. The target attribute name is the same as source_name. This is the same as adding a {source_name : source_name} mapping, using the mapped_names argument.
  • mapped_names ({source_name of string : target_name of string}) –

    names of source and target attributes to map and delegate.

    target_name will be mangled if they have a __ prefix. Mangling will occur every time it is delegated to, so you can change the target object any time.

copy()
get_deletable(attribute)

Get the mapped value of a deletable attribute

Return type:string
get_readable(attribute)

Get the mapped value of a readable attribute

Return type:string
get_writable(attribute)

Get the mapped value of a writable attribute

Return type:string
has_deletable(attribute)

Check for delete-access mapping of attribute

Returns:True if the mapping exists
has_readable(attribute)

Check for read-access mapping of attribute

Returns:True if the mapping exists
has_writable(attribute)

Check for write-access mapping of attribute

Returns:True if the mapping exists
remove_mappings(modifiers, *names)

Remove attribute mappings

Parameters:
  • modifiers (string) –

    the types of delegation access to the target. Valid modifiers are combinations of:

    • ‘r’: read
    • ‘w’: write
    • ‘d’: delete
  • names ((string...)) – source names of the attribute names to remove
attributes

Get all attributes, no matter what access they provide

Returns:(attribute_name, ...)
Return type:iter(str, ...)
deletables

Get all deletables attributes

Returns:(attribute_name, ...)
Return type:iter(str, ...)
readables

Get all readable attributes

Returns:(attribute_name, ...)
Return type:iter(str, ...)
writables

Get all writables attributes

Returns:(attribute_name, ...)
Return type:iter(str, ...)

Previous topic

pytilities.delegation.delegationaspect

Next topic

pytilities.delegation.decorators

This Page