wiki:DeveloperGuidelines

Version 90 (modified by Dominic König, 12 years ago) ( diff )

--

Developer Guide

Introduction

Understand the Sahana mission

Before you start on the Sahana project, understand clearly what the project is about and what it strives to accomplish. You can find most of this in the Sahana Overview and objectives

Join the Community

Sahana is developed and guided by a large community of people from around the world, with diverse expertise. As everyone is in different timezones, the heart of this community are the mailing lists, so it is important for you to join it and actively participate in the discussion.

Please join a suitable mailing list and we recommend you read the community mailing list etiquette.

Apart from that you can find a lot of us on #Sahana IRC Chat.

Install a Development Environment

Python

Indentation matters (use 4 spaces instead of Tabs)

More details at: DeveloperGuidelinesCodeConventions

Web2Py

This is an MVC environment (like Rails & Django. Django polls turorial conversion course).

Web2Py can work at several different levels of abstraction.
The SahanaPy 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.

Recommend using the CLI to try out code snippets in the Web2Py environment (gluon, Model):

python web2py.py -S sahana -M

Model

Defines databases in: /models/module.py

The Models are loaded 1st within Web2Py processing, before the controllers.
So you can import any global modules/set any global variables here.
The Models are imported in alphabetical order, so we load the files which other modules depend on 1st, hence naming them appropriately:
00_db.py, 01_RESTlike_controller.py, 02_pr.py, 03_gis.py

Controller

Python functions in /controllers/module.py
e.g.

   def list_records():
       items=t2.itemize(table)
       return dict(items=items)

View

HTML/Javascript templates in /views/module/function.html

  • these are normal HTML/JS files with the ability to add in Python code (e.g. variables) surrounded by brackets: {{ interpreted python here }}
  • there should be an .html file available for each function in the module (name normally being the same as the function)
  • these normally inherit from views/layout.html which also includes the JavaScript from views/*_ajax.html
  • if there is no view defined then a default view will be displayed, which will show the values of all the data it can see, but not be formatted nicely

Static CSS/Javascript files are stored in /static

Javascript

Reserved Keywords

Developer Guidelines

TranslatedPages

Note: See TracWiki for help on using the wiki.