AtomPub for zgeo.atom
2008-03-14T05:11:17Z | Comments: 5
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://zcologia.com/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"> <p>600 N Sherwood St, Fort Collins, CO</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://zcologia.com/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://zcologia.com/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://zcologia.com/kw/demo/600-n-sherwood/atom-entry" type="application/atom+xml;type=entry" rel="edit"/> <link href="http://zcologia.com/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://zcologia.com/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.
