Changes between Version 39 and Version 40 of DeveloperGuidelinesNewModule
- Timestamp:
- 06/27/10 09:33:02 (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DeveloperGuidelinesNewModule
v39 v40 18 18 To avoid namespace clashes, use the format: {{{db.module_table}}} 19 19 20 e.g. if building a Vehicle Management System, create db.v eh_vehicle:20 e.g. if building a Vehicle Management System, create db.vts_vehicle: 21 21 {{{ 22 module = 'veh'23 resource = 'vehicle'22 module = "vts" 23 resource = "vehicle" 24 24 25 tablename = module + '_'+ resource25 tablename = module + "_" + resource 26 26 table = db.define_table(tablename, timestamp, uuidstamp, 27 Field( 'name'))28 table.uuid.requires = IS_NOT_IN_DB(db, '%s.uuid'% table)27 Field("name")) 28 table.uuid.requires = IS_NOT_IN_DB(db, "%s.uuid" % table) 29 29 table.name.requires = IS_NOT_EMPTY() 30 30 table.name.comment = SPAN("*", _class="req") 31 }}}32 33 Add the messages for your resources:34 {{{35 s3.crud_strings[tablename] = Storage(36 title_create = T('Add Vehicle'),37 title_display = T('Vehicle Details'),38 title_list = T('List Vehicles'),39 title_update = T('Edit Vehicle'),40 title_search = T('Search Vehicles'),41 subtitle_create = T('Add New Vehicle'),42 subtitle_list = T('Vehicles'),43 label_list_button = T('List Vehicles'),44 label_create_button = T('Add Vehicle'),45 label_delete_button = T('Delete Vehicle'),46 msg_record_created = T('Vehicle added'),47 msg_record_modified = T('Vehicle updated'),48 msg_record_deleted = T('Vehicle deleted'),49 msg_list_empty = T('No Vehicles currently registered'))50 31 }}} 51 32 … … 53 34 Create a file: {{{/controllers/<MODULE NAME>.py}}} 54 35 55 Add the S3 framework functions:36 Add CRUD functions for your tables: 56 37 {{{ 57 module = 'veh'38 module = request.controller 58 39 40 def vehicle(): 41 "RESTful CRUD controller" 42 resource = request.function 43 return shn_rest_controller(module, resource) 44 }}} 45 46 Manual method for if/when you need more control: DeveloperGuidelinesCreateReadUpdateDelete 47 48 Add the messages for your resources: 49 {{{ 50 def vehicle(): 51 "RESTful CRUD controller" 52 resource = request.function 53 s3.crud_strings[tablename] = Storage( 54 title_create = T("Add Vehicle"), 55 title_display = T("Vehicle Details"), 56 title_list = T("List Vehicles"), 57 title_update = T("Edit Vehicle"), 58 title_search = T("Search Vehicles"), 59 subtitle_create = T("Add New Vehicle"), 60 subtitle_list = T("Vehicles"), 61 label_list_button = T("List Vehicles"), 62 label_create_button = T("Add Vehicle"), 63 label_delete_button = T("Delete Vehicle"), 64 msg_record_created = T("Vehicle added"), 65 msg_record_modified = T("Vehicle updated"), 66 msg_record_deleted = T("Vehicle deleted"), 67 msg_list_empty = T("No Vehicles currently registered")) 68 69 return shn_rest_controller(module, resource) 70 }}} 71 72 Add a menu: 73 {{{ 59 74 # Options Menu (available in all Functions' Views) 60 75 response.menu_options = [ … … 64 79 [T("Search Vehicles"), False, URL(r=request, f="vehicle", args="search")] 65 80 ] 66 67 81 }}} 68 69 Add CRUD functions for your tables:70 {{{71 def vehicle():72 "RESTful CRUD controller"73 return shn_rest_controller(module, "vehicle")74 }}}75 76 Manual method for if/when you need more control: DeveloperGuidelinesCreateReadUpdateDelete77 82 78 83 === Views === … … 82 87 If Custom Views are wanted they are detected automatically if files are found in {{{/views/<MODULE NAME>/<RESOURCE>_<METHOD>.html}}} 83 88 89 ---- 84 90 DeveloperGuidelines