which is the better way to decorate a callback?

Hi, good morning

I would like to decorate a callback to set user permisions where the callback isn´t inside a class

for example

@subscribre(‘topic’)
@is_login
@is_admin
def callbackfunc(*args, **kargs):
# doing something
return

``

If I used Pubsub system then it fails as in http://pypubsub.readthedocs.io/en/v4.0.0/usage/usage_basic_tasks.html
So, what method you will recomend me?

here is my aproach …

https://gitlab.com/Selobu/wxs/blob/master/examples/test_wxs.py

I also added a thread option as a decorator argument, so It can be easy to convert a function callback into a not blocking function.

@miruta.route(‘primero’, nonblocking=True)
def hola(name, control):
time_sleep = randint(1,40)/10
sleep(time_sleep)
print(‘this will not block your app’)

···

El jueves, 12 de abril de 2018, 6:41:26 (UTC-5), sebastian lópez escribió:

Hi, good morning

I would like to decorate a callback to set user permisions where the callback isn´t inside a class

for example

@subscribre(‘topic’)
@is_login
@is_admin
def callbackfunc(*args, **kargs):
# doing something
return

``

If I used Pubsub system then it fails as in http://pypubsub.readthedocs.io/en/v4.0.0/usage/usage_basic_tasks.html
So, what method you will recomend me?

here is my aproach …

https://gitlab.com/Selobu/wxs/blob/master/examples/test_wxs.py