Changes between Version 34 and Version 35 of BluePrintRESTImplementation


Ignore:
Timestamp:
01/17/09 18:16:59 (16 years ago)
Author:
Fran Boon
Comment:

Update to current

Legend:

Unmodified
Added
Removed
Modified
  • BluePrintRESTImplementation

    v34 v35  
    88db.define_table(table,timestamp,uuidstamp,
    99                SQLField('name'))
    10 exec("s3.crud_fields.%s=['name']" % table)
    11 db['%s' % table].exposes=s3.crud_fields['%s' % table]
     10s3.crud_fields[table]=['name']
     11db[table].exposes=s3.crud_fields[table]
    1212# Moved to Controller - allows us to redefine for different scenarios (& also better MVC separation)
    13 #db['%s' % table].displays=s3.crud_fields['%s' % table]
     13#db[table].displays=s3.crud_fields[table]
    1414# NB Beware of lambdas & %s substitution as they get evaluated when called, not when defined!
    15 #db['%s' % table].represent=lambda table:shn_list_item(table,resource='shelter',action='display')
     15#db[table].represent=lambda table:shn_list_item(table,resource='shelter',action='display')
    1616db[table].uuid.requires=IS_NOT_IN_DB(db,'%s.uuid' % table)
    1717title_create=T('Add Shelter')
     
    2727msg_record_deleted=T('Shelter deleted')
    2828msg_list_empty=T('No Shelters currently registered')
    29 exec('s3.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)' % table)
     29s3.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)
    3030}}}
    3131These optional settings can also be set, if-desired:
    3232{{{
    33 exec('s3.listonly.%s=1' % table)    # Don't allow resources to be creatable from List view
    34 exec('s3.undeletable.%s=1' % table) # Don't allow resources to be deletable from List/Display views
     33s3.listonly[table]=1    # Don't allow resources to be creatable from List view
     34s3.undeletable[table]=1 # Don't allow resources to be deletable from List/Display views
    3535}}}
    3636
     
    111111        if representation=="html":
    112112            if t2.logged_in and s3.deletable:
    113                 db['%s' % table].represent=lambda table:shn_list_item(table,resource='%s' % resource,action='display',extra="INPUT(_type='checkbox',_class='delete_row',_name='%s' % resource,_id='%i' % table.id)")
     113                db[table].represent=lambda table:shn_list_item(table,resource='%s' % resource,action='display',extra="INPUT(_type='checkbox',_class='delete_row',_name='%s' % resource,_id='%i' % table.id)")
    114114            else:
    115                 db['%s' % table].represent=lambda table:shn_list_item(table,resource='%s' % resource,action='display')
     115                db[table].represent=lambda table:shn_list_item(table,resource='%s' % resource,action='display')
    116116            list=t2.itemize(table)
    117             if list=="No data":
     117            if list=="None":
    118118                list=s3.crud_strings.msg_list_empty
    119119            title=s3.crud_strings.title_list
     
    151151        elif representation=="ajax":
    152152            if t2.logged_in and s3.deletable:
    153                 db['%s' % table].represent=lambda table:shn_list_item(table,resource='%s' % resource,action='display',extra="INPUT(_type='checkbox',_class='delete_row',_name='%s' % resource,_id='%i' % table.id)")
     153                db[table].represent=lambda table:shn_list_item(table,resource='%s' % resource,action='display',extra="INPUT(_type='checkbox',_class='delete_row',_name='%s' % resource,_id='%i' % table.id)")
    154154            else:
    155                 db['%s' % table].represent=lambda table:shn_list_item(table,resource='%s' % resource,action='display')
     155                db[table].represent=lambda table:shn_list_item(table,resource='%s' % resource,action='display')
    156156            list=t2.itemize(table)
    157157            if list=="No data":
     
    174174            import gluon.contenttype
    175175            response.headers['Content-Type']=gluon.contenttype.contenttype('.csv')
    176             query=db['%s' % table].id>0
     176            query=db[table].id>0
    177177            response.headers['Content-disposition']="attachment; filename=%s_%s_list.csv" % (request.env.server_name,resource)
    178178            return str(db(query).select())
     
    197197            if representation=="html":
    198198                try:
    199                     db['%s' % table].displays=s3.crud_fields['%s' % table]
     199                    db[table].displays=s3.crud_fields[table]
    200200                except:
    201201                    pass
     
    227227                import gluon.contenttype
    228228                response.headers['Content-Type']=gluon.contenttype.contenttype('.csv')
    229                 query=db['%s' % table].id==t2.id
     229                query=db[table].id==t2.id
    230230                response.headers['Content-disposition']="attachment; filename=%s_%s_%d.csv" % (request.env.server_name,resource,t2.id)
    231231                return str(db(query).select())
     
    302302                    if session.s3.audit_write:
    303303                        old_value = []
    304                         _old_value=db(db['%s' % table].id==t2.id).select()[0]
     304                        _old_value=db(db[table].id==t2.id).select()[0]
    305305                        for field in _old_value:
    306306                            old_value.append(field+':'+str(_old_value[field]))
     
    346346                    if session.s3.audit_write:
    347347                        old_value = []
    348                         _old_value=db(db['%s' % table].id==t2.id).select()[0]
     348                        _old_value=db(db[table].id==t2.id).select()[0]
    349349                        for field in _old_value:
    350350                            old_value.append(field+':'+str(_old_value[field]))