Debug web2py Actions with iPython

My Notes re debugging web2py Actions with iPython

My system

  • Using web2py 2.9.5-stable+timestamp.2014. (Running on Rocket 1.2.6, Python 2.7.5)
  • On Windows XP in C:\web2py

iPython log

Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.

IPython 0.13.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: cd C:\web2py

In [2]: from gluon import shell

In [3]:'fish/default/view_or_add_client_trips/?client_id=2', plain=True, import_models=True)
{'grid': <gluon.html.DIV object at 0x0289C930>}

In [4]:

#debug, #ipython, #web2py

Run Ipython magic functions from your profile startup python script

This is the  setup I did for a Music21 project named “chordMe”.

On WIN XP the .ipython configuration dir is in C:Documents and SettingsAdministrator.ipython

Create a profile for your project.

Open a command line shell and type the following to create a new profile

> ipython profile create chordMe
[ProfileCreate] Generating default config file: u'C:Documents and'

Now add the following python file to:
C:Documents and SettingsAdministrator.ipythonprofile_chordMestartup  file content:
# usage:
#     $ ipython --profile=chordMe

import os
from IPython.core.interactiveshell import InteractiveShell 

# from
# run_line_magic(magic_name, line)
# magic_name : str  "Name of the desired magic function, without ‘%’ prefix."
# line : str "The rest of the input line as a single string."

get_ipython().run_line_magic(u"logstart", u"-o append")
from music21 import *

Running Ipython with the startup commands. 
To the command line say:
> ipython --profile=chordMe

#ipython, #music21, #python