[prev in list] [next in list] [prev in thread] [next in thread] 

List:       zope-dev
Subject:    [Zope-dev] possible bug in zope.app.publication
From:       Gustavo Rahal <gustavorahal () gmail ! com>
Date:       2010-06-21 13:24:33
Message-ID: AANLkTimMRM5Z5UVgJ9rx0XJ5Tp4Bf_wMCFpxbYl_Mywf () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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

[Attachment #5 (text/html)]

I&#39;m trying to integrate lazr.restful into a Zope3 app and I was advised to \
created my own publication factory. For that I did<br><br>  &lt;publisher<br>      \
name=&quot;LAZRWS&quot;<br>      factory=&quot;.root.WSFactory&quot;<br>

      methods=&quot;GET POST HEAD DELETE&quot;<br>      mimetypes=&quot;*&quot;<br>   \
priority=&quot;5&quot;<br>      /&gt;<br><br>Priority is set to 5 as opposed to \
priority 10 of the standard BROWSER declaration in \
zope/app/publication/configure.zcml<br>

<br>  &lt;publisher<br>      name=&quot;BROWSER&quot;<br>      \
factory=&quot;.requestpublicationfactories.BrowserFactory&quot;<br>      \
methods=&quot;GET POST HEAD&quot;<br>      mimetypes=&quot;*&quot;<br>      \
priority=&quot;10&quot;<br>

      /&gt;<br><br>But although the RequestPublicationFactory class say:<br><br>    \
&quot;The `priority` is used to define a lookup-order when multiple factories<br>    \
are registered for the same method and mime-type.&quot;<br>

<br>the RequestPublicationFactory.lookup does not really take that into \
account.<br>So what I did on line 104 of \
zope/app/publication/requestpublicationregistry.py<br><br>        from operator \
import itemgetter<br>        factory_lst = sorted(factory_lst, \
key=itemgetter(&#39;priority&#39;))<br>

<br>Now it works as expected, calling canHandle of my factory and then falling back \
to &quot;.requestpublicationfactories.BrowserFactory&quot; for non WS \
requests.<br><br>Is this really a bug or should I be doing something different?<br>

<br><br>Thanks<br>Gustavo<br><br><br>



_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
https://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope )


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic