[Zope] Permission problem creating a wrapper class for custom search

Francis Kelly plone at crubellier.com
Wed Jun 2 19:51:38 EDT 2004


I'm trying to create custom search module that will fit into the out-of-the-box
Plone search functionality. I'm running into a permissions problem (which I
believe is a Zope and not Plone issue). I get back a list of dictionary objects
from my search method and I want to wrap those up in an object akin to the
AbstractCatalogBrains object used by Zope. But when I use my own SearchWrapper
class, an Unauthorized exception is raised telling me I don't have the right to
use the methods of my SearchWrapper class.

To summarize:
(1) a python script calls a search method that returns a list of dictionaries
(2) the list of dictionaries gets converted into a list of SearchWrapper objects
(3) the search.pt (in Plone) tries to display the search results, but when it
tries to use the methods/attributes of the SearchWrapper class (e.g. Title,
getId(), getURL(), etc) it raises an Unauthorized exception.

I've tried different strategies: defining SearchWrapper as a Product as well as
putting it in the Extensions directory. Neither seemed to work.

I guess my basic question is: how do I tell Zope that my SearchWrapper class is
safe in the same way that the AbstractCatalogBrains is safe, since Zope is ok
using the methods and attributes of search when it returns a list of ACB objects?

(I'll just add: I did try to sub-clas AbstractCatalogBrains, but I ran into
problems trying to define new attributes. I'm assuming ACB is defined (using
__slots__ or something), such that you can't define new attributes on
sub-classes. I'm quite new to Python and didn't have a lot of success figuring
that one out.)

Thanks in advance for your help!

Francis




More information about the Zope mailing list