I wanted to add a decorator function that wraps a bottle request decorated function within a class, I tried doing it using inspect but I am unable to see any changes done by the decorator when I am calling this request.
This is my code :
import inspect
from bottle import run, route, template, get, post, request, delete, redirect
def decorator_jwt(func):
def wrapper(*args, **kwargs):
print("Decorator 1 executed")
return func(*args, **kwargs)
return wrapper
def decorator_for_class(cls):
for name, method in inspect.getmembers(cls):
if (not inspect.ismethod(method) and not inspect.isfunction(method)) or inspect.isbuiltin(method):
continue
print("Decorating function %s" % name)
setattr(cls, name, decorator_jwt(method))
return cls
@decorator_for_class
class python_functions:
@route('/')
def show_index():
#something0
@get('/api/V1/something')
def Reboot():
#something
@get('/api/V1/something2')
def umountDevice():
#something2
@post('/api/V1/random/something3')
def LogOut():
#something3