which is the better way to decorate a callback?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

which is the better way to decorate a callback?

sebastian lópez
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

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: which is the better way to decorate a callback?

sebastian lópez
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 <a href="http://pypubsub.readthedocs.io/en/v4.0.0/usage/usage_basic_tasks.html" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fpypubsub.readthedocs.io%2Fen%2Fv4.0.0%2Fusage%2Fusage_basic_tasks.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGbDOov9OLSmqEhIdmzYs-pF-jxaA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fpypubsub.readthedocs.io%2Fen%2Fv4.0.0%2Fusage%2Fusage_basic_tasks.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGbDOov9OLSmqEhIdmzYs-pF-jxaA&#39;;return true;">http://pypubsub.readthedocs.io/en/v4.0.0/usage/usage_basic_tasks.html
So, what method you will recomend me?

here is my aproach ...

<a href="https://gitlab.com/Selobu/wxs/blob/master/examples/test_wxs.py" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgitlab.com%2FSelobu%2Fwxs%2Fblob%2Fmaster%2Fexamples%2Ftest_wxs.py\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHUKaRdQoDT6OGTuk7aDVPPtpnWoQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgitlab.com%2FSelobu%2Fwxs%2Fblob%2Fmaster%2Fexamples%2Ftest_wxs.py\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHUKaRdQoDT6OGTuk7aDVPPtpnWoQ&#39;;return true;">https://gitlab.com/Selobu/wxs/blob/master/examples/test_wxs.py

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.