[web2py] launch web2py from python interpreter

61 views
Skip to first unread message

Richard

unread,
Dec 8, 2015, 10:23:24 AM12/8/15
to web2py-users
Hello,

Is there a way to launch web2py from within python interpreter?


Thanks

Richard

Massimo Di Pierro

unread,
Dec 8, 2015, 2:38:33 PM12/8/15
to web2py-users
Not sure what you mean. web2py is a collection of pyhton modules. You can import them and use them as any pyhton module. 

>>> import sys
>>> sys.append('/path/to/web2py')
>>> from gluon.html import DIV, SPAN
>>> print DIV('hello',SPAN('world'))

for your convenience we provide a custom shell (like ipython does) which works as if you were inside an app:

python web2py.py -S appname -M
>>> print db.tables

Richard Vézina

unread,
Dec 8, 2015, 3:12:21 PM12/8/15
to web2py-users
I would like to start web2py rocket instance like what we can do with command line python web2py.py -S appname -M, but from python interpreter.

So, I can start web2py instance when I launch my test run from my test runner script... So I don't have to make sure there is a web2py instance running and I can launch test run in the background...

Richard

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anthony

unread,
Dec 8, 2015, 3:39:12 PM12/8/15
to web2py-users
You probably don't want to run tests by making HTTP calls to web2py running behind a web server (unless doing functional testing, in which case, just start up the built-in server from the command line and then run your tests -- which you can automate with a shell script). Instead, you can run tests in the context of a web2py environment (much like the environment that is constructed in the web2py shell). For an example specifically using py.test, check out https://github.com/viniciusban/web2py.test, in particular, https://github.com/viniciusban/web2py.test/blob/master/tests/conftest.py#L85.

Anthony
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@googlegroups.com.

Richard Vézina

unread,
Dec 9, 2015, 9:59:24 AM12/9/15
to web2py-users
I guess I will fallback with that solution... It is more fonctional testing... I actually remix Vinicius web2py.test example...

Thanks

Richard

To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages