Hello to the community.

 

I want to share with you a simple tool I created to extend the capabilities 
of completion of the DAL code. So far I've only tested PyCham. Experiment 
with other IDEs and tell me. 

 

Given the dynamic nature of Python and how web2py defines the tables, it 
becomes impossible (or very difficult) for the IDE to know the structure of 
these (tables names, fields, etc..). Based on the dummy code in gluon / 
__init__.py to activate the completion code, we can "show" to the IDE 
objects that exist only at runtime, such as tables and fields of the DAL. 

 

Well, suppose we have the following table: 

 

db.define_table ('student', 

                Field ('name'), 

                Field ('age', 'integer'), 

                Field ('career') 

) 

 

We want the IDE to recognize its structure. Here are the steps: 

 

1.       Copy the package "wood" in the "models" directory.


2.       The module zwood.py is the wood activator. Follow the instructions 
explained there. 


3.       Run the "appadmin" of the app. If all went well, a new python 
module should appear in "wood", named prefix_aliases.py. The dummy module 
contains code that simulates the structure of the tables and fields of the 
DAL. 


4.       Comment out the line db = DAL() in gluon.__init__.py to avoid 
possible conflicts. 

5.       Comment / replace db = DAL (...) line by the exec "db = DAL (...)" 
equivalent sentence, to avoid possible conflicts.


6.       Finally, create a model and insert the following: 

if 0: 

    wood.prefix_aliases from import * 

 

7.       Where "prefix" is the value entered in step 2. 

 

Done. If all went well, the completion should work. 

 

I hope you like it.

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