You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web2py-users
There is a function in models/utils.py called int_or_None. I'd like to be able to use this functions in modules. Is there a way to do this? If not, where would be the best place to keep this int_or_None function in order to make it accessible to the entire application? Thanks.
Leonel Câmara
unread,
Apr 18, 2016, 6:13:37 AM4/18/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web2py-users
This could be done, but it's a bad idea, just put the function itself in a module too instead of defining it in the models.
mfarees...@gmail.com
unread,
Apr 18, 2016, 6:17:26 AM4/18/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web2py-users
I want to use this function in multiple module files. Copying it over to each one of those files does not seem like a good idea. Is there some other approach to tackle this cleanly?
Anthony
unread,
Apr 18, 2016, 8:28:36 AM4/18/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
I want to use this function in multiple module files. Copying it over to each one of those files does not seem like a good idea. Is there some other approach to tackle this cleanly?
No, just put it in one module file and import it into any others where you need it -- that is the way Python works.
Anthony
mfarees...@gmail.com
unread,
Apr 18, 2016, 9:07:35 AM4/18/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web2py-users
I tried that but it did not work. I added the function to modules/common.py. Then I used import common and called the function using common.int_or_None(x). After doing this I ran my pytests but they failed on the import statement. This is the error I got:
'thread._local' object has no attribute 'auth'
Anthony
unread,
Apr 18, 2016, 9:13:55 AM4/18/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web2py-users
Sounds like a problem in your code. We need to see the code and the traceback.