SlideShare uma empresa Scribd logo
1 de 26
Sahana Eden:
Introduction to the Code
5 November 2010, Sahana Camp
Fran Boon
fran@sahanafoundation.org
Emergency
We have to build an application by lunchtime!
Agenda
‱ Web2Py execution model
‱ S3 REST Controller
– Model
– Controller
– View
Web2Py Execution Model
1. All Models executed every request
– In alphabetical order
– Within web2py environment
2. The Controller is executed
3. The View template is parsed
4. (HTML) page returned to client
Models
‱ Define Tables in Database
Live Migrations:
- Tables created/altered in database
Resources
‱ Common Resources from other Models
– Person
‱ Group
– Location
– Organisation
– Site
‱ Hospital
‱ Shelter
S3 REST Controller
‱ Args:
– /update, /create, /delete
‱ HTTP verbs:
– GET, PUT (POST), DELETE
‱ Representations:
– .html, .json, .xml, .xls, .pdf
Adding a new application
‱ Vehicle Tracking System
‱ Name: vts
‱ Resources:
– vehicle
– driver
– location
Model: Define Table
models/vts.py
# Vehicle resource
table = db.define_table("vts_vehicle",
Field("registration"),
Field("make"),
Field("model"),
Field("supplier"),
)
Controller: S3 REST
controllers/vts.py
def vehicle():
return s3_rest_controller("vts", "vehicle")
View
None needed at 1st – can RAD without them
& then polish later 
Try:
http://127.0.0.1:8000/eden/vts/vehicle
1. Create a vehicle.
2. View in different formats:
– .json, .xml, .xls, .pdf
Coffee
Views: S3 REST
‱ REST has default views
– create.html
– display.html
– list.html
– list_create.html
– update.html
Views
‱ Python code inside {{ }} is parsed server-
side
‱ Views can extend & include other views
‱ Extend ‘layout’ for overall look/feel
{{extend "layout.html"}}
Views: Custom
‱ They can also be customised:
views/vts/vehicle_list_create.html
{{extend "layout.html"}}
{{rheader="Register a new vehicle in the system:"}}
{{include "_list_create.html"}}
Model: SQL constraints
models/vts.py
table = db.define_table("vts_vehicle",
Field("registration", unique=True),
Field("make"),
Field("model"),
Field("supplier"),
)
Model: Field Types
models/vts.py
table = db.define_table("vts_vehicle",
Field("registration", unique=True),
Field("make"),
Field("model"),
Field("purchase_date", "date"),
Field("supplier"),
)
Model: Default Values
models/vts.py
table = db.define_table("vts_vehicle",
Field("registration", unique=True),
Field("make"),
Field("model"),
Field("purchase_date", "date",
default=request.utcnow),
Field("supplier"),
)
models/vts.py


db.vts_vehicle.registration.label = T("License Plate")
Labels
Controller: Comment
controllers/vts.py
def vehicle():
db.vts_vehicle.registration.comment = 
DIV(_class="tooltip", _title="Help text here")
return s3_rest_controller("vts", "vehicle")
How do we Navigate?
‱ Modules menu
‱ Modules list on frontpage
‱ Menu within Module
Enable Module
models/000_config.py
deployment_settings.modules = Storage(


vts = Storage(
name_nice = "Vehicle Tracking System",
description = "Track vehicles",
module_type = 10
),


)
Index page
controllers/vts.py
module = request.controller
def index():
"Custom View"
module_name = 
deployment_settings.modules[module].name_nice
return dict(module_name=module_name)
View
views/vts/index.html
{{extend "layout.html"}}
{{=H2(T(module_name))}}
<p>This module allows users to track their vehicles</p>
{{=LI(A("List Vehicles", _href=URL(r=request,
f="vehicle")))}}
Controller: Menu
controllers/vts.py
response.menu_options = [
[T("Vehicles"), False, URL(r=request, f="vehicle"),[
[T("List"), False, URL(r=request, f="vehicle")],
[T("Add"), False, URL(r=request, f="vehicle",
args="create")] ]]]
Lunch

