OpenLayers OpenLayers

Ticket #1652 (closed feature: fixed)

Opened 4 months ago

Last modified 3 months ago

add Protocol.HTTP

Reported by: elemoine Assigned to: elemoine
Priority: major Milestone: 2.7 Release
Component: Protocol Version: SVN
Keywords: Cc:
State: Complete

Description

Add Protocol.HTTP with the following behavior:

  • read features using HTTP GET
  • create features using HTTP POST
  • update features using HTTP PUT
  • delete features using HTTP DELETE
  • indicate success if 200 <= status code < 300, indicate failure otherwise

This protocol doesn't know how to deal with filters, it is aimed to be subclassed or decorated by more specific REST protocols like MapFish and FeatureServer.

Attachments

patch-1652-r7754-A0.diff (36.1 kB) - added by elemoine on 08/26/08 08:29:27.
patch-1652-r7754-A1.diff (36.6 kB) - added by fredj on 08/29/08 02:46:13.
Sync patch with trunk, fix coding style (no functional change)
http.patch (41.3 kB) - added by tschaub on 09/03/08 01:40:04.
updated http protocol, tests, and example
http-2.patch (41.6 kB) - added by elemoine on 09/03/08 03:25:45.

Change History

08/06/08 01:41:18 changed by fredj

  • owner set to fredj.
  • component changed from general to Protocol.

08/06/08 01:41:31 changed by fredj

  • owner changed from fredj to elemoine.

08/14/08 10:17:15 changed by elemoine

  • state set to Review.
  • version set to SVN.

Unit tests pass on FF2, FF3 and IE7.

08/14/08 10:19:09 changed by elemoine

This ticket depends on #1677.

08/26/08 08:29:27 changed by elemoine

  • attachment patch-1652-r7754-A0.diff added.

08/29/08 02:46:13 changed by fredj

  • attachment patch-1652-r7754-A1.diff added.

Sync patch with trunk, fix coding style (no functional change)

09/02/08 17:17:57 changed by tschaub

Since this is significantly different from what is in the vector behavior sandbox, can you guys apply those changes there?

If not, ping me on irc - don't want to hold things up, just want to coordinate efforts to get this stuff in the trunk.

09/02/08 19:01:48 changed by tschaub

Tweaking this currently, I'll post a patch and hope that it works for c2c.

09/03/08 01:40:04 changed by tschaub

  • attachment http.patch added.

updated http protocol, tests, and example

09/03/08 01:57:29 changed by tschaub

Thanks for the work on this Fred and Eric. I think this is in good shape now. I'll explain my changes and look forward to hearing how this works for you.

  • I renamed things like callbackCreate to handleCallback and rewrote things a bit. This gives us create/handleCreate, read/handleRead, update/handleUpdate, delete/handleDelete. For the base class, the handle* methods pass through handleResponse.
  • With the exception of deletions, all requests are passed from the handle* methods to parseFeatures. I think these changes simplify things a bit and make it more readible (where we are already overusing names like callback, response, read, etc.).
  • I added a createCallback method that applies the appropriate method with args: response, options. This gives the handle* methods more sensible signatures - was options, response, request. Since the response object already has a reference to the request, no duplication necessary. Following on the readability bit, this gives us things like protocol.handleResponse(response, options) instead of protocol.callbackReadCreateUpdate(options, resp, request).
  • The commit method now tallies up the number of requests that will be issued before it starts issuing them. This allows the logic in the callback to properly determine when the last request has completed (previously, if a request was complete before all requests were issued, response.last was not properly set).
  • The commit method applies defaults to local options with protocol.options. This allows for creation of a protocol with a single callback that will be called with repeat protocol.commit() calls (with no options to commit). I added test_options to the test suite to confirm options to the constructor are respected.
  • Other minor doc comment and test updates and an example added.

09/03/08 03:25:45 changed by elemoine

  • attachment http-2.patch added.

09/03/08 03:30:00 changed by elemoine

  • state changed from Review to Commit.

Tim, thanks for your patch. I like your changes. I tested the patch and it works great for me. http-2.patch brings a few changes to the doc:

  • complete the doc for the callback property
  • specify that properties url, headers, params, scope and callback are read-only properties that must be set through the options passed to the constructor
  • remove the options property, which is already in the parent class

I think this is ready to go. Please commit if you agree with my changes.

09/03/08 15:10:47 changed by tschaub

  • status changed from new to closed.
  • state changed from Commit to Complete.
  • resolution set to fixed.

(In [7940]) Adding HTTP protocol. Give a vector layer the HTTP protocol to create, read, update, and delete features via HTTP. This can be subclassed by protocols that extend HTTP. Thanks for the collaboration (and great tests) on this elemoine - good working with you guys. r=elemoine,me (closes #1652)