<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>apps/media/scripts/gadget_handler.js</filename>
    </added>
    <added>
      <filename>apps/media/tests/gadget_handler.xml</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,5 @@
 application: jquery-douban
-version: 0-1-20090228
+version: 2
 runtime: python
 api_version: 1
 </diff>
      <filename>apps/app.yaml</filename>
    </modified>
    <modified>
      <diff>@@ -1 +1 @@
-../../../src/gm_handler.js
\ No newline at end of file
+../../../src/greasemonkey_handler.js
\ No newline at end of file</diff>
      <filename>apps/media/scripts/gm_handler.js</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-var url = 'http://localhost:8080/test/handler/';
+var url = 'http://jquery-douban.appspot.com/test/handler/';
 var params = { 'p1': 'parameter_one', 'p2': 'parameter_two' };
 var headers = { 'h1': 'header_one', 'h2': 'header_two' };
 var data = '&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;entry&gt;&lt;/entry&gt;';
@@ -20,5 +20,5 @@ function testJson(json) {
 
 function testText(text) {
     console.debug(text);
-    fireunit.compare('{&quot;url&quot;: &quot;http:\\/\\/localhost:8080\\/test\\/handler\\/?p1=parameter_one&amp;p2=parameter_two&quot;, &quot;headers&quot;: {&quot;h2&quot;: &quot;header_two&quot;, &quot;h1&quot;: &quot;header_one&quot;}, &quot;params&quot;: {&quot;p2&quot;: &quot;parameter_two&quot;, &quot;p1&quot;: &quot;parameter_one&quot;}, &quot;data&quot;: &quot;&quot;}', text, &quot;Text&quot;);
+    fireunit.compare('{&quot;url&quot;: &quot;http:\\/\\/jquery-douban.appspot.com\\/test\\/handler\\/?p1=parameter_one&amp;p2=parameter_two&quot;, &quot;headers&quot;: {&quot;h2&quot;: &quot;header_two&quot;, &quot;h1&quot;: &quot;header_one&quot;}, &quot;params&quot;: {&quot;p2&quot;: &quot;parameter_two&quot;, &quot;p1&quot;: &quot;parameter_one&quot;}, &quot;data&quot;: &quot;&quot;}', text, &quot;Text&quot;);
 }</diff>
      <filename>apps/media/tests/gears.js</filename>
    </modified>
    <modified>
      <diff>@@ -16,7 +16,7 @@ window.fireunit = {
     }
 };
 
-var url = 'http://localhost:8080/test/handler/';
+var url = 'http://jquery-douban.appspot.com/test/handler/';
 var params = { 'p1': 'parameter_one', 'p2': 'parameter_two' };
 var headers = { 'h1': 'header_one', 'h2': 'header_two' };
 var data = '&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;entry&gt;&lt;/entry&gt;';
