[Checkins] SVN: z3c.rest/trunk/ Get ready for new release.
Stephan Richter
srichter at cosmos.phy.tufts.edu
Thu Mar 20 14:08:26 EDT 2008
Log message for revision 84806:
Get ready for new release.
Changed:
U z3c.rest/trunk/CHANGES.txt
U z3c.rest/trunk/setup.py
U z3c.rest/trunk/src/z3c/rest/client.py
U z3c.rest/trunk/src/z3c/rest/client.txt
U z3c.rest/trunk/src/z3c/rest/tests/folder.pt
-=-
Modified: z3c.rest/trunk/CHANGES.txt
===================================================================
--- z3c.rest/trunk/CHANGES.txt 2008-03-20 13:43:53 UTC (rev 84805)
+++ z3c.rest/trunk/CHANGES.txt 2008-03-20 18:08:25 UTC (rev 84806)
@@ -2,6 +2,14 @@
CHANGES
=======
+0.2.3 (2008-03-20)
+------------------
+
+- Bug/Misfeature: Sigh, getting the trailing slash handled correctly turned
+ out to be a big pain. I really hope I got it working the way it should be
+ for a REST client now.
+
+
0.2.2 (2008-03-19)
------------------
@@ -21,12 +29,14 @@
- Feature: Require lxml 2.0 for z3c.rest.
+
0.2.0 (2008-03-03)
------------------
- Feature: Made the HTTP caller pluggable for the REST client, allowing
request types other than ``RESTRequest``.
+
0.1.0 (2008-03-03)
------------------
Modified: z3c.rest/trunk/setup.py
===================================================================
--- z3c.rest/trunk/setup.py 2008-03-20 13:43:53 UTC (rev 84805)
+++ z3c.rest/trunk/setup.py 2008-03-20 18:08:25 UTC (rev 84806)
@@ -31,7 +31,7 @@
setup (
name='z3c.rest',
- version='0.2.3dev',
+ version='0.2.3',
author = "Stephan Richter and the Zope Community",
author_email = "zope3-dev at zope.org",
description = "A REST Framework for Zope 3 Applications",
Modified: z3c.rest/trunk/src/z3c/rest/client.py
===================================================================
--- z3c.rest/trunk/src/z3c/rest/client.py 2008-03-20 13:43:53 UTC (rev 84805)
+++ z3c.rest/trunk/src/z3c/rest/client.py 2008-03-20 18:08:25 UTC (rev 84806)
@@ -35,6 +35,8 @@
def absoluteURL(base, url):
"""Convertes a URL to an absolute URL given a base."""
if isRelativeURL(url):
+ if not base.endswith('/'):
+ base += '/'
fullUrl = urlparse.urljoin(base, url)
else:
fullUrl = url
Modified: z3c.rest/trunk/src/z3c/rest/client.txt
===================================================================
--- z3c.rest/trunk/src/z3c/rest/client.txt 2008-03-20 13:43:53 UTC (rev 84805)
+++ z3c.rest/trunk/src/z3c/rest/client.txt 2008-03-20 18:08:25 UTC (rev 84806)
@@ -23,6 +23,7 @@
<title></title>
<items>
</items>
+ <acl xlink:type="simple" xlink:href="acl" xlink:title="ACL"/>
</folder>
You can also instantiate the client providing a URL:
@@ -35,6 +36,7 @@
<title></title>
<items>
</items>
+ <acl xlink:type="simple" xlink:href="acl" xlink:title="ACL"/>
</folder>
@@ -52,6 +54,7 @@
<title></title>
<items>
</items>
+ <acl xlink:type="simple" xlink:href="acl" xlink:title="ACL"/>
</folder>
There are several other pieces of information of the response that are
@@ -67,7 +70,7 @@
'200 Ok'
>>> client.headers
[('X-Powered-By', 'Zope (www.zope.org), Python (www.python.org)'),
- ('Content-Length', '140'),
+ ('Content-Length', '204'),
('Content-Type', 'text/xml;charset=utf-8')]
If we try to access a non-existent resource, no exception is raised, but the
@@ -103,6 +106,7 @@
<folder xmlns:xlink="http://www.w3.org/1999/xlink">
<name></name>
<title></title>
+ <acl xlink:type="simple" xlink:href="acl" xlink:title="ACL"/>
</folder>
You can also specify the parameter via an argument:
@@ -113,6 +117,7 @@
<folder xmlns:xlink="http://www.w3.org/1999/xlink">
<name></name>
<title></title>
+ <acl xlink:type="simple" xlink:href="acl" xlink:title="ACL"/>
</folder>
You can even combine the two methods of specifying parameters:
@@ -122,6 +127,7 @@
<?xml version="1.0" ?>
<folder xmlns:xlink="http://www.w3.org/1999/xlink">
<name></name>
+ <acl xlink:type="simple" xlink:href="acl" xlink:title="ACL"/>
</folder>
But our little demo API can do more. Parameters can also be specified as a
@@ -135,6 +141,7 @@
<folder xmlns:xlink="http://www.w3.org/1999/xlink">
<name></name>
<title></title>
+ <acl xlink:type="simple" xlink:href="acl" xlink:title="ACL"/>
</folder>
There is also a headers argument to the "open" methods that specify the header
@@ -145,6 +152,7 @@
<?xml version="1.0" ?>
<folder xmlns:xlink="http://www.w3.org/1999/xlink">
<name></name>
+ <acl xlink:type="simple" xlink:href="acl" xlink:title="ACL"/>
</folder>
>>> del client.requestHeaders['demo-noitems']
@@ -209,6 +217,7 @@
xlink:href="http://localhost/folder1"
xlink:title="folder1"/>
</items>
+ <acl xlink:type="simple" xlink:href="acl" xlink:title="ACL"/>
</folder>
By the way, you can now use a relative URL to access the `folder1` resource:
@@ -225,6 +234,7 @@
<title></title>
<items>
</items>
+ <acl xlink:type="simple" xlink:href="acl" xlink:title="ACL"/>
</folder>
When we try to create a resource on top of a non-existent resource, we get a
@@ -264,6 +274,7 @@
<title>My Folder 1</title>
<items>
</items>
+ <acl xlink:type="simple" xlink:href="acl" xlink:title="ACL"/>
</folder>
As mentioned above, it must also work for PUT:
@@ -286,6 +297,7 @@
<title>Folder 1</title>
<items>
</items>
+ <acl xlink:type="simple" xlink:href="acl" xlink:title="ACL"/>
</folder>
@@ -352,6 +364,7 @@
xlink:href="http://localhost/folder2"
xlink:title="folder2"/>
</items>
+ <acl xlink:type="simple" xlink:href="acl" xlink:title="ACL"/>
</folder>
But in general, inspecting the XML output on the string level is tedious. So
@@ -399,8 +412,19 @@
...
ValueError: You must specify a title or URL.
+Links can also be relative, such as the one for ACL:
+
+ >>> client.open('http://localhost/folder1')
+ >>> client.getLink('ACL')
+ <XLink title='ACL' url='http://localhost/folder1/acl'>
+
+ >>> client.open('http://localhost/folder1/')
+ >>> client.getLink('ACL')
+ <XLink title='ACL' url='http://localhost/folder1/acl'>
+
The cool part about the link is that you can click it:
+ >>> client.open('http://localhost/')
>>> client.url
'http://localhost/'
@@ -439,6 +463,7 @@
xlink:href="http://localhost/folder2"
xlink:title="folder2"/>
</items>
+ <acl xlink:type="simple" xlink:href="acl" xlink:title="ACL"/>
</folder>
But going back in history is only cool, if you can also reload. So let's
@@ -467,6 +492,7 @@
xlink:href="http://localhost/folder2"
xlink:title="folder2"/>
</items>
+ <acl xlink:type="simple" xlink:href="acl" xlink:title="ACL"/>
</folder>
As expected, the contents has not changed yet. So let's reload:
@@ -486,6 +512,7 @@
xlink:href="http://localhost/folder1"
xlink:title="folder1"/>
</items>
+ <acl xlink:type="simple" xlink:href="acl" xlink:title="ACL"/>
</folder>
Note that going back zero steps does nothing:
Modified: z3c.rest/trunk/src/z3c/rest/tests/folder.pt
===================================================================
--- z3c.rest/trunk/src/z3c/rest/tests/folder.pt 2008-03-20 13:43:53 UTC (rev 84805)
+++ z3c.rest/trunk/src/z3c/rest/tests/folder.pt 2008-03-20 18:08:25 UTC (rev 84806)
@@ -11,4 +11,5 @@
tal:attributes="xlink:href item/@@absolute_url;
xlink:title item/__name__" />
</items>
+ <acl xlink:type="simple" xlink:href="acl" xlink:title="ACL" />
</folder>
More information about the Checkins
mailing list