Wrapper-function Pattern

1
2
3
4
5
6
7
8
9
def wrapper_function(*args, **kwargs):
    arg_names = original_function.func_code.co_varnames
    params = dict(zip(arg_names, args))
    params.update(kwargs)
    
    # now you have args and kwargs collected to the dictionary params
    # you can read and modify them here and then call the original function
    
    return original_function(**params)

More like this

  1. keywords arguments parser for custom template tags by bruno 4 years, 3 months ago
  2. Other approach of making middleware (by decorators) by diverman 2 years, 2 months ago
  3. A templatetag to insert the output of another view (or local URL) by jamesgpearce 3 years, 11 months ago
  4. Resolve URLs to view name and args/kwargs by fahhem 2 years, 6 months ago
  5. Owner required decorator by polarbear 4 years, 10 months ago

Comments

(Forgotten your password?)