Dear Anthony,

So, just start up a notebook, and at the top, run:
>
> %w2p myapp/mycontroller
>
> and you will get a full web2py environment with the models from myapp as
> well as the (optionally) specified controller (so you can run functions
> from that controller). Should be easy to add an optional command line flag
> to later add other controllers (without overwriting the full environment).
>
>
I am struggling to get this to work.

The following show that the environment works with normal ipython:

 > pwd
/home/js/web2py

> python web2py.py -M -S test
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2014
Version 2.9.5-trunk+timestamp.2014.05.09.15.41.38
Database drivers available: SQLite(sqlite2), SQLite(sqlite3),
MySQL(pymysql), MySQL(MySQLdb), PostgreSQL(psycopg2), PostgreSQL(pg8000),
MSSQL(pyodbc), DB2(pyodbc), Teradata(pyodbc), Ingres(pyodbc), IMAP(imaplib)
Python 2.7.6 (default, Mar 22 2014, 15:40:47)
Type "copyright", "credits" or "license" for more information.

IPython 1.2.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]:


In ipython-notebook I was trying to debug the process following the logic
in your web2py_magic.py:

In [4]:

line = 'test/default'

In [5]:

line = line.split('/')

In [6]:

line

Out[6]:

['test', 'default']

In [7]:

app = line[0]

In [8]:

controller = line[1] if len(line) > 1 else None

    In [9]:

WEB2PY_PATH = os.path.join('/', 'home', 'js', 'web2py')



In [10]:

sys.path.append(WEB2PY_PATH)



In [11]:

environment = gluon.shell.env(app, import_models=True, c=controller,

        dir=os.path.join(WEB2PY_PATH, 'applications', app))

An exception has occurred, use %tb to see the full traceback.
SystemExit: 1



Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/gluon/restricted.py", line 205,
in restricted
    exec ccode in environment
  File "/home/js/web2py/applications/test/models/db.py", line 48, in <module>
    auth.define_tables(username=False, signature=False)
TypeError: define_tables() got an unexpected keyword argument 'signature'

To exit: use 'exit', 'quit', or Ctrl-D.



I get the same exception when I try

%w2p
or
 %w2p test/default.

Lines 43-48 in db.py are

 43 from gluon.tools import Auth, Crud, Service, PluginManager, prettydate$
 44 auth = Auth(db)$
 45 crud, service, plugins = Crud(db), Service(), PluginManager()$
 46 $
 47 ## create all tables needed by auth if not custom tables$
 48 auth.define_tables(username=False, signature=False)$

which was created by the admin app when I created the test app.


I could so far not figure out what is causing this.

When I try another app it complains about 'lazy_tables'

An exception has occurred, use %tb to see the full traceback.
SystemExit: 1



Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/gluon/restricted.py", line 205,
in restricted
    exec ccode in environment
  File "/home/js/web2py/applications/nkb/models/0.py", line 18, in <module>
    lazy_tables=True, bigint_id = True)
TypeError: __init__() got an unexpected keyword argument 'lazy_tables'

REgards
Johann
-- 

Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to