b3j0f.aop.joinpoint module¶
Module which aims to manage python joinpoint interception.
A joinpoint is just a callable element.
functions allow to weave an interception function on any python callable object.
-
class
b3j0f.aop.joinpoint.
Joinpoint
(target=None, args=None, kwargs=None, advices=None, ctx=None, exec_ctx=None)[source]¶ Bases:
object
Manage joinpoint execution with Advices.
Advices are callable objects which take in parameter a Joinpoint.
- Joinpoint provides to advices:
- the joinpoint,
- joinpoint call arguments as args and kwargs property,
- a shared context during interception such as a dictionary.
-
ARGS
= 'args'¶ interception args attribute name
-
CTX
= 'ctx'¶ target element ctx attribute name
-
EXEC_CTX
= 'exec_ctx'¶ context execution attribute name
-
KWARGS
= 'kwargs'¶ interception kwargs attribute name
-
TARGET
= 'target'¶ target element attribute name
-
apply_pointcut
(target, function=None, ctx=None)[source]¶ Apply pointcut on input target and returns final interception.
The poincut respects all meta properties such as: - function signature, - module path, - file path, - __dict__ reference.
-
args
¶
-
ctx
¶
-
exec_ctx
¶
-
get_advices
(target)[source]¶ Get target advices.
Parameters: target – target from where getting advices.
-
kwargs
¶
-
proceed
()[source]¶ Proceed this Joinpoint in calling all advices with this joinpoint as the only one parameter, and call at the end the target.
-
set_target
(target, ctx=None)[source]¶ Set target.
Parameters: - target – new target to use.
- ctx (target) – target ctx if target is an class/instance attribute.
-
start
(target=None, args=None, kwargs=None, advices=None, exec_ctx=None, ctx=None)[source]¶ Start to proceed this Joinpoint in initializing target, its arguments and advices. Call self.proceed at the end.
Parameters: - target (callable) – new target to use in proceeding. self.target by default.
- args (tuple) – new target args to use in proceeding. self.args by default.
- kwargs (dict) – new target kwargs to use in proceeding. self.kwargs by default.
- advices (list) – advices to use in proceeding. self advices by default.
- exec_ctx (dict) – execution context.
- target_ctx – target ctx to use in proceeding.
Returns: self.proceed()
-
target
¶
-
exception
b3j0f.aop.joinpoint.
JoinpointError
[source]¶ Bases:
exceptions.Exception
Handle Joinpoint errors
-
b3j0f.aop.joinpoint.
get_intercepted
(target)[source]¶ Get intercepted function and ctx from input target.
Parameters: target – target from where getting the intercepted function and ctx. Returns: target intercepted function and ctx. (None, None) if no intercepted function exist. (fn, None) if not ctx exists. Return type: tuple
-
b3j0f.aop.joinpoint.
is_intercepted
(target)[source]¶ True iif input target is intercepted.
Parameters: target – target to check such as an intercepted target. Returns: True iif input target is intercepted. Return type: bool
-
b3j0f.aop.joinpoint.
super_method
(name, ctx)[source]¶ Get super ctx method and ctx where name matches with input name.
Parameters: - name – method name to find in super ctx.
- ctx – initial method ctx.
Returns: method in super ctx and super ctx.
Return type: