Changes between Version 40 and Version 41 of RESTController


Ignore:
Timestamp:
05/25/10 14:25:02 (14 years ago)
Author:
Praneeth Bodduluri
Comment:

Added disabling create method snippet

Legend:

Unmodified
Added
Removed
Modified
  • RESTController

    v40 v41  
    164164}}}
    165165
     166Example:
     167The following disables the create method for a resource
     168{{{
     169def restricted_method(*arguments, **keywords):                                                                               
     170    """Handy function for restricting access to certain methods """                                                           
     171    session.error = T("Restricted method")                                                                                   
     172    redirect(URL(r=request))   
     173
     174# Note the s3xrc.model.set_method usage below.
     175def inbox():                                                                                                                 
     176    " RESTlike CRUD controller for inbox"                                                                                     
     177    person = db(db.pr_person.uuid==auth.user.person_uuid).select(db.pr_person.id)                                             
     178    response.s3.filer = (db.msg_inbox.person_id == person[0].id)                                                             
     179    s3xrc.model.set_method(module, 'inbox', method='create', action = restricted_method)                                     
     180    return shn_rest_controller(module, 'inbox', listadd=False, editable = False) 
     181
     182}}}
     183
     184
    166185Arguments of {{{set_method}}}:
    167186