I'm trying to integrate lazr.restful into a Zope3 app and I was advised to created my own publication factory. For that I did
<publisher
name="LAZRWS"
factory=".root.WSFactory"
methods="GET POST HEAD DELETE"
mimetypes="*"
priority="5"
/>
Priority is set to 5 as opposed to priority 10 of the standard BROWSER declaration in zope/app/publication/configure.zcml
<publisher
name="BROWSER"
factory=".requestpublicationfactories.BrowserFactory"
methods="GET POST HEAD"
mimetypes="*"
priority="10"
/>
But although the RequestPublicationFactory class say:
"The `priority` is used to define a lookup-order when multiple factories
are registered for the same method and mime-type."
the RequestPublicationFactory.lookup does not really take that into account.
So what I did on line 104 of zope/app/publication/requestpublicationregistry.py
from operator import itemgetter
factory_lst = sorted(factory_lst, key=itemgetter('priority'))
Now it works as expected, calling canHandle of my factory and then falling back to ".requestpublicationfactories.BrowserFactory" for non WS requests.
Is this really a bug or should I be doing something different?
Thanks
Gustavo