Version 46 (modified by 13 years ago) ( diff ) | ,
---|
Table of Contents
Developer Guidelines - Eclipse
Eclipse is a full IDE supporting Debugging & Code Completion.
PyDev is an Eclipse module which supports Python.
Installation
An Eclipse install with PyDev included is available in the 75Mb zip file which also includes Web2Py & Eden:
or install manually:
- Install Java JDK
- Install Eclipse (setup for 3.6 is documented below):
- Look for "Latest release" on the downloads page.
- (For Linux, and also
apt-get install eclipse-platform
but may get old version.)
- If using JDK 6u21: modify eclipse.ini
- Install PyDev through Eclipse:
- Help menu > Install New Software
- Work with: http://pydev.org/updates
- Add, OK
- tick PyDev (can exclude the optional PyDev Mylyn Integration), Next, Next, Accept, Finish
- tick to trust certificate, Restart now
- Recommend installing Psyco to speed-up Python in Eclipse:
- Linux: http://psyco.sourceforge.net/
- Windows: http://www.voidspace.org.uk/python/modules.shtml#psyco
Configuration
- Set up the Python Interpreter:
- Window > Preferences > PyDev > Interpreter - Python. Click New
- On Windows: Browse to python26/python.exe (or python27/python.exe if using 2.7), OK, OK
- On Linux: "python" is the name of the interpreter, the location is "/usr/bin/python", OK, OK
- Window > Preferences > PyDev > Interpreter - Python. Click New
- Add a new PyDev Project:
- File > New > Project...
- Open the PyDev folder, and choose PyDev Project
- Give the project a name "web2py"
- Un-tick "Use Default"
- Grammar Version (should be 2.6 in the Linux VM)
- Browse to the web2py directory (on the Linux VM, this is in
/home/web2py
) - Un-tick "Create default 'src' folder and add it to the pythonpath"
- Click Finish
- Click "No" when asked to open the perspective
- Debug Configuration:
- From the Run menu, choose Debug Configurations...
- Double-click Python Run
- On the Main tab: Name: Enter (e.g.) web2py
- Project: Select web2py (should be the only option)
- On the Main tab: Browse to web2py.py (on the Linux VM, this is
/home/web2py/web2py.py
) - On the Arguments tab: Type in the program arguments: "-a password" (Choose a password for web2py and substitute it for "password".)
- Click Apply
- In the Packages tab, select web2py.
- Click Debug (If you get an error saying $project_loc is empty, click OK. Then select web2py in the Packages tab and Run -> Debug.)
- On Windows: If asked, unblock in Windows Firewall (not necessary on the Linux VM)
- Miscellaneous suggestions for comfort and convenience:
- Right-click on Java perspective in top-right & select Close
- Window > Open Perspective > Other > Debug
- Window > Show View > Expressions
- Window > Show View > Expressions > Other > PyDev > PyDev Package Explorer
(This is where you will need to select web2py before trying Run or Debug to avoid the empty $project_loc error.) - Drag the Expressions, Console, Tasks tabs to the upper right, where the Variables tab is. Drag PyDev Package Explorer to the upper left where Debug is. (This leaves more space for the editor view.)
- Window > Customize Perspective > Go through the tabs and untick PyDev Debug. Click OK
- Set your default HTML editor
- From the Window menu, choose Preferences
- Under General section on the left
- Open the Editors section
- Choose File Associations
- Highlight .htm
- Click "Add..."
- Choose "Text Editor"
- Click OK
- Repeat the process with .html
- Click OK
- Window > Preferences > General > Editors > Text Editors
- tick Show line numbers
- tick Show Print Margin and set the margin to 80 (to assist in our vain attempt to keep within that width)
- Window > Preferences > General > Workspace
- tick 'Refresh on access'
- untick 'Build automatically'
- You may want to change the layout of the window by dragging sections to convenient regions of the window and resizing them. Combine less-used sections as tabs in the same region.
Debugging with Eclipse
- Set and remove breakpoints by double clicking in the margin of the code file
- Click the 'Debug Sahana Eden' button
- F5 Step into functions
- F6 Step over lines
- F7 Step out of functions
- Use expressions (drag and drop from code) or right-click > watch
Accessing private data
Some data is marked as private to let other developers know they shouldn't access this directly
- e.g. in
s3xrc.py
we haveS3Resource.__set
&S3Resource.__query
This then means that Eclipse can't see these attributes as self.__set
, etc.
Instead need to use:
xxx._ClassName__AttributeName
e.g.:
resource._S3Resource__query resource._S3Resource__set
Bzr integration (optional)
- http://wiki.bazaar.canonical.com/BzrEclipse
bzr checkout --lightweight lp:bzr-xmloutput cd bzr-xmloutput python setup.py install cd ..
Related Links
Other Configuration Guides (should not be required):
- http://kollerie.wordpress.com/2009/04/07/setting-up-your-ide-for-web2py-development/
- (Simpler Instructions) http://allisterx.blogspot.com/2009/06/using-web2py-framework-on-eclipse.html
Note:
See TracWiki
for help on using the wiki.