Version 206 (modified by 12 years ago) ( diff ) | ,
---|
Developer Guidelines
Table of Contents
Getting Started
Development Process
- Projects
- BluePrints
- using Git for getting your changes integrated into Trunk
Development Enviroment
- Install a Development Enviroment
- Using git Version Control
Framework
Other Resources
- Tips - useful links to explore
Uncategorized
These pages need to be sorted into their appropriate category on this page. (DeveloperGuidelines)
- DeveloperGuidelinesBzrWindows
- DeveloperGuidelinesCreateReadUpdateDelete
- DeveloperGuidelinesCron
- DeveloperGuidelines/CustomPages
- DeveloperGuidelinesDataTables
- DeveloperGuidelinesDatabaseSynchronization
- DeveloperGuidelinesDeletableList
- DeveloperGuidelines/DeploymentSettings
- DeveloperGuidelines/Eclipse
- DeveloperGuidelinesLibraries
- DeveloperGuidelines/Logistics
- DeveloperGuidelines/Menus
- DeveloperGuidelines/Messaging
- DeveloperGuidelines/Organisations
- DeveloperGuidelinesPopup
- DeveloperGuidelines/PrePopulate
- DeveloperGuidelines/SaveSearchAndSubscription
- DeveloperGuidelines/Scheduler
- DeveloperGuidelines/Search
- DeveloperGuidelinesSubmenus
- DeveloperGuidelinesSubtypes
- DeveloperGuidelinesSurvey
- DeveloperGuidelines/UserManagement
- DeveloperGuidelinesWebServices
- DeveloperGuidelines/WebSetup
- DeveloperGuidelines/de
- DeveloperGuidelinesCRUDManual
- DeveloperGuidelinesGISInAction
- DeveloperGuidelinesRESTCustomisation
- DeveloperQuickstart
Python
Indentation matters (use 4 spaces instead of Tabs)
- http://diveintopython.net
- http://openbookproject.net/thinkcs/python/english2e/
- http://software-carpentry.org
- Python v2 documentation: http://docs.python.org/ (We are currently using v2.7.)
- Style Guide: http://www.python.org/dev/peps/pep-0008/
- lxml (XML I/O): http://codespeak.net/lxml/tutorial.html
More details at: DeveloperGuidelines/CodeConventions
Web2Py
This is an MVC environment (like Rails & Django. Django polls tutorial conversion course).
Web2Py can work at several different levels of abstraction.
The Sahana Eden framework (S3) is built on Web2Py's Auth/Crud classes in tools.py
(with some remnants of the older T2), however sometimes we need more control therefore need to drop down a level or two.
- Web2Py recommends the official book)
Recommend using the CLI to try out code snippets in the Web2Py environment (gluon, Model):
python web2py.py -S eden -M
Can execute a controller to be able to access its functions using:
execfile("applications/eden/controllers/mycontroller.py", globals())
Web2Py can be extended through Plugins & also has a recipes site.
Javascript
- W3Schools' basic JS: http://www.w3schools.com/js/
- jQuery is used for client-side business logic (hiding fields, opening up tabs, etc):
- Tutorial 1: http://docs.jquery.com/Tutorials:How_jQuery_Works
- Tutorial 2: http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery
- Main reference: http://docs.jquery.com
- We use some plugins: http://plugins.jquery.com
- & some Widgets: http://jqueryui.com
- ExtJS is used for some advanced widgets:
- S3 includes a cross-browser debug utility (only shows up when ?debug=1):
s3_debug('message', value);
All global variables should be in the S3 namespace:
Private variables should be protected, e.g. using the Module Pattern:
- http://yuiblog.com/blog/2007/06/12/module-pattern/
- http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-Depth
Can test out the performance of different options to achieve a task using:
Can check quality using JSLint:
Deployment
Browsers default to only downloading 2 files from the same origin at a time, so many files is very slow on high latency links.
We therefore consolidate into fewer, larger files when running in Production mode.
Although, note that iPhone 3.x cannot cache files larger than 15kb and in iPhone 4 the limit is 25kb. And this is the size before gzipping.
Since GIS is a specialised app which requires many files, it's JS is loaded separately when required.
The build script is static/scripts/tools/build.sahana.py
It needs to be run as a web2py script:
python web2py.py -S eden -M -R applications/eden/static/scripts/tools/build.sahana.py
There is also a convenience wrapper for Windows to run this: static/scripts/tools/build.cmd
You must have an internet connection to run the build script unless you have a local version of the Compiler.
Our build process is based on the one used by OpenLayers
This uses Google's Closure compiler to compress the JS. This is done using their web service, however for OpenLayers itself we need to download the jar file & place in the tools folder since this is over 1Mb:
ToDo: Investigate using other options instead:
- http://developer.yahoo.com/yui/compressor/
- http://www.crowproductions.de/repos/main/public/packer/jspacker.py
ToDo: Download/execute scripts asynchronously:
Mobile
- Android - Android clients
XSLT
- XSLT - Stylesheets for XML & JSON Import/Export