@@ -38,5 +38,5 @@ function testJson(json) {
 
 function testText(text) {
     console.debug(text);
-    fireunit.compare('{&quot;url&quot;: &quot;http:\\/\\/localhost:8080\\/test\\/handler\\/?p1=parameter_one&amp;p2=parameter_two&quot;, &quot;headers&quot;: {&quot;h2&quot;: &quot;header_two&quot;, &quot;h1&quot;: &quot;header_one&quot;}, &quot;params&quot;: {&quot;p2&quot;: &quot;parameter_two&quot;, &quot;p1&quot;: &quot;parameter_one&quot;}, &quot;data&quot;: &quot;&quot;}', text, &quot;Text&quot;);
+    fireunit.compare('{&quot;url&quot;: &quot;http:\\/\\/jquery-douban.appspot.com\\/test\\/handler\\/?p1=parameter_one&amp;p2=parameter_two&quot;, &quot;headers&quot;: {&quot;h2&quot;: &quot;header_two&quot;, &quot;h1&quot;: &quot;header_one&quot;}, &quot;params&quot;: {&quot;p2&quot;: &quot;parameter_two&quot;, &quot;p1&quot;: &quot;parameter_one&quot;}, &quot;data&quot;: &quot;&quot;}', text, &quot;Text&quot;);
 }</diff>
      <filename>apps/media/tests/gm_handler.user.js</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,6 @@
 netscape.security.PrivilegeManager.enablePrivilege(&quot;UniversalBrowserRead&quot;);
 
-var url = 'http://localhost:8080/test/handler/';
+var url = 'http://jquery-douban.appspot.com/test/handler/';
 var params = { 'p1': 'parameter_one', 'p2': 'parameter_two' };
 var headers = { 'h1': 'header_one', 'h2': 'header_two' };
 var data = '&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;entry&gt;&lt;/entry&gt;';
@@ -22,5 +22,5 @@ function testJson(json) {
 
 function testText(text) {
     console.debug(text);
-    fireunit.compare('{&quot;url&quot;: &quot;http:\\/\\/localhost:8080\\/test\\/handler\\/&quot;, &quot;headers&quot;: {&quot;h2&quot;: &quot;header_two&quot;, &quot;h1&quot;: &quot;header_one&quot;}, &quot;params&quot;: {}, &quot;data&quot;: &quot;p1=parameter_one&amp;p2=parameter_two&quot;}', text, &quot;Text&quot;);
+    fireunit.compare('{&quot;url&quot;: &quot;http:\\/\\/jquery-douban.appspot.com\\/test\\/handler\\/&quot;, &quot;headers&quot;: {&quot;h2&quot;: &quot;header_two&quot;, &quot;h1&quot;: &quot;header_one&quot;}, &quot;params&quot;: {}, &quot;data&quot;: &quot;p1=parameter_one&amp;p2=parameter_two&quot;}', text, &quot;Text&quot;);
 }</diff>
      <filename>apps/media/tests/jquery.js</filename>
    </modified>
    <modified>
      <diff>@@ -9,7 +9,6 @@ from google.appengine.ext.webapp import template
 from google.appengine.ext.webapp.util import run_wsgi_app
 
 testcases = (
-    'basic',
     'collection',
     'event',
     'miniblog',
@@ -52,8 +51,7 @@ class TestHandler(webapp.RequestHandler):
 class TestcasePage(webapp.RequestHandler):
     def get(self, testcase_name):
         if testcase_name not in testcases:
-            # return self.error(404)
-            return self.response.out.write(testcase_name)
+            return self.error(404)
 
         template_path = 'templates/tests/%s.html' % testcase_name
         template_values = {</diff>
      <filename>apps/test.py</filename>
    </modified>
    <modified>
      <diff>@@ -4,7 +4,7 @@
 import os
 from optparse import OptionParser
 
-&quot;&quot;&quot; python build.py [-acemnrRstu] [-AgGMj] [-h|--help] &quot;&quot;&quot;
+&quot;&quot;&quot; Usage: python build.py [-acemnrRstu] [-AgGMj] [-h|--help] &quot;&quot;&quot;
 
 src_dir = 'src'
 build_dir = 'build'
@@ -21,7 +21,6 @@ services = ['collection', 'event', 'miniblog', 'note', 'recommendation', \
 
 handlers = ['jquery', 'gears', 'gadget', 'greasemonkey']
 
-
 options = (
     ('-a', '--all',             'include all services'),
     ('-c', '--collection',      'include collection service'),</diff>
      <filename>build.py</filename>
    </modified>
    <modified>
      <diff>@@ -1,39 +1,46 @@
-if (window.gadgets) {
+if (gadgets) {
 
 var GadgetHandler = Douban.handler.gadget = {
     name: 'gadget',
     
-    GET: function(url, params, headers, success) {
+    GET: function(url, params, headers, success, type) {
         url = Douban.util.buildUri(url, params); 
-        var parameters = GadgetHandler.setParams('GET', 'JSON', headers);
-        return gadgets.io.makeRequest(url, success, parameters );
+        var parameters = GadgetHandler.setParams('GET', type || 'JSON', headers);
+        return gadgets.io.makeRequest(url, this.response(type, success), parameters );
     },
 
-    POST: function(url, params, data, headers, success) {
+    POST: function(url, params, data, headers, success, type) {
         url = Douban.util.buildUri(url, params); 
-        var parameters  = GadgetHandler.setParams('POST', 'JSON', headers, data);
-        return gadgets.io.makeRequest(url, success, parameters );
+        var parameters  = GadgetHandler.setParams('POST', type || 'JSON', headers, data);
+        return gadgets.io.makeRequest(url, this.response(type, success), parameters );
     },
 
-    PUT: function(url, params, data, headers, success) {
+    PUT: function(url, params, data, headers, success, type) {
         url = Douban.util.buildUri(url, params); 
-        var parameters = GadgetHandler.setParams('PUT', 'JSON', headers, data);
-        return gadgets.io.makeRequest(url, success, parameters);
+        var parameters = GadgetHandler.setParams('PUT', type || 'JSON', headers, data);
+        return gadgets.io.makeRequest(url, this.response(type, success), parameters);
     },
 
-    DELETE: function(url, params, headers, success) {
+    DELETE: function(url, params, headers, success, type) {
         url = Douban.util.buildUri(url, params); 
-        var parameters = GadgetHandler.setParams('DELETL', 'TEXT', headers);
-        return gadgets.io.makeRequest(url, success, parameters);
+        var parameters = GadgetHandler.setParams('DELETE', type || 'TEXT', headers);
+        return gadgets.io.makeRequest(url, this.response(type, success), parameters);
     },
 
     setParams: function(type, contentType, headers, data) {
         var params = {};
         params[gadgets.io.RequestParameters.METHOD] = gadgets.io.MethodType[type];
-        params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType[contentType];
+        params[gadgets.io.RequestParameters.CONTENT_TYPE] = gadgets.io.ContentType[contentType.toUpperCase()];
         params[gadgets.io.RequestParameters.HEADERS] = headers;
         if (data) params[gadgets.io.RequestParameters.POST_DATA] = data;
         return params;
+    },
+
+    response: function(type, success) {
+        return function(response) {
+            var data = type == 'text' ? response.text : response.data;
+            success &amp;&amp; success(data);
+        }
     }
 };
 </diff>
      <filename>src/gadget_handler.js</filename>
    </modified>
    <modified>
      <diff>@@ -4,9 +4,8 @@ var jQueryHandler = Douban.handler.jquery = {
     name: 'jquery',
 
     GET: function(url, params, headers, success, type) {
-        return jQuery.ajax({ url: url,
+        return jQuery.ajax({ url: Douban.util.buildUri(url, params),
                              type: 'GET',
-                             data: params,
                              dataType: type || 'json',
                              success: success,
                              beforeSend: jQueryHandler.beforeSend(headers) });
@@ -35,9 +34,8 @@ var jQueryHandler = Douban.handler.jquery = {
     },
 
     DELETE: function(url, params, headers, success, type) {
-        return jQuery.ajax({ url: url,
+        return jQuery.ajax({ url: Douban.util.buildUri(url, params),
                              type: 'DELETE',
-                             data: params,
                              dataType: type || 'text',
                              success: success,
                              beforeSend: jQueryHandler.beforeSend(headers) });</diff>
      <filename>src/jquery_handler.js</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>apps/media/tests/basic.js</filename>
    </removed>
    <removed>
      <filename>apps/templates/tests/basic.html</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>33b8a19ee3e0a399b2c965e61622805be63da6da</id>
    </parent>
  </parents>
  <author>
    <name>wu yuntao</name>
    <email>wyt.py@thonic.org</email>
  </author>
  <url>http://github.com/wuyuntao/jquery-douban/commit/0c111b08776ad1cd3d9d4af6006dc79183118945</url>
  <id>0c111b08776ad1cd3d9d4af6006dc79183118945</id>
  <committed-date>2009-03-19T21:20:49-07:00</committed-date>
  <authored-date>2009-03-19T21:20:49-07:00</authored-date>
  <message>Gadget handler testcases. Fix bugs</message>
  <tree>071b659682a32234b322b21909bd8183162e26b2</tree>
  <committer>
    <name>wu yuntao</name>
    <email>wyt.py@thonic.org</email>
  </committer>
</commit>
