Changes between Initial Version and Version 1 of Ticket #342


Ignore:
Timestamp:
06/10/10 13:17:19 (4 years ago)
Author:
dread
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #342 – Description

    initial v1  
    99== Suggested implementation == 
    1010 
    11 All API calls allow the JSONP 'callback' parameter to be specified in the request and this wraps the JSON response. 
     11All API calls allow the JSONP 'callback' parameter to be specified in the request and this wraps the JSON response. See suggested patch to rest.py by Donovan Hide: 
     12 
     13http://knowledgeforge.net/ckan/trac/attachment/ticket/336/resource.patch 
     14 
     15== Test == 
     16 
     17import re 
     18import unittest 
     19 
     20def test_jsonp_callback(): 
     21  response = self.app.get('/api/search/resource/?url=http://www.scraperwiki.com&callback=jsoncallback') 
     22  match = re.match('jsoncallback\(.*\);',response) 
     23  self.assertTrue(match) 
     24 
     25  response = self.app.get('/api/search/resource/?url=http://www.scraperwiki.com') 
     26  match = re.match('jsoncallback\(.*\);',response) 
     27  self.assertFalse(match) 
     28 
     29I think the point needs to be made that JSONP only works for GET 
     30requests and not POST/PUT/DELETE, so there needs to be a check 
     31for that in the _finish_ok method. 
     32 
     33(thanks to Donovan Hide for test)