You cannot "import" web2py models and controllers. Because they can only be executed in the web2py environment. They use keywords (request, response, etc.) that are not defined on import.
On Nov 25, 5:22 am, selecta <[email protected]> wrote: > but i do not want to run this code in the shell but in a controller > > controllers/test.py > > def test(): > 'this is a test' > import applications.myapp.controllers.test > return dict(a = dir(applications.myapp.controllers.test)) > > i have similar problems for other objects like db, request ... > what i want to do in the end is to use the inspect module to create > source code documentation > > On Nov 25, 11:44 am, ron_m <[email protected]> wrote: > > > It should work if you run web2py in shell mode and run the models, > > this will define auth. > > > python web2py.py -S myapp -M > > > then do the import etc. > > > I just tried it on my own app, worked ok. The __init__.py had to be > > there (it was empty). > > > Ron > > > On Nov 25, 1:58 am, selecta <[email protected]> wrote: > > > > Is it possible to access the docstrings of controller functions? > > > i tried the following: > > > > I added __init__.py to the controllers folder > > > and wrote > > > import applications.myapp.controllers.mycontroller > > > print dir(applications.myapp.controllers.mycontroller) > > > > however this gives me > > > ... > > > @auth.requires_login() > > > NameError: name 'auth' is not defined > > > > because I use the @auth decorators > > > > is there another way? > >

