Package pytilities :: Package delegation :: Module decorators
[hide private]
[frames] | no frames]

Module decorators

source code


Various decorators to ease delegation

Functions [hide private]
 
delegator_factory(bases=())
Makes a `DelegatorFactory` on the class and adds profiles to it.
source code
 
delegated(profile_name='default', modifiers='rwd')
Includes the decorated attribute in the specified delegation profile.
source code
Variables [hide private]
  _logger = logging.getLogger("pytilities.delegation")
  __package__ = 'pytilities.delegation'
Function Details [hide private]

delegator_factory(bases=())

source code 

Makes a `DelegatorFactory` on the class and adds profiles to it.

The factory is stored as a class attribute with name _delegator_factory.

`Profile`s are created based on the annotations left by `delegated`.

After the `Profile`s are created, __init_delegation_profiles(profiles) is
called, if it exists. It is a static method found on the decorated class.
The `profiles` parameter is of type {name::string: ::Profile}. You can
modify the profiles as you like, these are the profiles that will be added
to the DelegatorFactory after the call. At the time of this call
_delegator_factory does not exist yet.

Parameters:

    `bases` :: iter(cls...)
        classes that have a _delegator_factory attribute. Classes that
        contain base factories for this factory, see `DelegatorFactory` for
        more info on base factories.

delegated(profile_name='default', modifiers='rwd')

source code 

Includes the decorated attribute in the specified delegation profile.

Parameters:

    `profile_name` :: string
        name of the `Profile` to add the attribute to

    `modifiers` :: string
        the types of access to delegate to the target. Possible modifiers
        are combinations of:
            
            - `r`: read
            - `w`: write
            - `d`: delete