← Back to team overview

lazr-users team mailing list archive

Re: Using lazr.restful with a zope3 app

 

Hi Gustavo.  Thank you for writing.

Please see responses inline below.

On Jun 18, 2010, at 1:26 PM, Gustavo Rahal wrote:

> Ok, my first email was vague (late work day, I guess I was too tired)
> 
> Now I also understand a bit more the martian stuff which I did not had much idea first and things make some more sense
> 
> So, I removed the root["foobar"] hack and tried a few things in zope debug prompt:
> 
> >>> request = create_web_service_request("/api/1.0/")
> >>> request.traverse(root)
> <tp4.rest.root.WebServiceRootResource object at 0xeca8fec>
> 
> >>> request = create_web_service_request("/api/1.0/systems")  # systems is a collection I created
> >>> request.traverse(root)
> <lazr.restful._resource.CollectionResource object at 0xbca4c8c>
> 
> So, at least the setup seems right, or part of it

cool

> 
> The create_web_service_request, as well as the WSGIApplication, are customizing the request to empower it so it can find and deal with the WS.
> 
> How can I do that when a request is really coming from a browser?

I assume you mean "when a request is really coming through the Zope publisher".

In Zope 3, you'll need to register your own IRequestPublicationFactory, which will look at a request, claim it, and return a webservice request.  Launchpad does this (along with lots of other confusing bits) in the register_launchpad_request_publication_factories function of http://bazaar.launchpad.net/~launchpad-pqm/launchpad/db-devel/annotate/head:/lib/canonical/launchpad/webapp/servers.py .  Switching that to zcml shouldn't be too bad.

Hope that helps

Gary

> 
> 
> 
> 
> 2010/6/17 Gustavo Rahal <gustavorahal@xxxxxxxxx>
> Hello
> 
> I'm trying to setup lazr.restful with a zope3 app, more specifically z3ext/zojax (http://z3ext.net and http://sourceforge.net/projects/zojax/)
> Part of my trouble is just plain lack of traversal/publisher/zope3 knowledge but I did understand some bits from reading the txt files in lazr.resful package.
> 
> So, I noticed that the WSGI app class (wsgi.WSGIApplication) has the "__iter__" method that seems to be customizing the request and publisher that takes care of the request. Also, by reading Martjin email (https://lists.launchpad.net/lazr-users/msg00006.html) it seems that I need to plug in this customization into my zope app. Is this something I need to do manually or lazr.restful does it for me when I register a RootResource ?. If I need to do that, how should I proceed?
> 
> I tried a lame test and simply added my service root object into app root when I accessed localhost:8080/foobar I could get the service root
> 
> service = getUtility(IServiceRootResource)
> root["foobar"] = service
> transaction.commit()
> 
> apparently it did not work. I'm not sure how I can test that programatically as well. Doing a getMultiAdapter((root["foobar"], request), name=??) does not seem to make much sense as I don't have a view name...
> 
> Anyway, i'm clearly lost in the zope3/lazr concepts so some direction is appreciated
> 
> 
> Thanks
> Gustavo
> 
> 
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~lazr-users
> Post to     : lazr-users@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~lazr-users
> More help   : https://help.launchpad.net/ListHelp




Follow ups

References