>
> First, I want to learn what Setup is needed for me to try out web2py
> examples like the following shown in the web2py book
> >>> print str(DIV("hello world"))
> <div>hello world</div>
> I tried using
> >>>import gluon
> but that did not work. I added web2py in sys.path but the above import
> still did not work.
> I found gluon in library.zip folder. Am I supposed to add web2py/
> library.zip to the sys.path? If not, how can I get the web2py example
> statements to work?
>
If you have library.zip, that means you are using the web2py binary version
for Windows. That version includes its own Python interpreter, so when you
run web2py, it is not using your computer's installation of Python, and if
you run your computer's Python shell, it won't have access to web2py. If
you've already got Python installed, you're probably better off running
web2py from source -- just download and unzip the source version (on
Windows, make sure you also have http://sourceforge.net/projects/pywin32/
installed). It's just as easy as running the binary -- instead of
web2py.exe, you'll see web2py.py -- you can either double click that, or
run from shell with "python web2py.py".
To run the examples in the book, the best method is to start a web2py shell:
python web2py.py -S appname -M -N
That starts a Python shell in the environment of the web2py app named
"appname", including the entire web2py API. The -M tells it to run the
app's model files, and the -N turns off cron (which you don't need in the
shell). In place of "appname", you can put "appname/mycontroller", which
will expose the functions/objects in the mycontroller.py controller as
well. For more,
see http://web2py.com/books/default/chapter/29/4#Command-line-options.
Anthony