← Back to team overview

lazr-users team mailing list archive

Re: Using lazr.restful with a zope3 app

 

On Jun 21, 2010, at 11:37 AM, Gustavo Rahal wrote:

> 
> Thanks, it indeed worked out.

Awesome.

> I think there is even a bug on zope.app.publication. Asked zope-dev for comments

I just looked at that.  It does sound suspicious, yes.  (I'd suggest you using .sort rather than sorted in this case, but that's trivial.)  I'm going to hope someone else follows up, so I don't get bogged down there, but if you decide you need to kick someone to get attention on it, I guess I'm willing to be kicked. :-)

> 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?

I think actually it's the call to sorted on the result of registeredAdapters().

The core problem is that the z3c/form/button.py object, whatever it is, has a broken repr.  A broken repr is just unacceptable IMO.

This code is trying to generate WADL.  It wants the WADL output to be stable, so it sorts.  It could probably sort something else further down the chain, but what it is doing now is entirely reasonable, so it's hard to argue for a change to accommodate a broken repr.  The z3c.form bits should be fixed, is my take.

Gary


Follow ups

References