Changes between Version 39 and Version 40 of BluePrintRESTImplementation


Ignore:
Timestamp:
05/26/09 22:15:53 (16 years ago)
Author:
Fran Boon
Comment:

00_db.py, Python style

Legend:

Unmodified
Added
Removed
Modified
  • BluePrintRESTImplementation

    v39 v40  
    44This is how Module writers need to add tables to their {{{models/module.py}}}:
    55{{{
    6 resource='shelter'
    7 table=module+'_'+resource
    8 db.define_table(table,timestamp,uuidstamp,
     6resource = 'shelter'
     7table = module + '_' + resource
     8db.define_table(table, timestamp, uuidstamp,
    99                SQLField('name'))
    10 s3.crud_fields[table]=['name']
    11 db[table].exposes=s3.crud_fields[table]
    12 # Moved to Controller - allows us to redefine for different scenarios (& also better MVC separation)
    13 #db[table].displays=s3.crud_fields[table]
    14 # NB Beware of lambdas & %s substitution as they get evaluated when called, not when defined!
    15 #db[table].represent=lambda table:shn_list_item(table,resource='shelter',action='display')
    16 db[table].uuid.requires=IS_NOT_IN_DB(db,'%s.uuid' % table)
    17 title_create=T('Add Shelter')
    18 title_display=T('Shelter Details')
    19 title_list=T('List Shelters')
    20 title_update=T('Edit Shelter')
    21 subtitle_create=T('Add New Shelter')
    22 subtitle_list=T('Shelters')
    23 label_list_button=T('List Shelters')
    24 label_create_button=T('Add Shelter')
    25 msg_record_created=T('Shelter added')
    26 msg_record_modified=T('Shelter updated')
    27 msg_record_deleted=T('Shelter deleted')
    28 msg_list_empty=T('No Shelters currently registered')
    29 s3.crud_strings[table]=Storage(title_create=title_create, title_display=title_display, title_list=title_list, title_update=title_update, subtitle_create=subtitle_create, subtitle_list=subtitle_list, label_list_button=label_list_button, label_create_button=label_create_button, msg_record_created=msg_record_created, msg_record_modified=msg_record_modified, msg_record_deleted=msg_record_deleted, msg_list_empty=msg_list_empty)
     10s3.crud_fields[table] = ['name']
     11db[table].exposes = s3.crud_fields[table]
     12db[table].uuid.requires = IS_NOT_IN_DB(db, '%s.uuid' % table)
     13title_create = T('Add Shelter')
     14title_display = T('Shelter Details')
     15title_list = T('List Shelters')
     16title_update = T('Edit Shelter')
     17subtitle_create = T('Add New Shelter')
     18subtitle_list = T('Shelters')
     19label_list_button = T('List Shelters')
     20label_create_button = T('Add Shelter')
     21msg_record_created = T('Shelter added')
     22msg_record_modified = T('Shelter updated')
     23msg_record_deleted = T('Shelter deleted')
     24msg_list_empty = T('No Shelters currently registered')
     25s3.crud_strings[table] = Storage(title_create=title_create, title_display=title_display, title_list=title_list, title_update=title_update, subtitle_create=subtitle_create, subtitle_list=subtitle_list, label_list_button=label_list_button, label_create_button=label_create_button, msg_record_created=msg_record_created, msg_record_modified=msg_record_modified, msg_record_deleted=msg_record_deleted, msg_list_empty=msg_list_empty)
    3026}}}
    3127
    32 The supporting functions are in {{{models/__db.py}}}:
    33  * http://trac.sahanapy.org/browser/models/__db.py
     28The supporting functions are in {{{models/00_db.py}}}:
     29 * http://trac.sahanapy.org/browser/models/00_db.py
    3430
    3531== Controller ==