Changes between Version 21 and Version 22 of BluePrintRESTImplementation


Ignore:
Timestamp:
01/03/09 08:09:04 (13 years ago)
Author:
Fran Boon
Comment:

single & plural to make less edits when copy/pasting

Legend:

Unmodified
Added
Removed
Modified
  • BluePrintRESTImplementation

    v21 v22  
    44{{{models/module.py}}}
    55{{{
    6 crud_strings_shelter=Storage(title_create=T('Add Shelter'),
    7             title_display=T('Organisation Details'),
    8             title_list=T('List Shelters'),
    9             title_update=T('Edit Shelter'),
    10             subtitle_list=T('Shelters'),
    11             subtitle_create=T('Add New Shelter'),
    12             label_list_button=T('List Shelters'),
    13             label_create_button=T('Add Shelter'),
    14             msg_record_created=T('Shelter added'),
    15             msg_record_modified=T('Shelter updated'),
    16             msg_record_deleted=T('Shelter deleted'),
    17             msg_list_empty=T('No Shelters currently registered'))
     6resource='shelter'
     7single=resource.capitalize()
     8# NB May need manual fixing!
     9plural=single+'s'
     10title_create=T('Add %s' % single)
     11title_display=T('%s Details' % single)
     12title_list=T('List %s' % plural)
     13title_update=T('Edit %s' % single)
     14subtitle_create=T('Add New %s' % single)
     15subtitle_list=T('%s' % plural)
     16label_list_button=T('List %s' % plural)
     17label_create_button=T('Add %s' % single)
     18msg_record_created=T('%s added' % single)
     19msg_record_modified=T('%s updated' % single)
     20msg_record_deleted=T('%s deleted' % single)
     21msg_list_empty=T('No %s currently registered' % plural)
     22exec('crud_strings.%s=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)' % resource)
    1823}}}
    1924
     
    2227def shn_crud_strings_lookup(resource):
    2328    "Look up CRUD strings for a given resource."
    24     return eval('crud_strings_%s' % resource)
     29    return getattr(crud_strings,'%s' % resource)
    2530
    2631def shn_rest_controller(module,resource):
     
    106111Simplified module table:
    107112{{{
    108 db.define_table('cr_shelter',
     113resource='shelter'
     114table=module+'_'+resource
     115db.define_table(table,
    109116                SQLField('modified_on','datetime',default=now),
    110117                SQLField('uuid',length=64,default=uuid.uuid4()),
    111118                SQLField('name'))
    112 db.cr_shelter.represent=lambda table:shn_list_item(table,resource='shelter',action='display')
     119db['%s' % table].represent=lambda table:shn_list_item(table,resource='shelter',action='display')
    113120}}}
    114121