Python Field level security example

From DreamFactory
Jump to: navigation, search
DreamFactoryTutorialsPython Field level security example

Always removes the 'twitter' and 'skype' fields before returning JSON content to the client.

For this change to take effect, you have to enable modification of response in the Admin Console script editor. Check the box 'Allow script to modify request (pre-process) or response (post-process)'.

#db._table.contact.get.post_process
#GET /api/v2/db/_table/contact
 
content = event.response.content;
 
 
if(content.resource):
    for record in content.resource:
       del record['skype'];
if(content.resource):
     for record in content.resource:
       del record['twitter'];