[web2py] Re: DAL not working in shell

2011-03-25 Thread DenesL

Please tell us how do you start the shell, which OS and which version
of web2py are you using.

On Mar 25, 12:12 am, Nosnam nos...@gmail.com wrote:
 I'm following along with the web2py book, and got hung up in Chapter
 6:http://web2py.com/book/default/chapter/06#DAL,-Table,-Field

 When I do the following: db = DAL('sqlite://storage.db') absolute
 nothing happens after I press enter. Nothing happens in the console,
 no errors pop up in the error log, 'db' is still undefined if I try to
 reference it.

 As a test, I did db = 'test' in the shell, then again did db =
 DAL('sqlite://storage.db') and then refenced db, and it was still the
 string 'test'

 Just to test it out, I defined a database in my Models/db.py; I'm able
 to reference it in the shell, but if I try to define_table it doesn't
 actually define the table.

 Do you guys have any ideas of how I can dig deeper to see why it's not
 working?


[web2py] Re: DAL not working in shell

2011-03-25 Thread Kevin Ivarsen
Are you using the shell in the web browser, accessed via the Admin app, or 
the command line shell?

There are currently some limitations in the browser-based shell that prevent 
things like database connections and open file handles from working. 
(Speaking more precisely, the online shell can only store variables 
comprising entirely of objects that can be serialized with Python's pickle 
module.)

A week or two ago I proposed some changes to the online shell that would 
remove these limitations and never heard back from anyone about it. However, 
I'm now searching for the post and can't find it, so perhaps the post never 
actually made it up. I'll pull together my notes and post again when I have 
a chance.

Anyway, to solve your immediate problem, I believe you want to use the 
command line web2py/python shell instead. Assuming you are running the 
source distribution of web2py, open a command prompt / terminal, cd to your 
web2py directory, and run:

python web2py.py  --shell=welcome

This launches an interactive shell in the context of the welcome 
application. You may replace this with your own application name if you 
wish.

If you run into trouble, re-post with your operating system and which 
distribution of web2py you are running (source, Windows, or Mac) and I can 
give you more specific instructions.

Kevin


[web2py] Re: DAL not working in shell

2011-03-25 Thread Kevin Ivarsen
I see that the web2py book describes tarting the shell in Chapter 2 under 
Starting Up:
http://web2py.com/book/default/chapter/02#Starting-up

However, I think Chapter 6 should clarify that you need to use the command 
line shell and not the browser-based shell for doing the interactive 
examples, at least until the limitation is fixed in the online shell.

Kevin 


[web2py] Re: DAL not working in shell

2011-03-25 Thread ron_m
It is in web2py-developers


[web2py] Re: DAL not working in shell

2011-03-25 Thread ron_m
Sorry should have put in link for interest of others, the post on the DAL 
shell by Kevin is in web2py-developers at

https://groups.google.com/forum/?pli=1#!topic/web2py-developers/AbBiV8hoLIw


[web2py] Re: DAL not working in shell

2011-03-25 Thread Nosnam
Thanks for the help everyone! It was just as you expected, I was
trying to create database connections with the browser-based shell
instead of the console shell. Everything seems to work fine in the
console. It would be nice to see Kevin's proposed changes to the
browser-based shell get rolled into web2py, or at least the change in
Chapter 6 noting which shell to use.


[web2py] Re: DAL not working in shell

2011-03-25 Thread Nosnam
Thanks to everyone for the help! It was as you expected, I was trying
to create (and manipulate) the database using the browser-based shell.
I switched to the command line shell and it worked fine. It would be
great to see Kevin's proposed changes to the browser-based shell, or
at least a mention of this in chapter 6.