cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
src.clm.utils.decorators Namespace Reference

Here are placed decorators for CLM views functions targeted to specific CLM role actors (and src.clm.utils.decorators.genericlog() called by all those). More...

Functions

def admin_clm_log
 Decorator for functions requiring admin_clm's privilidges.
def admin_cm_log
 Decorator for functions requiring admin_cm's privilidges.
def auth
def cm_request
 Decorator for CM views functions that:
def genericlog
 Generic log is called by actor decorators defined in src.clm.utils.decorators :
def guest_log
 Decorator for functions requiring only guest's privilidges.
def user_log
 Decorator for functions requiring logged in user's privilidges.

Variables

tuple decorated_functions = set([])

Detailed Description

Here are placed decorators for CLM views functions targeted to specific CLM role actors (and src.clm.utils.decorators.genericlog() called by all those).

Actor decorators

All those decorators call src.clm.utils.decorators.genericlog(). By default those decorators call src.clm.utils.decorators.genericlog with logging disabled. You can enable it by giving kwarg log=True , when decorating, eg.:

@admin_clm_log(log=True)
def get_by_id(cm_id, caller_id, id):
pass
Author
Tomasz SoĊ›nicki tom.s.nosp@m.osni.nosp@m.cki@g.nosp@m.mail.nosp@m..com

Function Documentation

def src.clm.utils.decorators.admin_clm_log (   arg,
  kw 
)

Decorator for functions requiring admin_clm's privilidges.

src.clm.utils.decorators.genericlog is called with parameters:

  • is_user=True
  • is_clm_superuser=True
  • is_cm_superuser=False
Decorated function's declaration
@admin_clm_log[(log=<False|True>)]
function (cm_id, caller_id, *args, **kw)
Decorated function's call
function (cm_id, login, password, *arg, **kw)

password argument is removed by src.cm.utils.decorators.genericlog(), so it doesn't appear in formal parameters of the function.

Definition at line 194 of file decorators.py.

def src.clm.utils.decorators.admin_cm_log (   arg,
  kw 
)

Decorator for functions requiring admin_cm's privilidges.

src.clm.utils.decorators.genericlog is called with parameters:

  • is_user=True
  • is_clm_superuser=False
  • is_cm_superuser=True
Decorated function's declaration
@admin_clm_log[(log=<False|True>)]
function (cm_id, caller_id, **kw)
Decorated function's call
function (cm_id=<cm_id>, login=<login>, password=<password>, **kw)

password argument is removed by src.cm.utils.decorators.genericlog(), so it doesn't appear in formal parameters of the function.

Definition at line 157 of file decorators.py.

def src.clm.utils.decorators.auth (   is_user,
  is_clm_superuser,
  data 
)

Definition at line 208 of file decorators.py.

def src.clm.utils.decorators.cm_request (   fun)

Decorator for CM views functions that:

  • either are fully transparent and just return CM response,
  • or propagate request to CM and further postprocess its response.

Decorated function ought to be defined like:

Decorated function's declaration
@cm_request
def function (cm_response, <kwargs>):
# postprocess cm_response
return cm_response
Decorated function's call
function (cm_id, <kwargs>) # `cm_id` is keyword arg as well, but it's required

Definition at line 336 of file decorators.py.

def src.clm.utils.decorators.genericlog (   log_enabled,
  pack_resp,
  is_user,
  is_clm_superuser,
  is_cm_superuser,
  fun,
  args,
  kwargs 
)

Generic log is called by actor decorators defined in src.clm.utils.decorators :

It calls decorated functions, additionally performing several tasks.

Genericlog performes:

  1. if decorated function requires user or admin privilidges: authorization;
  2. execution of the decorated function;
  3. debug log of the arguments depending on log_enabled and function's success;
  4. if exception is thrown: general exception log.
Returns
(dict) response; fields:
  • status (string) 'ok', if succeeded
  • data (dict) response data

Definition at line 272 of file decorators.py.

def src.clm.utils.decorators.guest_log (   arg,
  kw 
)

Decorator for functions requiring only guest's privilidges.

src.clm.utils.decorators.genericlog() is called with parameters:

  • is_user=False
  • is_clm_superuser=False
  • is_cm_superuser=False
Decorated function's declaration
@guest_log[(log=<False|True>)]
function (**kw)
Decorated function's call
function (**kw)

Definition at line 87 of file decorators.py.

def src.clm.utils.decorators.user_log (   arg,
  kw 
)

Decorator for functions requiring logged in user's privilidges.

src.clm.utils.decorators.genericlog() is called with parameters:

  • is_user=True
  • is_clm_superuser=False
  • is_cm_superuser=False
Decorated function's declaration
@user_log[(log=<False|True>)]
function (cm_id, caller_id, **kw)
Decorated function's call
function (cm_id=<cm_id>, login=<login>, password=<password>, **kw)

Definition at line 120 of file decorators.py.

Variable Documentation

tuple src.clm.utils.decorators.decorated_functions = set([])

Definition at line 64 of file decorators.py.