Changes between Version 32 and Version 33 of BluePrintRESTImplementation


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

Update to current API

Legend:

Unmodified
Added
Removed
Modified
  • BluePrintRESTImplementation

    v32 v33  
    66resource='shelter'
    77table=module+'_'+resource
    8 db.define_table(table,
    9                 SQLField('modified_on','datetime',default=now),
    10                 SQLField('uuid',length=64,default=uuid.uuid4()),
     8db.define_table(table,timestamp,uuidstamp,
    119                SQLField('name'))
    1210exec("s3.crud_fields.%s=['name']" % table)
     
    1614# NB Beware of lambdas & %s substitution as they get evaluated when called, not when defined!
    1715#db['%s' % table].represent=lambda table:shn_list_item(table,resource='shelter',action='display')
     16db[table].uuid.requires=IS_NOT_IN_DB(db,'%s.uuid' % table)
    1817title_create=T('Add Shelter')
    1918title_display=T('Shelter Details')
     
    3635}}}
    3736
    38 This is the supporting material in {{{models/_db.py}}}:
     37This is the supporting material in {{{models/__db.py}}}:
    3938{{{
    4039from gluon.storage import Storage
     
    7372            CSV create/update
    7473            SMS,XML,PDF
    75         Search method
    7674        Customisable Security Policy
    7775    """
     
    366364                else:
    367365                    t2.redirect('login',vars={'_destination':'%s/delete/%i' % (resource,t2.id)})
     366            elif method=="search":
     367                if session.s3.audit_read:
     368                    db.s3_audit.insert(
     369                        person=t2.person_id,
     370                        operation='search',
     371                        module=request.controller,
     372                        resource=resource,
     373                        old_value='',
     374                        new_value=''
     375                    )
     376                if representation=="html":
     377                    if t2.logged_in and s3.deletable:
     378                        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)")
     379                    else:
     380                        db[table].represent=lambda table:shn_list_item(table,resource='%s' % resource,action='display')
     381                    search=t2.search(table)
     382                    # Check for presence of Custom View
     383                    custom_view='%s_search.html' % resource
     384                    _custom_view=os.path.join(request.folder,'views',module,custom_view)
     385                    if os.path.exists(_custom_view):
     386                        response.view=module+'/'+custom_view
     387                    else:
     388                        response.view='search.html'
     389                    title=s3.crud_strings.title_search
     390                    return dict(module_name=module_name,modules=modules,options=options,search=search,title=title)
     391                else:
     392                    session.error=T("Unsupported format!")
     393                    redirect(URL(r=request,f=resource))
    368394            else:
    369395                session.error=T("Unsupported method!")