b3j0f.utils.proxy module¶
Module in charge of creating proxies like the design pattern proxy
.
A proxy is based on a callable element. It respects its signature but not the implementation.
-
b3j0f.utils.proxy.
get_proxy
(elt, bases=None, _dict=None)[source]¶ Get proxy from an elt.
If elt implements the proxy generator method (named
__getproxy__
), use it instead of using this module functions.Parameters: - elt (object or function/method) – elt to proxify.
- bases – base types to enrich in the result cls if not None.
- _dict – class members to proxify if not None.
-
b3j0f.utils.proxy.
proxify_routine
(routine, impl=None)[source]¶ Proxify a routine with input impl.
Parameters: - routine – routine to proxify.
- impl – new impl to use. If None, use routine.
-
b3j0f.utils.proxy.
proxify_elt
(elt, bases=None, _dict=None, public=False)[source]¶ Proxify input elt.
Parameters: Returns: proxified element.
Raises: TypeError if elt does not implement all routines of bases and _dict.