Some of the information here may be outdated, please check the book instead

New in version 1.27

by Limodou is a commandline tool, you can use it to do some testing work. You can find it in web2py installation folder. If you want to test some appliance just run:

on Unix

python2.5 -S appname

on Windows

web2py.exe -S appname

And it'll prepare a web2py environment for appname, and then go into interactive mode. So you can test controller or model or other python code there. For example, type:

>>> INPUT(_name='name', _type='text').xml()
'<input type="text" name="name"/>'

And if you've installed ipython tool, it'll automatically find the ipython and use it. Other command line options:

-P, --plain to ignore IPython and use a regular shell

-M, --import_models it'll automatically find all model files in app's models folder, and then execute them in web2py environment. So you can directly use your db objects defined in model files. Have fun with it. Requires version 1.28 or later.

ATTENTION: Notice that while in models and controllers commit/rollback is automatic, in the shell you have to explicitly db.commit() or db.rollback() your transactions.

© 2008-2010 by Massimo Di Pierro - All rights reserved - Powered by web2py - design derived from a theme by the earlybird
The content of this book is released under the Artistic License 2.0 - Modified content cannot be reproduced.