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.


Get target advices.

Parameters:target – target from where getting advices.

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.

  • 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.

  • 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.


exception b3j0f.aop.joinpoint.JoinpointError[source]

Bases: exceptions.Exception

Handle Joinpoint errors


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

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.

  • name – method name to find in super ctx.
  • ctx – initial method ctx.

method in super ctx and super ctx.

Return type:



Find a Pointcut ctx which is a class/instance related to input function/method.

Parameters:elt – elt from where find a ctx.
Returns:elt ctx. None if no ctx available or if elt is a None method.

Get base ctx.

Parameters:ctx – initial ctx.
Returns:base ctx.