web2py shell vs terminal shell

1,962 views
Skip to first unread message

Michael Herman

unread,
Apr 5, 2013, 4:57:49 PM4/5/13
to web...@googlegroups.com
i remember reading somewhere that it's better to use the built-in shell in web2py, but i can't find the article/post. anyone know (1) if it is "better", and, (2)  if so, why?

Massimo Di Pierro

unread,
Apr 5, 2013, 5:41:48 PM4/5/13
to web...@googlegroups.com
It is not better. The web2py shell is the normal Python shell or the IPython shell if available. The difference is that the code in the web2py shell has already imported for you web2py environment (and optionally the models) so it it like coding in a web2py controller:

>>> python
>>> print db.tables
Error

>>> python web2py.py -S welcome -M
>>> print db.tables
['auth_user', ....]

Anthony

unread,
Apr 5, 2013, 5:43:24 PM4/5/13
to web...@googlegroups.com
By "built-in" shell, do you mean the one in the admin app? I think there are sometimes problems with that (particularly with database operations), so I tend to use the web2py shell in the terminal, which you can start as follows from the web2py directory:

python web2py.py -S yourapp/[optional controller] -M

But you may fine the admin shell works just fine for you, in which case, use it.

Anthony

Michael Herman

unread,
Apr 5, 2013, 5:48:50 PM4/5/13
to web...@googlegroups.com
yes. so when working with DAL directly from the shell it's better to
work from the web2py shell in the terminal rather than the admin app
shell? any idea why?
> --
>
> ---
> You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/XWMt1Pb_2wk/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Anthony

unread,
Apr 5, 2013, 6:13:35 PM4/5/13
to web...@googlegroups.com
Well, give the admin shell a try and see if it works. I just had some problems in the past with db operations not committing (at least on Windows) -- not sure why. I think the terminal shell is easier to use anyway (don't have to type "print" before every command, recall previous command, etc.).

Anthony

Massimo Di Pierro

unread,
Apr 6, 2013, 12:09:40 AM4/6/13
to web...@googlegroups.com
The admin shell has problems maintaining state. I do not consider it reliable. The terminal shell is rock solid. It is a normal pyhton shell.

Nico Zanferrari

unread,
Apr 7, 2013, 6:23:09 AM4/7/13
to web...@googlegroups.com
Yes, Massimo already explained this in the past, and I've added this note on http://web2py.com/books/default/chapter/29/03#Design (under the Shell paragraph):

Be careful using the web based shell - because different shell requests will be executed in different threads. This easily gives errors, especially if you play with databases creation and connections. For activities like these (i.e. if you need persistence) it's much better to use the python command line.

Nico


2013/4/6 Massimo Di Pierro <massimo....@gmail.com>

--
 
---
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.

Giacomo Dorigo

unread,
Aug 13, 2014, 3:41:17 AM8/13/14
to web...@googlegroups.com
Today I discovered an other problem with the admin shell.
If I execute command 1
and then command 2, at this point it will re-execute command 1 too.
If then I execute command 3, it will execute again also 1 and 2.

This is while running web2py from source code on Windows with simple 
python web2py.py 

Massimo Di Pierro

unread,
Aug 13, 2014, 2:04:15 PM8/13/14
to web...@googlegroups.com
Please open a ticket about this. This is a major issue. Perhaps we should remove the web based shell.

Giacomo Dorigo

unread,
Aug 17, 2014, 12:08:36 AM8/17/14
to web...@googlegroups.com
OK, how do I open a ticket?



---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.

To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Massimo Di Pierro

unread,
Aug 17, 2014, 12:18:51 AM8/17/14
to web...@googlegroups.com
https://code.google.com/p/web2py/issues/entry
To unsubscribe from this group and all its topics, send an email to web2py+unsubscribe@googlegroups.com.

Giacomo Dorigo

unread,
Aug 18, 2014, 12:17:29 AM8/18/14
to web...@googlegroups.com
I don't know,
for some reason it does not leave me submit the ticket:

Windows 8
web2py :
2.9.5-stable+timestamp.2014.03.16.02.35.39
(Running on Rocket 1.2.6, Python 2.7.7)

What steps will reproduce the problem?
1. run web2py from source code from a .bat file python path_to_web2py/web2py.py
2. at same time run an other instance of web2py from terminal so: path_to_web2py/web2py.py -S myapp -M
3. start to interact with the db api from the online shell (not from the command line)
4. insert some records
5. truncate the table
6. insert new records

=>> check the table, the old inserts had been repeated again

What is the expected output?
only the new inserts should have been inserted


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

Massimo Di Pierro

unread,
Aug 18, 2014, 12:22:29 AM8/18/14
to web...@googlegroups.com
After truncate the table did you db.commit()?

Giacomo Dorigo

unread,
Aug 20, 2014, 2:10:45 PM8/20/14
to web...@googlegroups.com
no I didn't.
Anyway, now I just tried without opening the two prompt, just opening the GUI from the .bat file, and I didn't truncate the table, I just did an insert. Then I tried to input some other commands and it keeps repeating the insert. So it seems it's not the truncate. 
I tried also the db.commit() but it didn't change the behaviour, the online shell keeps repeating the inserts.
What is strange is that the other day it also repeated the truncate commands, but now I am unable to reproduce that, it only repeats the inserts.


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

Reply all
Reply to author
Forward
0 new messages