[[TOC]] = Tutorial = == Sahana Eden Essential Guide == Have a look at the [wiki:Book Sahana Eden Essential Guide Book] and follow the tutorial chapters: * [http://en.flossmanuals.net/sahana-eden/customisation/ Customisation] * [http://en.flossmanuals.net/sahana-eden/building-a-new-application/ Building a New Module] * Older doc to merge/deprecate: [wiki:DeveloperGuidelinesNewModule How to add a new Module?] * real-life example: https://github.com/flavour/aidiq/commit/e352bf501295827cc1496362ceccbd6d10e4467a == Other == * [wiki:DeveloperGuidelines/Tutorial/RESTCustomisation REST Customisation] == Python == DeveloperGuidelines/Basics === MVC Architecture === == Model == Defines database tables in: {{{/modules/s3db/modulename.py}}} The Models are loaded 1st within Web2Py processing, before the controllers.[[BR]] So you can import any global modules/set any global variables here.[[BR]] The Models are imported in alphabetical order, so we load the files which other modules depend on 1st, hence naming them appropriately: {{{000_1st_run.py}}}, {{{000_config.py}}}, {{{zz_last.py}}}, etc == View == HTML/Javascript templates in {{{/views/*}}} * 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 == Controller == Python functions in {{{/controllers/modulename.py}}} [[BR]] e.g. {{{ def list_records(): items = crud.select(table) return dict(items=items) }}} Static CSS/Javascript files are stored in {{{/static}}}