Mais conteĂșdo relacionado

Mais procurados

Editable Documents on the Web
Editable Documents on the WebEditable Documents on the Web
Editable Documents on the WebMarkku Laine
 
Azure DocumentDB for Healthcare Integration - Part 2
Azure DocumentDB for Healthcare Integration - Part 2Azure DocumentDB for Healthcare Integration - Part 2
Azure DocumentDB for Healthcare Integration - Part 2BizTalk360
 
Scheduled Jobs in Azure
Scheduled Jobs in AzureScheduled Jobs in Azure
Scheduled Jobs in AzureBizTalk360
 
SharePoint 2013 Javascript Object Model
SharePoint 2013 Javascript Object ModelSharePoint 2013 Javascript Object Model
SharePoint 2013 Javascript Object ModelInnoTech
 
The ART of Modern Azure Deployments
The ART of Modern Azure DeploymentsThe ART of Modern Azure Deployments
The ART of Modern Azure DeploymentsBizTalk360
 

Mais procurados (7)

Editable Documents on the Web
Editable Documents on the WebEditable Documents on the Web
Editable Documents on the Web
 
Azure DocumentDB for Healthcare Integration - Part 2
Azure DocumentDB for Healthcare Integration - Part 2Azure DocumentDB for Healthcare Integration - Part 2
Azure DocumentDB for Healthcare Integration - Part 2
 
Visualforce
VisualforceVisualforce
Visualforce
 
Scheduled Jobs in Azure
Scheduled Jobs in AzureScheduled Jobs in Azure
Scheduled Jobs in Azure
 
SharePoint 2013 Javascript Object Model
SharePoint 2013 Javascript Object ModelSharePoint 2013 Javascript Object Model
SharePoint 2013 Javascript Object Model
 
Couch db
Couch dbCouch db
Couch db
 
The ART of Modern Azure Deployments
The ART of Modern Azure DeploymentsThe ART of Modern Azure Deployments
The ART of Modern Azure Deployments
 

Destaque

Introduction to Sahana Eden
Introduction to Sahana EdenIntroduction to Sahana Eden
Introduction to Sahana EdenAidIQ
 
Tech 2 - Introduction to the Code
Tech 2 - Introduction to the CodeTech 2 - Introduction to the Code
Tech 2 - Introduction to the CodeAidIQ
 
Tech 1 - Deploying Sahana Eden
Tech 1  - Deploying Sahana EdenTech 1  - Deploying Sahana Eden
Tech 1 - Deploying Sahana EdenAidIQ
 
Bombeiros Workshop - Introduction to Sahana Eden
Bombeiros Workshop - Introduction to Sahana EdenBombeiros Workshop - Introduction to Sahana Eden
Bombeiros Workshop - Introduction to Sahana EdenAidIQ
 
Sahana Open Source Humanitarian Software Project - Pandemic Preparedness Forum
Sahana Open Source Humanitarian Software Project - Pandemic Preparedness ForumSahana Open Source Humanitarian Software Project - Pandemic Preparedness Forum
Sahana Open Source Humanitarian Software Project - Pandemic Preparedness ForumAidIQ
 
Sahana Camp Radio Exercise
Sahana Camp Radio ExerciseSahana Camp Radio Exercise
Sahana Camp Radio ExerciseAidIQ
 
Simulation: Incidents (SahanaCamp 1.2)
Simulation: Incidents (SahanaCamp 1.2)Simulation: Incidents (SahanaCamp 1.2)
Simulation: Incidents (SahanaCamp 1.2)AidIQ
 
Sahana camp simulation 1.1
Sahana camp simulation 1.1Sahana camp simulation 1.1
Sahana camp simulation 1.1AidIQ
 
