AlterEgo
old web2py blog
Useful Links
List all entries
Book
Interactive Examples
F.A.Q.
Free Applications
Plugins
Recipes
Demo of Admin Interface
Semantic web extension
Some of the information here may be outdated, please check the book instead
Edit page
Title:
Security Code:
Body:
(use
this
wiki markup)
This document explains how to use Eclipse with web2py. It was tested on the cookbook example. The only notable things so far are: - make a new project, unchecking the default, and choosing the root folder as the location (where web2py.py is located) - add `__init__.py` modules where you want to be able to import things from your own code. Only models have been tested so far. - add the web2py root folder as a project source folder for the python path. On the mac version I am using this is the Resources folder, again where the web2py.py file is located - download the web2py source and add the web2py source root as an external source folder - (OPTIONAL) Go to Preferences > Pydev > PyDev Extensions > Auto Imports, and uncheck "Do auto imports?" One gotcha is make sure you choose the correct case: return dict(records=SQLTABLE(records)) There are two SQLTABLE: SQLTABLE and SQLTable. The lower case one does not need to exposed since it is not intended to be instantiated by the user. The upper case one is being used to output html, and is the one we want. As Python is case sensitive, you would not get the expected outcome if you choose the wrong item. To let Eclipse know about variables being passed into the controller at runtime, you can do the following global db global request global session global reqponse This will remove the warnings about them being undefined. Typing `redirect` will get the correct import and you can use it normally. To use `session`, `request` and (theoretically but untried) `response` with hints and code completion, you can use this code: req=Request() req=request ses=Session() ses=session resp=Response() resp=response as you type those you will get the imports for these objects as well: from gluon.globals import Request from gluon.globals import Session from gluon.globals import Response Then you can use `req` as you would with `request` but with code hinting, etc., and `ses` for `session`, and `resp` for `response`. If anyone knows a better way to cast `request`, `session`, and `response` as their correct types, please do leave a comment. Code hints and completion in Eclipse is very nice and provide a valid alternative to the web2py built-in editor. Unfortunately you do not get the code hints unless you also import the statement. If you choose to keep "Do auto imports?" checked, imports from your own models, controllers, etc., may throw errors. You can review those and delete the undesired imports. Or perhaps simply use it as a memory aid and keep typing without selecting the object so as to not trigger the auto import. Please note that this is still a work in progress!
© 2008-2010 by Massimo Di Pierro - All rights reserved - Powered by
web2py
- design derived from a theme by
the earlybird
The content of this book is released under the
Artistic License 2.0
- Modified content cannot be reproduced.