[[TOC]] = 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: * http://eden.sahanafoundation.org/Sahana-Eden.zip or install manually: 1. Install [http://java.sun.com/javase/downloads/widget/jdk6.jsp Java JDK] 2. Install Eclipse (setup for 3.6 is documented below): * Look for "Latest release" on the [http://download.eclipse.org/eclipse/downloads/ downloads page]. * (For Linux, and also {{{apt-get install eclipse-platform}}} but may get old version.) 3. If using JDK 6u21: [http://wiki.eclipse.org/FAQ_How_do_I_run_Eclipse%3F#Oracle.2FSun_VM_1.6.0_21_on_Windows modify eclipse.ini] 4. Install !PyDev through Eclipse: i. Help menu > Install New Software i. Work with: http://pydev.org/updates i. Add, OK i. tick !PyDev (can exclude the optional !PyDev Mylyn Integration), Next, Next, Accept, Finish i. tick to trust certificate, Restart now 5. 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 == 1. Set up the Python Interpreter: i. Window > Preferences > !PyDev > Interpreter - Python. Click New i. On Windows: Browse to python26/python.exe (or python27/python.exe if using 2.7), OK, OK i. On Linux: "python" is the name of the interpreter, the location is "/usr/bin/python", OK, OK 1. Add a new !PyDev Project: i. File > New > Project... i. Open the !PyDev folder, and choose !PyDev Project i. Give the project a name "web2py" i. Un-tick "Use Default" i. Grammar Version (should be 2.6 in the Linux VM) i. Browse to the web2py directory (on the Linux VM, this is in /home/web2py) i. Un-tick "Create default 'src' folder and add it to the pythonpath" i. Click Finish i. Click "No" when asked to open the perspective 1. Debug Configuration: i. From the Run menu, choose Debug Configurations... i. Double-click Python Run i. Enter a name "web2py" i. Project: Browse to web2py (on the Linux VM, this is '/home/web2py') i. On the Main tab: Browse to web2py.py (on the Linux VM, this is '/home/web2py/web2py.py') i. On the Arguments tab: Type in the program arguments: "-a password" (Choose a password for web2py and substitute it for "password".) i. Click Apply i. Click Debug i. On Windows: If asked, unblock in Windows Firewall (not necessary on the Linux VM) 1. Miscellaneous suggestions: i. Right-click on Java perspective in top-right & select Close i. Window > Open Perspective > Other > Debug i. Window > Show View > Expressions i. Window > Customize Perspective > Go through the tabs and untick !PyDev Debug. Click OK i. Set your default HTML editor 1. From the Window menu, choose Preferences 1. Under General section on the left 1. Open the Editors section 1. Choose File Associations 1. Highlight .htm 1. Click "Add..." 1. Choose "Text Editor" 1. Click OK 1. Repeat the process with .html 1. Click OK i. 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) i. Window > Preferences > General > Workspace * tick 'Refresh on access' * untick 'Build automatically' i. 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 have {{{S3Resource.__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 == * [wiki:DeveloperGuidelinesTips#Pythondebugging Debugging Web2Py] 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 ---- DeveloperGuidelines