Command line options

109 views
Skip to first unread message

Denes L

unread,
May 14, 2020, 7:05:29 PM5/14/20
to py4web
Hello all,

chapter-01 in the documentation says:
"py4web provides multiple command line options which can be listed with --help"
which when executed gives:

Commands:
  call
  run
  set-password
  setup
  shell
  version

with no additional info.
chapter-05 says "Models also make for useful interactive shell sessions when py4web is started with the -M commandline option"

So I am not sure how to start a shell as in web2py:
web2py.py -M -S someapp -a "<recycle>"

I like to have an interactive shell to test some of the things as I code an app.

Thanks,
Denes

Denes L

unread,
May 19, 2020, 6:03:54 PM5/19/20
to py4web
^ bump ^

Jim Steil

unread,
May 19, 2020, 6:08:36 PM5/19/20
to py4web
Denes

does

py4web shell 

help?

Massimo DiPierro

unread,
May 19, 2020, 6:15:46 PM5/19/20
to Jim Steil, py4web
To list commands:

py4web —help

For each command (for example shell)

py4web shell —help

In particular

py4web shell apps

Gives you the shell you seek. Notice the shell is for all the apps, not a single one. You can then import the modules from the apps you need to access.


Denes L

unread,
May 19, 2020, 8:28:38 PM5/19/20
to py4web
Thank you Jim and Massimo.

What threw me off is that sentence in chapter-05 (under the "Model-less applications" heading stating
"Models also make for useful interactive shell sessions when py4web is started with the -M commandline option"

That sounds like the -M option is still available somehow.

Massimo DiPierro

unread,
May 19, 2020, 8:30:50 PM5/19/20
to Denes L, py4web
No. That option is no longer needed. That sentence spilled over from the web2py manual. py4web’s shell is just the regular python shell with apps added to the search path. It no longer needs a special context/environment.

--
You received this message because you are subscribed to the Google Groups "py4web" group.
To unsubscribe from this group and stop receiving emails from it, send an email to py4web+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/py4web/4af79a65-9dc6-48d7-bfb5-af161e2bbdf3%40googlegroups.com.

Manuele Pesenti

unread,
May 20, 2020, 5:01:51 AM5/20/20
to py4...@googlegroups.com
Hi Massimo!

can you give a little example? I tried without success to import the
settings of an application of mine using:

$ py4web shell ./apps
Python 3.6.9 (default, Apr 18 2020, 01:56:04)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from _scaffold import settings
Traceback (most recent call last):
  File "/usr/lib/python3.6/code.py", line 91, in runcode
    exec(code, self.locals)
  File "<console>", line 1, in <module>
ModuleNotFoundError: No module named '_scaffold'
>>> from apps._scaffold import settings
Traceback (most recent call last):
  File "/usr/lib/python3.6/code.py", line 91, in runcode
    exec(code, self.locals)
  File "<console>", line 1, in <module>
ModuleNotFoundError: No module named 'apps'
>>> from ._scaffold import settings
Traceback (most recent call last):
  File "/usr/lib/python3.6/code.py", line 91, in runcode
    exec(code, self.locals)
  File "<console>", line 1, in <module>
ModuleNotFoundError: No module named 'py4web._scaffold'
>>> from .apps._scaffold import settings
Traceback (most recent call last):
  File "/usr/lib/python3.6/code.py", line 91, in runcode
    exec(code, self.locals)
  File "<console>", line 1, in <module>
ModuleNotFoundError: No module named 'py4web.apps'

Thanks!

    Manuele

Denes L

unread,
May 20, 2020, 9:48:47 AM5/20/20
to py4web
Hi Manuele

Running on Windows here.
I have a .bat file to start the shell:

ECHO off
cd C:\w2p\py4web\20200510\
c:\python374\python.exe py4web.py shell apps

In the shell, the following commands work:

from apps.myapp import settings
from apps.myapp import common
from apps.myapp import db

also

from py4web import Session, Cache, Translator, DAL, Field
from py4web.utils.auth import Auth

Regards,
Denes
Reply all
Reply to author
Forward
0 new messages