Changes between Version 12 and Version 13 of DeveloperGuidelinesNewModule


Ignore:
Timestamp:
01/02/09 17:25:54 (13 years ago)
Author:
Fran Boon
Comment:

Vehicles example including main resource table

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelinesNewModule

    v12 v13  
    3030}}}
    3131
    32 Add additional tables to this file, as-required.[[BR]]
     32Add additional tables to this file, as-required for your resources.[[BR]]
    3333To avoid namespace clashes, use the format: {{{db.module_table}}}
     34
     35e.g. if beilding a Vehicle Management System, create db.veh_vehicle:
     36{{{
     37db.define_table('veh_vehicle',
     38                SQLField('modified_on','datetime',default=now),
     39                SQLField('uuid',length=64,default=uuid.uuid4()),
     40                SQLField('name'))
     41db.veh_vehicle.name.requires=IS_NOT_EMPTY()
     42db.veh_vehicle.name.comment=SPAN("*",_class="req")
     43}}}
     44
    3445Also add the messages for your resources:
    3546{{{
    36 crud_strings_shelter=Storage(title_create=T('Add Shelter'),
    37             title_display=T('Organisation Details'),
    38             title_list=T('List Shelters'),
    39             title_update=T('Edit Shelter'),
    40             subtitle_list=T('Shelters'),
    41             subtitle_create=T('Add New Shelter'),
    42             label_list_button=T('List Shelters'),
     47crud_strings_vehicle=Storage(title_create=T('Add Vehicle'),
     48            title_display=T('Vehicle Details'),
     49            title_list=T('List Vehicles'),
     50            title_update=T('Edit Vehicle'),
     51            subtitle_list=T('Vehicles'),
     52            subtitle_create=T('Add New Vehicle'),
     53            label_list_button=T('List Vehicles'),
    4354            label_create_button=T('Add Shelter'),
    44             msg_record_created=T('Shelter added'),
    45             msg_record_modified=T('Shelter updated'),
    46             msg_record_deleted=T('Shelter deleted'),
    47             msg_list_empty=T('No Shelters currently registered'))
     55            msg_record_created=T('Vehicle added'),
     56            msg_record_modified=T('Vehicle updated'),
     57            msg_record_deleted=T('Vehicle deleted'),
     58            msg_list_empty=T('No Vehicles currently registered'))
    4859}}}
    4960Copy/paste & do just a few small tweaks once pasted:
    5061 * Search/Replace 'Shelter' with Your_resource
    5162 * Fix plurals, if required (e.g. Persons -> People, Classs -> Classes, Metadatas -> Metadata)
     63 * Maybe change phrasing: registered vs defined, etc
    5264
    5365=== Controller ===
    5466Add CRUD functions for these tables to {{{/controllers/module.py}}}:
    5567{{{
    56 def shelter():
     68def vehicle():
    5769    "RESTful CRUD controller"
    58     return shn_rest_controller(module,'shelter')
     70    return shn_rest_controller(module,'vehicle')
    5971}}}
    6072