I hope this will save time to others wich struggle with setting up 
Eclipse+PyDev+GAE SDK, Windows environment and ot be able to step up in *
default.py* with the PyDev debugger.

Using GAE, setting up a development environment is very tricky but I 
managed to set it up. That is what I came out with up to now.

Instructions: Setting up Eclipse+PyDev+GAE, Windows

1) web2py trunk source, install under root/app, app.yaml -> configure for 
you GAE app.
2) your app - build under root/*app*/applications/*myapp. I*t is a matter 
of copy/paste to add/replace your app there. Copy *myapp *at separate 
folder like backup/*myapp *and you can use bitbucket for source control. It 
has a free private hosting for up to 5 collaborators.
3) download GAE SDK source copy *google.appengine* directory on the same 
level as gluon - web2py will find for example *import google.appengine.ext * 
only 
that way.
in your app.yaml exclude *google.appengine* directory explicitly.
4) set all GAE dependencies in *db.py *- when you fire up the debugger, the 
breakpoints stop in *db.py* but nowhere else ( a few places actually).
5) make function in *db.py:*
def *MyHook()*: 
  pass  <-- set up a breakpoint in your Eclipse here.
6) in your *default.py* place *MyHook() *where you want a breakpoint to 
stop.
Breakpoints doesn't stop anywhere else but a few places like *db.py. *I 
suppose
default.py is run time compiled and does not works with source code.
7) in Eclipse point to root/*app - right click Debug As,* Properties - find 
the directory paths - add root/*app*/applications/*myapp *- so Eclipse can 
find your app source to stop in debugging.
8) run * Debug As,* Eclipse fires, your debugger stops at 
def *MyHook()*: 
  pass <--
click with F5 to follow the link and you are in default.py, from there with 
F5 you can follow your code in default.py.


Running with the debugger you can see where your code can be optimized. For 
example I mentioned 0.py, db.py, all files under models/ are loaded every 
time a link is visited. 
This slows down the execution and you will need to place everything db GAE 
related in db.py
and 0.py. In 0.py you place the constants, in db.py - GAE db stuff. This is 
the most code separating wise can be made under web2py. Otherwise loading 
all these /models files every time slows things up in real usage mode.



Reply via email to