Changes between Version 10 and Version 11 of DeveloperGuidelinesNewModule


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

New RESTful controller - even easier :)

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelinesNewModule

    v10 v11  
    1111
    1212This makes it visible on the front page & the left-hand navigation menu
    13 
    1413
    1514Create a file {{{/models/module.py}}}
     
    3534To avoid namespace clashes, use the format: {{{db.module_table}}}
    3635
    37 === Controller ===
    38 Add CRUD functions for these tables to {{{/controllers/module.py}}}
     36Add a section for messages for your resources to {{{models/_db.py}}}:
     37{{{
     38def shn_crud_strings_lookup(resource):
     39    "Look up CRUD strings for a given resource."
     40    elif resource=='shelter':
     41        return Storage(title_create=T('Add Shelter'),
     42            title_display=T('Organisation Details'),
     43            title_list=T('List Shelters'),
     44            title_update=T('Edit Shelter'),
     45            subtitle_list=T('Shelters'),
     46            subtitle_create=T('Add New Shelter'),
     47            label_list_button=T('List Shelters'),
     48            label_create_button=T('Add Shelter'),
     49            msg_record_created=T('Shelter added'),
     50            msg_record_modified=T('Shelter updated'),
     51            msg_record_deleted=T('Shelter deleted'),
     52            msg_list_empty=T('No Shelters currently registered'))
     53}}}
    3954
    40 The RESTful controller for a table needs just a few small tweaks once pasted:
    41  * Search/Replace 'organisation' with your_resource
     55Copy/paste & do just a few small tweaks once pasted:
    4256 * Search/Replace 'Organisation' with Your_resource
    4357 * Fix plurals, if required (e.g. Persons -> People, Classs to Classes, Metadatas -> Metadata)
     58
     59=== Controller ===
     60Add CRUD functions for these tables to {{{/controllers/module.py}}}:
     61{{{
     62def shelter():
     63    "RESTful CRUD controller"
     64    return shn_rest_controller(module,'shelter')
     65}}}
    4466
    4567Manual method for if/when you need more control: DeveloperGuidelinesCreateReadUpdateDelete