On Monday, September 5, 2011 12:18:28 PM UTC-4, Ramos wrote:
>
> hello, i dont like the shell in the admin because in windows i cannot 
> repeat last command also the pythonwin is way more friendly...
>
> 1 - in windows how can i do the shame as the admin shell using pythonwin or 
> just command line python?
>

I'm not sure you can use PythonWin, but open a command window (cmd.exe), 
change directory to your \web2py folder, and enter:

python web2py -S your_app -N -M

You'll get the web2py environment (including the models for your app) in a 
Python shell. Note, -N tells it to turn off cron, and -M tells it to run the 
models from your app. 
See http://web2py.com/book/default/chapter/04#Command-Line-Options.

 

> 2 - in windows in command line python how do i execute a function in a 
> controller?
>

When you run the web2py shell (as described above), you can tell it to run a 
particular controller and function:

python web2py -S your_app/your_controller/your_function -N -M

Note, you could also just do your_app/your_controller, and once you're in 
the shell, you can run any function within the controller.

Here's a simple batch file you can adapt -- when you click it, it will 
prompt you for an app (which can include app/controller/function), and it 
will change to the web2py folder and start the shell for you:

@echo off
set /P app="Enter web2py app/controller/function to run in the shell 
(controller/function optional): "
cd c:\path\to\web2py
python web2py.py -S %app% -M -N


If you want a nicer command window in Windows, in any command window, click 
the icon in the upper left, and select Defaults from the menu. There you can 
change the window size and position, colors, etc., and the changes will 
affect all command windows.

Anthony

Reply via email to