Reputation: 1625
I'm trying to import external modules into my controller code for a web2py application. The module I'm importing is located in myapp/modules and seems to import fine. However, it doesn't let me call any of the functions defined in there; gives the following error 'module' object has no attribute 'testfunc'
I'm importing like this:
import json_utils as u
And calling like this:
u.testfunc()
Am I missing something obvious here? I have tried stop/starting the server in case its not reloaded the file.
Cheers
EDIT: Here is the entire json_utils.py file:
def testfunc():
return 3
def testfunc2():
# some stuff
return 5
Upvotes: 0
Views: 757
Reputation: 1625
Problem is web2py caching external modules. Stop/Starting the server is not enough, I need to kill the whole thing are reboot.
Upvotes: 1
Reputation: 1
The module json_utils has no built-in function testfunc()
for example if I do
import random
u.nonfunction()
and then I run it I get
AttributeError: 'module' object has no attribute 'nonfunction'
but if I do a function that it has
import random
random = u.randrange(1,10)
print(random)
It works properly
Upvotes: 0