Simulation: Instructions ((SahanaCamp 1.2)
Simulation: Instructions ((SahanaCamp 1.2)Simulation: Instructions ((SahanaCamp 1.2)
Simulation: Instructions ((SahanaCamp 1.2)AidIQ
 
General Sessions Hand Outs (SahanaCamp 1.2)
General Sessions Hand Outs (SahanaCamp 1.2)General Sessions Hand Outs (SahanaCamp 1.2)
General Sessions Hand Outs (SahanaCamp 1.2)AidIQ
 
Sahana Camp Simulation
Sahana Camp SimulationSahana Camp Simulation
Sahana Camp SimulationAidIQ
 
Sahana camp incident reporting exercise v3
Sahana camp incident reporting exercise v3Sahana camp incident reporting exercise v3
Sahana camp incident reporting exercise v3AidIQ
 
Humanitarian Mapping - Sahana and OpenStreetMap
Humanitarian Mapping - Sahana and OpenStreetMapHumanitarian Mapping - Sahana and OpenStreetMap
Humanitarian Mapping - Sahana and OpenStreetMapAidIQ
 
Inventory management system
Inventory management systemInventory management system
Inventory management systemcopo7475
 

Destaque (14)

Introduction to Sahana Eden
Introduction to Sahana EdenIntroduction to Sahana Eden
Introduction to Sahana Eden
 
Tech 2 - Introduction to the Code
Tech 2 - Introduction to the CodeTech 2 - Introduction to the Code
Tech 2 - Introduction to the Code
 
Tech 1 - Deploying Sahana Eden
Tech 1  - Deploying Sahana EdenTech 1  - Deploying Sahana Eden
Tech 1 - Deploying Sahana Eden
 
Bombeiros Workshop - Introduction to Sahana Eden
Bombeiros Workshop - Introduction to Sahana EdenBombeiros Workshop - Introduction to Sahana Eden
Bombeiros Workshop - Introduction to Sahana Eden
 
Sahana Open Source Humanitarian Software Project - Pandemic Preparedness Forum
Sahana Open Source Humanitarian Software Project - Pandemic Preparedness ForumSahana Open Source Humanitarian Software Project - Pandemic Preparedness Forum
Sahana Open Source Humanitarian Software Project - Pandemic Preparedness Forum
 
Sahana Camp Radio Exercise
Sahana Camp Radio ExerciseSahana Camp Radio Exercise
Sahana Camp Radio Exercise
 
Simulation: Incidents (SahanaCamp 1.2)
Simulation: Incidents (SahanaCamp 1.2)Simulation: Incidents (SahanaCamp 1.2)
Simulation: Incidents (SahanaCamp 1.2)
 
Sahana camp simulation 1.1
Sahana camp simulation 1.1Sahana camp simulation 1.1
Sahana camp simulation 1.1
 
Simulation: Instructions ((SahanaCamp 1.2)
Simulation: Instructions ((SahanaCamp 1.2)Simulation: Instructions ((SahanaCamp 1.2)
Simulation: Instructions ((SahanaCamp 1.2)
 
General Sessions Hand Outs (SahanaCamp 1.2)
General Sessions Hand Outs (SahanaCamp 1.2)General Sessions Hand Outs (SahanaCamp 1.2)
General Sessions Hand Outs (SahanaCamp 1.2)
 
Sahana Camp Simulation
Sahana Camp SimulationSahana Camp Simulation
Sahana Camp Simulation
 
Sahana camp incident reporting exercise v3
Sahana camp incident reporting exercise v3Sahana camp incident reporting exercise v3
Sahana camp incident reporting exercise v3
 
Humanitarian Mapping - Sahana and OpenStreetMap
Humanitarian Mapping - Sahana and OpenStreetMapHumanitarian Mapping - Sahana and OpenStreetMap
Humanitarian Mapping - Sahana and OpenStreetMap
 
Inventory management system
Inventory management systemInventory management system
Inventory management system
 

Semelhante a Sahana Eden : Introduction to the Code (SahanaCamp 1.2)

SFScon 2020 - Nikola Milisavljevic - BASE - Python REST API framework
SFScon 2020 - Nikola Milisavljevic - BASE - Python REST API frameworkSFScon 2020 - Nikola Milisavljevic - BASE - Python REST API framework
SFScon 2020 - Nikola Milisavljevic - BASE - Python REST API frameworkSouth Tyrol Free Software Conference
 
GHC
GHCGHC
GHCAidIQ
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_HourDilip Patel
 
SharePoint 2013 - What's New
SharePoint 2013 - What's NewSharePoint 2013 - What's New
SharePoint 2013 - What's NewAdventosConsulting
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiTiago Knoch
 
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...Anupam Ranku
 
Building RESTfull Data Services with WebAPI
Building RESTfull Data Services with WebAPIBuilding RESTfull Data Services with WebAPI
Building RESTfull Data Services with WebAPIGert Drapers
 
[Luca/Van Campenhoudt] Microsoft Flow Beyone the Limits: Tips, Pitfalls, Patt...
[Luca/Van Campenhoudt] Microsoft Flow Beyone the Limits: Tips, Pitfalls, Patt...[Luca/Van Campenhoudt] Microsoft Flow Beyone the Limits: Tips, Pitfalls, Patt...
[Luca/Van Campenhoudt] Microsoft Flow Beyone the Limits: Tips, Pitfalls, Patt...European Collaboration Summit
 
Microsoft Flow best practices European Collaboration Summit 2018
Microsoft Flow best practices European Collaboration Summit 2018Microsoft Flow best practices European Collaboration Summit 2018
Microsoft Flow best practices European Collaboration Summit 2018serge luca
 
REST easy with API Platform
REST easy with API PlatformREST easy with API Platform
REST easy with API PlatformAntonio Peric-Mazar
 
Building Your First App with MongoDB
Building Your First App with MongoDBBuilding Your First App with MongoDB
Building Your First App with MongoDBMongoDB
 
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...Lucidworks
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformAntonio Peric-Mazar
 
Resting on your laurels will get you powned
Resting on your laurels will get you pownedResting on your laurels will get you powned
Resting on your laurels will get you pownedDinis Cruz
 
(ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service (ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service BIOVIA
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
Charla desarrollo de apps con sharepoint y office 365
Charla   desarrollo de apps con sharepoint y office 365Charla   desarrollo de apps con sharepoint y office 365
Charla desarrollo de apps con sharepoint y office 365Luis Valencia
 
6 10-presentation
6 10-presentation6 10-presentation
6 10-presentationRemi Arnaud
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformAntonio Peric-Mazar
 

Semelhante a Sahana Eden : Introduction to the Code (SahanaCamp 1.2) (20)

SFScon 2020 - Nikola Milisavljevic - BASE - Python REST API framework
SFScon 2020 - Nikola Milisavljevic - BASE - Python REST API frameworkSFScon 2020 - Nikola Milisavljevic - BASE - Python REST API framework
SFScon 2020 - Nikola Milisavljevic - BASE - Python REST API framework
 
GHC
GHCGHC
GHC
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
 
SharePoint 2013 - What's New
SharePoint 2013 - What's NewSharePoint 2013 - What's New
SharePoint 2013 - What's New
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
 
Building RESTfull Data Services with WebAPI
Building RESTfull Data Services with WebAPIBuilding RESTfull Data Services with WebAPI
Building RESTfull Data Services with WebAPI
 
[Luca/Van Campenhoudt] Microsoft Flow Beyone the Limits: Tips, Pitfalls, Patt...
[Luca/Van Campenhoudt] Microsoft Flow Beyone the Limits: Tips, Pitfalls, Patt...[Luca/Van Campenhoudt] Microsoft Flow Beyone the Limits: Tips, Pitfalls, Patt...
[Luca/Van Campenhoudt] Microsoft Flow Beyone the Limits: Tips, Pitfalls, Patt...
 
Microsoft Flow best practices European Collaboration Summit 2018
Microsoft Flow best practices European Collaboration Summit 2018Microsoft Flow best practices European Collaboration Summit 2018
Microsoft Flow best practices European Collaboration Summit 2018
 
REST easy with API Platform
REST easy with API PlatformREST easy with API Platform
REST easy with API Platform
 
Building Your First App with MongoDB
Building Your First App with MongoDBBuilding Your First App with MongoDB
Building Your First App with MongoDB
 
06 web api
06 web api06 web api
06 web api
 
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
 
Resting on your laurels will get you powned
Resting on your laurels will get you pownedResting on your laurels will get you powned
Resting on your laurels will get you powned
 
(ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service (ATS6-PLAT04) Query service
(ATS6-PLAT04) Query service
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Charla desarrollo de apps con sharepoint y office 365
Charla   desarrollo de apps con sharepoint y office 365Charla   desarrollo de apps con sharepoint y office 365
Charla desarrollo de apps con sharepoint y office 365
 
6 10-presentation
6 10-presentation6 10-presentation
6 10-presentation
 
Building APIs in an easy way using API Platform
Building APIs in an easy way using API PlatformBuilding APIs in an easy way using API Platform
Building APIs in an easy way using API Platform
 

Mais de AidIQ

Sahana Eden : Introduction and Simulation A (SahanaCamp 1.2)
Sahana Eden : Introduction and Simulation A (SahanaCamp 1.2)Sahana Eden : Introduction and Simulation A (SahanaCamp 1.2)
Sahana Eden : Introduction and Simulation A (SahanaCamp 1.2)AidIQ
 
Sahana Eden : Developer Environment (VM) (SahanaCamp 1.2)
Sahana Eden : Developer Environment (VM) (SahanaCamp 1.2)Sahana Eden : Developer Environment (VM) (SahanaCamp 1.2)
Sahana Eden : Developer Environment (VM) (SahanaCamp 1.2)AidIQ
 
Sahana Eden : Deployment (SahanaCamp 1.2)
Sahana Eden : Deployment (SahanaCamp 1.2)Sahana Eden : Deployment (SahanaCamp 1.2)
Sahana Eden : Deployment (SahanaCamp 1.2)AidIQ
 
Sahana Eden : Bug Reporting (SahanaCamp 1.2)
Sahana Eden : Bug Reporting (SahanaCamp 1.2)Sahana Eden : Bug Reporting (SahanaCamp 1.2)
Sahana Eden : Bug Reporting (SahanaCamp 1.2)AidIQ
 
Sahana : Case Studies (SahanaCamp 1.2)
Sahana : Case Studies (SahanaCamp 1.2)Sahana : Case Studies (SahanaCamp 1.2)
Sahana : Case Studies (SahanaCamp 1.2)AidIQ
 
Participatory programming
Participatory programmingParticipatory programming
Participatory programmingAidIQ
 
OpenStreetMap : Technical (SahanaCamp 1.2)
OpenStreetMap : Technical (SahanaCamp 1.2)OpenStreetMap : Technical (SahanaCamp 1.2)
OpenStreetMap : Technical (SahanaCamp 1.2)AidIQ
 
OpenStreetMap : Sahana Mapping Client (SahanaCamp 1.2)
OpenStreetMap : Sahana Mapping Client (SahanaCamp 1.2)OpenStreetMap : Sahana Mapping Client (SahanaCamp 1.2)
OpenStreetMap : Sahana Mapping Client (SahanaCamp 1.2)AidIQ
 
Implementing IT Solutions for Disaster Management (SahanaCamp 1.2)
Implementing IT Solutions for Disaster Management (SahanaCamp 1.2)Implementing IT Solutions for Disaster Management (SahanaCamp 1.2)
Implementing IT Solutions for Disaster Management (SahanaCamp 1.2)AidIQ
 
BZR & LaunchPad : Sharing Your Work With Others (SahanaCamp 1.2)
BZR & LaunchPad : Sharing Your Work With Others (SahanaCamp 1.2)BZR & LaunchPad : Sharing Your Work With Others (SahanaCamp 1.2)
BZR & LaunchPad : Sharing Your Work With Others (SahanaCamp 1.2)AidIQ
 
GHC Participant Training
GHC Participant TrainingGHC Participant Training
GHC Participant TrainingAidIQ
 
Exercise24
Exercise24Exercise24
Exercise24AidIQ
 
Sahana sharing your work with others
Sahana   sharing your work with othersSahana   sharing your work with others
Sahana sharing your work with othersAidIQ
 
Sahana introduction to the code v2
Sahana   introduction to the code v2Sahana   introduction to the code v2
Sahana introduction to the code v2AidIQ
 
Sahana community development process
Sahana   community development processSahana   community development process
Sahana community development processAidIQ
 
OpenStreetMap louis liu
OpenStreetMap   louis liuOpenStreetMap   louis liu
OpenStreetMap louis liuAidIQ
 
OpenStreetMap dongpo deng
OpenStreetMap   dongpo dengOpenStreetMap   dongpo deng
OpenStreetMap dongpo dengAidIQ
 
Open GeoSMS slayer chuang
Open GeoSMS   slayer chuangOpen GeoSMS   slayer chuang
Open GeoSMS slayer chuangAidIQ
 

Mais de AidIQ (18)

Sahana Eden : Introduction and Simulation A (SahanaCamp 1.2)
Sahana Eden : Introduction and Simulation A (SahanaCamp 1.2)Sahana Eden : Introduction and Simulation A (SahanaCamp 1.2)
Sahana Eden : Introduction and Simulation A (SahanaCamp 1.2)
 
Sahana Eden : Developer Environment (VM) (SahanaCamp 1.2)
Sahana Eden : Developer Environment (VM) (SahanaCamp 1.2)Sahana Eden : Developer Environment (VM) (SahanaCamp 1.2)
Sahana Eden : Developer Environment (VM) (SahanaCamp 1.2)
 
Sahana Eden : Deployment (SahanaCamp 1.2)
Sahana Eden : Deployment (SahanaCamp 1.2)Sahana Eden : Deployment (SahanaCamp 1.2)
Sahana Eden : Deployment (SahanaCamp 1.2)
 
Sahana Eden : Bug Reporting (SahanaCamp 1.2)
Sahana Eden : Bug Reporting (SahanaCamp 1.2)Sahana Eden : Bug Reporting (SahanaCamp 1.2)
Sahana Eden : Bug Reporting (SahanaCamp 1.2)
 
Sahana : Case Studies (SahanaCamp 1.2)
Sahana : Case Studies (SahanaCamp 1.2)Sahana : Case Studies (SahanaCamp 1.2)
Sahana : Case Studies (SahanaCamp 1.2)
 
Participatory programming
Participatory programmingParticipatory programming
Participatory programming
 
OpenStreetMap : Technical (SahanaCamp 1.2)
OpenStreetMap : Technical (SahanaCamp 1.2)OpenStreetMap : Technical (SahanaCamp 1.2)
OpenStreetMap : Technical (SahanaCamp 1.2)
 
OpenStreetMap : Sahana Mapping Client (SahanaCamp 1.2)
OpenStreetMap : Sahana Mapping Client (SahanaCamp 1.2)OpenStreetMap : Sahana Mapping Client (SahanaCamp 1.2)
OpenStreetMap : Sahana Mapping Client (SahanaCamp 1.2)
 
Implementing IT Solutions for Disaster Management (SahanaCamp 1.2)
Implementing IT Solutions for Disaster Management (SahanaCamp 1.2)Implementing IT Solutions for Disaster Management (SahanaCamp 1.2)
Implementing IT Solutions for Disaster Management (SahanaCamp 1.2)
 
BZR & LaunchPad : Sharing Your Work With Others (SahanaCamp 1.2)
BZR & LaunchPad : Sharing Your Work With Others (SahanaCamp 1.2)BZR & LaunchPad : Sharing Your Work With Others (SahanaCamp 1.2)
BZR & LaunchPad : Sharing Your Work With Others (SahanaCamp 1.2)
 
GHC Participant Training
GHC Participant TrainingGHC Participant Training
GHC Participant Training
 
Exercise24
Exercise24Exercise24
Exercise24
 
Sahana sharing your work with others
Sahana   sharing your work with othersSahana   sharing your work with others
Sahana sharing your work with others
 
Sahana introduction to the code v2
Sahana   introduction to the code v2Sahana   introduction to the code v2
Sahana introduction to the code v2
 
Sahana community development process
Sahana   community development processSahana   community development process
Sahana community development process
 
OpenStreetMap louis liu
OpenStreetMap   louis liuOpenStreetMap   louis liu
OpenStreetMap louis liu
 
OpenStreetMap dongpo deng
OpenStreetMap   dongpo dengOpenStreetMap   dongpo deng
OpenStreetMap dongpo deng
 
Open GeoSMS slayer chuang
Open GeoSMS   slayer chuangOpen GeoSMS   slayer chuang
Open GeoSMS slayer chuang
 

Último

Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 

Último (20)

Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 

Sahana Eden : Introduction to the Code (SahanaCamp 1.2)

Notas do Editor

  1. As well as being a suite of pre-built applications, Eden is also an Emergency Development Environment: a framework which can be used to rapidly build new ones to meet custom needs (as every emergency is different).
  2. Because all models are executed every request, it is important to minimise the amount of time taken to process them. Alphabetical order is to Manage the dependencies ‘In the Web2Py environment’ means no need to import most of the libraries in ‘gluon/’ & access to the global variables: request, session & response. First the parts of the Controller outside Functions are executed & then the relevant Function. Functions with no arguments are automatically visible via URLs No need to add a routes entry (unlike other frameworks, like Django) The Controller or View could also return XML (e.g. RSS or KML), JSON, PDF or XLS.
  3. Remember that after server-side Python finishes, we still have a lot of possibilities client-side with JavaScript. URL() is an example of an HTML ‘Helper’ object
  4. JS = JavaScript
  5. Deleted Columns / Tables simply Ignored Sahana Eden is Resource-centric
  6. Sahana Eden is Resource-centric
  7. Web Services, Mash-ups
  8. 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.
  9. Create a new file in the Controllers folder called ‘vts.py’ & type in the text above.
  10. Note that you’ll need to Login to the system before you’re allowed to create a resource.
  11. These defaults are why we didn’t need any views for our application. Web2Py defaults to views/controller/function.html, but S3REST needs a different view per Method
  12. No need to learn another macro language Can Extend just a single other file Can Include many others
  13. 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
  14. 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
  15. Unique=True is a SQL-level constraint. Open your vts.py from the models directory & add the extra code above. Try adding multiple vehicles with the same registration. Validators are DAL-level constraints which provide server-side validation & some also provide client-side rendering & validation. These are automatically added with SQL constraints to produce nice error messages instead of tickets. Validators can also be added manually as: db.vts_vehicle.registration.requires = IS_NOT_IN_DB(
)
  16. 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 (This comes from the default IS_DATE() Validator) Add the extra code above to your file & refresh the page, now enter a date.
  17. Add the extra code above to your file & refresh the page to see the default value
  18. Add this to your model (under the table definition) & try it out. T() is to Internationalise the string
  19. Add the comment to your controller & try it out
  20. If you have time, then you can try out these CRUD strings
copy/paste from another model & then edit
see what effect this has on your module.
  21. 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)
  22. 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("applications/eden/controllers/vts.py", globals()) help(index)
  23. 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?
  24. Add this text to your controller (outside the functions – e.g. at the top) & see what effect this has on your module.
  25. 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’).
  26. The alias ‘w2p’ runs: python web2py.py –S eden –M
  27. Don’t take effect until you db.commit()
  28. Copt this text into your model. Note the use of string substitution to define the tablename
  29. 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.
  30. 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
  31. 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
  32. 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.
  33. We can add additional fields into the link table.
  34. 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
  35. Add this to your model underneath the definition of the Presence table & try out the URL. No need for dedicated presence() controller This can then be enhanced with the use of Tabs – look for rheader tabs in the source of other applications

  36. Add this Resource Header definition to your Controller. Be careful to get the end brackets & commas right! ‘r’ is the resource
  37. Then plug it into the Controller
  38. Take a look at the HTML structure of the page in Firebug.