You can install the software from the server or from provided packs on USB flash drives Users of other Linux distributions are without step-by-step help currently – contributions welcomed
http://eden.sahanafoundation.org/wiki/DeveloperGuidelinesEclipse Launch Eclipse tick Use this as the default & do not ask again, Next Right-click on ‘Resource’ in top-right & close Window menu | Open Perspective | Other | Debug Window menu | Open Perspective | Other | PyDev Open the ‘Debug’ perspective. Window menu | Show View | Expressions Set up the Python Interpreter: Window > Preferences > PyDev > Interpreter - Python New, Browse to python26/python.exe, OK, OK Add a new PyDev Project: File > New > Project > PyDev Project > Next untick Use Default Browse to the web2py directory Give the project a name: eden, Next untick &quot;Create default 'src' folder and add it to the pythonpath&quot; Debug Configuration: Run > Debug Configurations > Python Run Name: Sahana Eden Project: Browse to eden Main Module: Browse to web2py.py Arguments tab: Program Arguments: -a password Apply, Debug unblock in Windows Firewall
Look around the filesystem in web2py/applications/eden folder Similar layout structure to other MVC frameworks, such as Ruby-on-Rails
Minimise the time taken to process Manage dependencies No need to import most of the libraries in ‘gluon/’
Deleted Columns / Tables simply Ignored
Take a look at them now Remember that execution order is defined by alphabetical order
Take a look at them now
Take a look at them now
For each of these, you should find at least 1 Model, a single Controller & a folder containing 1 or more Views
Sahana Eden is Resource-centric
Web Services, Mash-ups
Create a new file in the Models folder called ‘vts.py’ & type in the text above. # Text after this symbol is a comment & is ignored If you make a mistake, then the Ticketing system should catch the error & let you know what you did wrong.
No need to create a manual routes entry, unlike other frameworks, like Django
Create a new file in the Controllers folder called ‘vts.py’ & type in the text above.
Note that you’ll need to Register yourself as a user on the system before you’re allowed to create a resource. The 1 st user to register gets the Administrator role by default.
This should be available as a script or an alias ‘w2p’
No need to learn another macro language Can Extend just a single other file Can Include many others
These defaults are why we didn’t need any views for our application.
Create a new folder in the views folder called ‘vts’ & inside that put a new file ‘vehicle_list_create.html’. Type in the text above. Refresh the vehicle page to see the new text: http://127.0.0.1:8000/eden/vts/vehicle
All user-visible text should be localised by calling through T() Amend your view & then update the languages files - the string should now be visible in the list of strings to translate
HTML tags shouldn’t be in the translatable strings If concatenating with strings, need to str() the LazyT 1 st . Tstr() is a convenience function defined within Eden
Open the About page & browse the variables We store our S3 variables in response.s3.*, session.s3.* so as not to pollute the Web2Py namespace
Unique=True is a SQL-level constraint. Open your vts.py from the models directory & add the extra code above. Try to enter bad data: tickets
Validators are DAL-level constraints which produce nice error messages instead of tickets! Validators provide server-side validation & some also provide client-side rendering & validation Add the extra code above to your file & now add bad data to see the difference.
Fields default to type ‘string’. ‘ date’ is the SQL-level field type & also provides the class in the HTML which means we get a date widget Add the extra code above to your file & refresh the page, now enter a date.
Add the extra code above to your file & refresh the page to see the default value
Add this to your controller & try it out
You can check out the languages file again, if you wish: http://127.0.0.1:8000/admin/default/design/eden#languages Update all languages
Add this to your controller & try it out Comment is rendered as ‘column3’ (although can be moved using ‘formstyle’)
Try them out…copy/paste from another controller & then edit…see what effect this has on your module.
Can provide your own custom buttons here – shn_action_buttons are just the common ones. See definition in models/00_utils.py Copy this into your controller file & see what effect this has on your module. This REST ‘post-processor’ has a companion ‘pre-processor’ available too (you can see org.py organsiation() for an example)
URL() is an example of an HTML ‘Helper’ object
Add this text to the file 000_config.py in the models folder. Navigate to the home page to see the module appear both there & on the menu. Try navigating to the module. Module Type 10 means appears in the ‘more’ section of the default modules menu. (Most deployments will create a fully-customised menu anyway)
Add this text to your controller file & now open the module. “ Custom View” is a Doc String One should be added to all functions for automatic documentation generators & interactive browsing of docs You can try this out in the Interactive Shell: w2p execfile(&quot;applications/eden/controllers/vts.py&quot;, globals()) help(index)
Create a file called ‘index.html’ inside the views/vts folder See plain HTML being interspersed with the server-side parsed Python Look at another module’s index.html What’s bad about this index?
Add this text to your controller (outside the functions – e.g. at the top) & see what effect this has on your module.
Copt this text into your model. Note the use of string substitution to define the tablename
Tells SQL that these fields are ‘reference’ fields (i.e. Foreign Keys) - They store integers which are a pointer to the ID field in the other tables.
Copy this text into your Model & refresh the presence page Reusable field defined in models/03_gis.py Includes additional useful configuration such as .requires & .represent
Copt this text into your controller. Try it out. Note the automation of the resource name to minimise the editing after copy/paste of new functions
Copy this text into your model & see what it does for the page IS_ONE_OF() will provide us a dropdown showing license plates, even though we actually store the ID. This is an S3 validator which extends Web2Py’s IS_IN_DB() to support the ‘deleted’ status & also allow the use of lambdas as formatting options.
We can add additional fields into the link table.
Google: web2py dal Try these out in the Web2Py shell Don’t take effect until you db.commit() Beware locking with Sqlite! (e.g. cron tasks) Wipe DB if developing a lot For Production, split Dev/UAT/Prod instances so that you can plan Data Migrations (Live migrations works in most cases, but some do need manual scripts still – not a complete ‘Get out of jail free’).
Don’t take effect until you db.commit()
IS_ONE_OF provides the representation in the dropdown table.field.represent provides the representation in Display/List views Optimise the query – we know we only want a single record & a single field from that record
Add this to your model underneath the definition of the Presence table & try out the URL. No need for dedicated presence() controller
Add this Resource Header to your Controller.
Then plug it into the Controller Take another look
Add a Vehicle Presence & view it on the Map
Can automate the collection of the location information if it makes sense
Whilst we spend a lot of time updating developer documentation, the actual codebase always moves faster, so the source is always the most authoritative source of information.
Web2Py source code very accessible – small enough to be able to grasp the whole thing after not too long FORM defined in gluon/html.py: Dumb HTML elements SQLFORM defined in gluon/sqlhtml.py: Self-processing forms which update the database CRUD defined in gluon/tools.py: Wrappers around SQLFORM REST defined in modules/s3xrc.py: RESTful interface & XML representations If you drop down a level, then need to do things more manually & need to take care of framework issues yourself.
NB Don’t redirect in an onaccept or you’ll break bulk XML imports!
XSLT stored in static
More effort at 1 st but makes subsequent resources much faster to copy/paste
S3’s REST Controller is built on top of Web2Py’s ‘Crud’ controller, so we can also use it’s controls NB Be careful using next or you’ll break bulk XML imports!
Only want this in interactive views, not JSON/XML & not in Popups either
We wrap the underlying CRUD functions within REST