Zope's Webdav port for RESTful web service
Hi. I am looking at how to implement a RESTful web service in Zope2. Has anyone implemented such a thing that could provide any advice. Is it possible just to use the existing webdav port for this to provide a dedicated port? The only thing close I can think of at the moment is SchoolTool but it is a Zope3 implementation. Many thanks. Regards, David
Hi Tino. Here are a couple of links that describe it. Boils down to using regular GET, POST, PUT, and DELETE over HTTP using specific URI's to invoke actions - sort of like XMLRPC over HTTP. It occurred to me that perhaps the current webdav server could be modified to handle requests for this purpose. I wondered how sensible this would be and whether anyone else has considered this or other options for setting up another listener for this type of service to their sites. REST Web Service Conventions: - Plain XML is the data representation format. - HTTP is the transfer protocol. - HTTP's GET, POST, PUT, and DELETE are the access/manipulation verbs. - URIs point to individual data records (such as catalog items or customer info). - HTTP authentication and SSL provide security. http://www.networkworld.com/ee/2003/eerest.html http://www.osmoticweb.com/rest-web-service-demo.htm http://www.xml.com/pub/a/2004/12/01/restful-web.html http://www.xml.com/pub/a/2005/08/17/restful-web.html http://www.xml.com/pub/a/2005/11/02/rest-on-rails.html http://hinchcliffe.org/archive/2005/02/12/171.aspx Regards, David On Saturday, November 26, 2005, at 09:26 PM, Tino Wildenhain wrote:
Am Samstag, den 26.11.2005, 21:17 -0400 schrieb David Pratt:
Hi. I am looking at how to implement a RESTful web service in Zope2.
Could you expand a bit on whatever a RESTful web service is?
thx Tino
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 David Pratt wrote:
Hi Tino.
Here are a couple of links that describe it. Boils down to using regular GET, POST, PUT, and DELETE over HTTP using specific URI's to invoke actions - sort of like XMLRPC over HTTP. It occurred to me that perhaps the current webdav server could be modified to handle requests for this purpose. I wondered how sensible this would be and whether anyone else has considered this or other options for setting up another listener for this type of service to their sites.
REST Web Service Conventions:
- Plain XML is the data representation format.
That isn't part of REST at all. RESTified applications can be built using *any* fileish representation.
- HTTP is the transfer protocol. - HTTP's GET, POST, PUT, and DELETE are the access/manipulation verbs.
Zope already supports applicatoins built around the standard HTTP verbs. The trickiest thing about REST from Zope's point of view is that its proponents seem to think POST (which is a general purpose verb) should only be used for "resource creation". Zope is happy to map POST / GET requests onto *any* publishable method, which means that you have to try hard to abide by the RESTriction. Zope also supports using PUT for "resource creation", which the REST folks don't seem to get.
- URIs point to individual data records (such as catalog items or customer info).
Already doable, and in fact done in many Zope applications.
- HTTP authentication and SSL provide security.
Likewise. Basically, Zope already provides everything you need, and more (not using the "more" is the hard part). Tres. - -- =================================================================== Tres Seaver +1 202-558-7113 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDiwV/+gerLs4ltQ4RAjavAJ9PnKZ8rhVi9ZsyCIbrH02tNjzamgCgrsLL iY2u2jHWvH5uT3riUtK+coQ= =B+lA -----END PGP SIGNATURE-----
Hi. Thanks Tres and Sascha for replies. Sascha, I think this is right way to go and will make a product to do this and put the templates into skins. As far as URL's, I was hoping to do something like: http://mydomain.com/folder_to_resource/resource_id but I guess it will be enough to append to the url to trigger the method(s) Iike: http://mydomain.com/folder_to_resource/resource_id/get_resource http://mydomain.com/folder_to_resource/resource_id/modify_resource etc.. I am not using xhtml for my exchange but another xml format. I was originally thinking of using a different port for this which is reason for possible use of webdav port instead of regular port. Regards, David On Monday, November 28, 2005, at 09:26 AM, Tres Seaver wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
David Pratt wrote:
Hi Tino.
Here are a couple of links that describe it. Boils down to using regular GET, POST, PUT, and DELETE over HTTP using specific URI's to invoke actions - sort of like XMLRPC over HTTP. It occurred to me that perhaps the current webdav server could be modified to handle requests for this purpose. I wondered how sensible this would be and whether anyone else has considered this or other options for setting up another listener for this type of service to their sites.
REST Web Service Conventions:
- Plain XML is the data representation format.
That isn't part of REST at all. RESTified applications can be built using *any* fileish representation.
- HTTP is the transfer protocol. - HTTP's GET, POST, PUT, and DELETE are the access/manipulation verbs.
Zope already supports applicatoins built around the standard HTTP verbs. The trickiest thing about REST from Zope's point of view is that its proponents seem to think POST (which is a general purpose verb) should only be used for "resource creation". Zope is happy to map POST / GET requests onto *any* publishable method, which means that you have to try hard to abide by the RESTriction. Zope also supports using PUT for "resource creation", which the REST folks don't seem to get.
- URIs point to individual data records (such as catalog items or customer info).
Already doable, and in fact done in many Zope applications.
- HTTP authentication and SSL provide security.
Likewise. Basically, Zope already provides everything you need, and more (not using the "more" is the hard part).
Tres. - -- =================================================================== Tres Seaver +1 202-558-7113 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFDiwV/+gerLs4ltQ4RAjavAJ9PnKZ8rhVi9ZsyCIbrH02tNjzamgCgrsLL iY2u2jHWvH5uT3riUtK+coQ= =B+lA -----END PGP SIGNATURE-----
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
Yeah, if POST and GET are desired to have semantic differences, your code will have to explicitly check request['REQUEST_METHOD']. On 11/28/05, Tres Seaver <tseaver@palladion.com> wrote:
The trickiest thing about REST from Zope's point of view is that its proponents seem to think POST (which is a general purpose verb) should only be used for "resource creation". Zope is happy to map POST / GET requests onto *any* publishable method, which means that you have to try hard to abide by the RESTriction. Zope also supports using PUT for "resource creation", which the REST folks don't seem to get.
On 28 Nov 2005 at 8:26, Tres Seaver wrote:
requests onto *any* publishable method, which means that you have to try hard to abide by the RESTriction. Zope also supports using PUT for "resource creation", which the REST folks don't seem to get.
I'm not sure what part REST folks don't seem to get regarding PUT. But in any case, I have not been able to get PUT to work in a PythonScript in Zope 2.7.2 because PythonScript objects have a PUT method that assumes it's a DAV upload. PythonScript.py line 368 or so def PUT(self, REQUEST, RESPONSE): """ Handle HTTP PUT requests """ self.dav__init(REQUEST, RESPONSE) self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1) self.write(REQUEST.get('BODY', '')) RESPONSE.setStatus(204) return RESPONSE Plus that method is protected by "Change Python Scripts" permission as well. -- Brad Clements, bkc@murkworks.com (315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements
Brad Clements wrote:
PythonScript.py line 368 or so
def PUT(self, REQUEST, RESPONSE): """ Handle HTTP PUT requests """ self.dav__init(REQUEST, RESPONSE) self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1) self.write(REQUEST.get('BODY', '')) RESPONSE.setStatus(204) return RESPONSE
...well, you could always subclass and override ;-)
Plus that method is protected by "Change Python Scripts" permission as well.
Why is that a problem? Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
On 29 Nov 2005 at 9:53, Chris Withers wrote:
Brad Clements wrote:
PythonScript.py line 368 or so
def PUT(self, REQUEST, RESPONSE):
...well, you could always subclass and override ;-)
Plus that method is protected by "Change Python Scripts" permission as well.
Why is that a problem?
My point was that I wanted to create a REST compliant interface in PythonScript, without having to create any Zope products. That is not possible given the current design. Just a simple statement, that is all. -- Brad Clements, bkc@murkworks.com (315)268-1000 http://www.murkworks.com AOL-IM or SKYPE: BKClements
participants (6)
-
Brad Clements -
Chris Withers -
David Pratt -
Paul Winkler -
Tino Wildenhain -
Tres Seaver