lazr-users team mailing list archive
-
lazr-users team
-
Mailing list archive
-
Message #00028
Re: Using lazr.restful with a zope3 app
Thanks, it indeed worked out. I think there is even a bug on
zope.app.publication. Asked zope-dev for comments
So, now I have another problem that seems more obscure. I'm using
lazr.restfulclient and did a call to /api/
---
Response body:
---
maximum recursion depth exceeded
Traceback (most recent call last):
File
"/home/grahal/.buildout/eggs/zope.publisher-3.4.6-py2.5.egg/zope/publisher/publish.py",
line 133, in publish
result = publication.callObject(request, obj)
File
"/home/grahal/devel/eclipse-workspace/virtualenv/lazr.restful/src/lazr/restful/publisher.py",
line 171, in callObject
WebServicePublicationMixin, self).callObject(request, object)
File
"/home/grahal/devel/eclipse-workspace/virtualenv/lazr.restful/src/lazr/restful/simple.py",
line 113, in callObject
return mapply(ob, request.getPositionalArguments(), request)
File
"/home/grahal/.buildout/eggs/zope.publisher-3.4.6-py2.5.egg/zope/publisher/publish.py",
line 108, in mapply
return debug_call(obj, args)
File
"/home/grahal/.buildout/eggs/zope.publisher-3.4.6-py2.5.egg/zope/publisher/publish.py",
line 114, in debug_call
return obj(*args)
File
"/home/grahal/devel/eclipse-workspace/virtualenv/lazr.restful/src/lazr/restful/_resource.py",
line 1739, in __call__
result = self.do_GET()
File
"/home/grahal/devel/eclipse-workspace/virtualenv/lazr.restful/src/lazr/restful/_resource.py",
line 1780, in do_GET
result = self.toWADL().encode("utf-8")
File
"/home/grahal/devel/eclipse-workspace/virtualenv/lazr.restful/src/lazr/restful/_resource.py",
line 1801, in toWADL
for registration in sorted(site_manager.registeredAdapters()):
File
"/home/grahal/.buildout/eggs/zope.component-3.4.0-py2.5.egg/zope/component/registry.py",
line 435, in __cmp__
return cmp(self.__repr__(), other.__repr__())
File
"/home/grahal/.buildout/eggs/zope.component-3.4.0-py2.5.egg/zope/component/registry.py",
line 431, in __repr__
getattr(self.factory, '__name__', `self.factory`), self.info,
File
"/home/grahal/.buildout/eggs/z3c.form-2.2.0-py2.5.egg/z3c/form/button.py",
line 65, in __repr__
self.__class__.__name__, self.__name__, self.title)
File
"/home/grahal/.buildout/eggs/z3c.form-2.2.0-py2.5.egg/z3c/form/button.py",
line 65, in __repr__
self.__class__.__name__, self.__name__, self.title)
[...]
RuntimeError: maximum recursion depth exceeded
The call to site_manager.registeredAdapters() is what cause this problem.
Any ideas?
Thanks again
2010/6/18 Gary Poster <gary.poster@xxxxxxxxxxxxx>
> 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<http://bazaar.launchpad.net/%7Elaunchpad-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<https://launchpad.net/%7Elazr-users>
> > Post to : lazr-users@xxxxxxxxxxxxxxxxxxx
> > Unsubscribe : https://launchpad.net/~lazr-users<https://launchpad.net/%7Elazr-users>
> > More help : https://help.launchpad.net/ListHelp
>
>
Follow ups
References