Unauthorized error with ZCatalog
I have some "trusted code" (an external method) which is doing a ZCatalog search: sRes = targetFolder.Catalog({'PrincipiaSearchSource' : self.REQUEST['searchText']}) But this is causing the following error: Traceback (innermost last): Module ZPublisher.Publish, line 115, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 41, in call_object Module OFS.DTMLMethod, line 144, in __call__ - <DTMLMethod at /Playwiser/WUI/SearchPublicPosts> - Physical Path: /Playwiser/WUI/SearchPublicPosts Module DocumentTemplate.DT_String, line 476, in __call__ Module DocumentTemplate.DT_Let, line 75, in render Module DocumentTemplate.DT_Util, line 196, in eval - __traceback_info__: document_id Module <string>, line 1, in <expression> Module Products.ExternalMethod.ExternalMethod, line 232, in __call__ - __traceback_info__: (('SearchPublicPosts',), {}, None) Module /apps/Zope-2.9.2/Extensions/playwiser-1.0.py, line 718, in ProcessControl Module <string>, line 1, in ? Module /apps/Zope-2.9.2/Extensions/playwiser-1.0.py, line 6819, in subSearchPublicPosts Module Products.ZCatalog.CatalogBrains, line 86, in getObject Module OFS.Traversable, line 238, in restrictedTraverse Module OFS.Traversable, line 209, in unrestrictedTraverse - __traceback_info__: ([], '0000000001') Module AccessControl.ImplPython, line 563, in validate Module AccessControl.ImplPython, line 461, in validate Module AccessControl.ImplPython, line 808, in raiseVerbose Unauthorized: Your user account does not have the required permission. Access to '0000000001' of (BTreeFolder2 at /Playwiser/PublicForums/0000000000/0000000000) denied. Your user account, Anonymous User, exists at /acl_users. Access requires one of the following roles: ['Manager']. Your roles in this context are ['Anonymous']. This error is being generated because the containing folders ( /Playwiser/PublicForums/0000000000/0000000000) require 'Manager' privileges to access and the external method is being run from an 'Anonymous' method. I do not want users to be able to access the folders or content directly (hence the 'Manager' restrictions), I only want users to access the content of these folders via the external method routines (so that I can control inputs, searching and display). The problem code in CatalogBrains.py is: line 60: def getObject(self, REQUEST=None): ... line 85: try: line 86: target = parent.restrictedTraverse(path[-1]) line 87: except ConflictError: line 88: raise Is there any way to get Zope to treat my external method as if it had 'Manager' access privilege so that the restrictedTraverse call doesn't generate the "Unauthorized" error? (ie. in python scripts you can set a proxy role, but I don't know of anything similar for external methods). Any and all ideas appreciated! Jonathan
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jonathan wrote:
Is there any way to get Zope to treat my external method as if it had 'Manager' access privilege so that the restrictedTraverse call doesn't generate the "Unauthorized" error? (ie. in python scripts you can set a proxy role, but I don't know of anything similar for external methods).
Any and all ideas appreciated!
Look at the '_unrestrictedGetObject' method of the brain. Tres. - -- =================================================================== Tres Seaver +1 540-429-0999 tseaver@palladion.com Palladion Software "Excellence by Design" http://palladion.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFF+Cf7+gerLs4ltQ4RAkcmAJ9SJ7Q+f5zCRFaH9IrNHZ3YTNeo5gCfWLuY y2t61Z+Fs9Fmf9lpDQn5JEs= =KC63 -----END PGP SIGNATURE-----
----- Original Message ----- From: "Tres Seaver" <tseaver@palladion.com> To: <zope@zope.org> Cc: <public-zope-CWUwpEBWKX0@ciao.gmane.org> Sent: Wednesday, March 14, 2007 12:51 PM Subject: [Zope] Re: Unauthorized error with ZCatalog
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Jonathan wrote:
Is there any way to get Zope to treat my external method as if it had 'Manager' access privilege so that the restrictedTraverse call doesn't generate the "Unauthorized" error? (ie. in python scripts you can set a proxy role, but I don't know of anything similar for external methods).
Any and all ideas appreciated!
Look at the '_unrestrictedGetObject' method of the brain.
Exactly what I needed Tres. Thanks very much! Jonathan
Jonathan wrote at 2007-3-14 10:10 -0400:
I have some "trusted code" (an external method) which is doing a ZCatalog search:
sRes = targetFolder.Catalog({'PrincipiaSearchSource' : self.REQUEST['searchText']})
But this is causing the following error: ... Module Products.ZCatalog.CatalogBrains, line 86, in getObject
You are using the "getObject" method which performs an internal security check. There is also an internal version (I think, "_getObject") which does not check security and can be used from trusted code. -- Dieter
participants (3)
-
Dieter Maurer -
Jonathan -
Tres Seaver