AtomPub for zgeo.atom

I've rewritten Knowhere's AtomPub implementation, dropping the Grok skin traversal mechanism in favor of a custom publisher and customized traverser. I've gained harmony among the various resource URLs and learned a ton about publishing in Zope. Now, zgeo.atom has an incomplete, but functional Atom publishing protocol. A collection is currently online at

http://sgillies.net/kw/demo/atompub-collection

The curious are free to add new placemark entries and edit them following the steps below.

First, create a file called test.atom with contents something like this:

<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom"
       xmlns:georss="http://www.georss.org/georss"
       xmlns:gml="http://www.opengis.net/gml">
  <title>Test</title>
  <summary>Testing placemark</summary>
  <content type="text/html">
    &lt;p>600 N Sherwood St, Fort Collins, CO&lt;/p>
  </content>
  <georss:where>
    <gml:Point>
      <gml:pos>-105.0842514037999962 40.5944633483999979</gml:pos>
    </gml:Point>
  </georss:where>
</entry>

Use your own location for extra points. Add to my collection using everyone's favorite RESTful client, curl:

sean@lenny:/tmp$ curl -i -X POST \
  -H "Authorization: Basic YWRtaW46OGZjOGFkZmM=" \
  -H "Content-Type: application/atom+xml;type=entry" \
  -H "Slug: 600 N Sherwood" \
  -d@test.atom \
  http://sgillies.net/kw/demo/atompub-collection

Use a different slug if you like. Here are the response headers:

HTTP/1.1 201 Created
Date: Fri, 14 Mar 2008 04:32:33 GMT
Server: Twisted/2.5.0 TwistedWeb/[twisted.web2, version 0.2.0]
Content-Length: 744
X-Powered-By: Zope (www.zope.org), Python (www.python.org)
Accept-Ranges: bytes
Location: http://sgillies.net/kw/demo/600-n-sherwood/atom-entry
Content-Type: application/atom+xml;type=entry

Browse to that location and you'll get an Atom entry document like this:

<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom"
       xmlns:georss="http://www.georss.org/georss"
       xmlns:gml="http://www.opengis.net/gml">

    <title>Test</title>
    <link href="http://sgillies.net/kw/demo/600-n-sherwood/atom-entry"
          type="application/atom+xml;type=entry" rel="edit"/>
    <link href="http://sgillies.net/kw/demo/600-n-sherwood"
          type="text/html" rel="alternate"/>
    <id>urn:uuid:dfa47428-e9ce-41b4-9f42-c2a3cad9037a</id>
    <updated>2008-03-14T04:32:33Z</updated>
    <summary>Testing placemark</summary>
    <georss:where>
      <gml:Point>
        <gml:pos>-105.084251 40.594463</gml:pos>
      </gml:Point>
    </georss:where>
</entry>

The newly created placemark can be edited by PUT of a new representation to its "edit" link. Edit your test.atom file, changing the title, or summary, or location, and use curl once again:

sean@lenny:/tmp$ curl -i -X PUT \
  -H "Authorization: Basic YWRtaW46OGZjOGFkZmM=" \
  -H "Content-Type: application/atom+xml;type=entry" \
  -d@test-edit.atom \
  http://sgillies.net/kw/demo/600-n-sherwood/atom-entry

The response: HTTP/1.1 200 OK.

DELETE works too. Go ahead and delete your own placemark if you wish. It's not as exciting as you might think. The Knowhere map app uses the same AtomPub links to add placemarks. Editing and deletion through OpenLayers are next up.

Comments

Re: AtomPub for zgeo.atom

Author: Brian Flood

hi sean what are your thoughts on APP feeds with multiple geometry types? (like the example above). At first I thought we should enforce a single geometry type per feed but this is probably impracticable in the real world. Client apps that tried to enforce this would be precluded from using (what could be) the vast majority of feeds that don’t care about enforcing similar geometries (for example I could see GMaps MyMaps doing this). How do you see the OL APP client working? a free for all like cschmidt’s original demo or something more GIS like with a single geometry? for our ArcMap client, I’m now creating point,line,and polygon featureclasses for each feed to serve as the local store. users will need to switch between layers when editing but all updates will be posted to the same feed. thoughts? cheers brian

Re: AtomPub for zgeo.atom

Author: Yves Moisan

Neat. Made me discover curl on Windows. I typed a bit too quick and inadvertently edited the title of your 600 N sherwood entry :-(. I redid it after for the entry I made for "Mont Orford" and refixed yours using the info in your edit.atom example :-). Phew ! Great work again.

Re: AtomPub for zgeo.atom

Author: Sean

Brian, I'm mainly going to use collections of a single geometry type for Pleiades, separating settlements and ethnic regions for example, but there are uses for the free for all collection.

Re: AtomPub for zgeo.atom

Author: Sean

Thanks, Yves. Hopefully I can turn some other Zope/Plone developers on to this. The scope of zgeo.atom is rather narrow now, but could be generalized to non-geo content.

Re: AtomPub for zgeo.atom

Author: Yves Moisan

Hopefully I can turn [INTO a] Zope/Plone developer [soon]. I'm more of a give-it-a-quick-go lurker for the time being.