-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checkPermission: align behavior with objects raising in __getattr__
The observed problem was a behavior different between C and python implementation on python 3, happening with Zope python script. When the context can not be accessed by the current user, Zope binds a `Shared.DC.Scripts.Bindings.UnauthorizedBinding`, a class that raises an Unauthorized error when the context is actually accessed, in order to postpone the Unauthorized if something is actually accessed. This class does implements this by raising Unauthorized in __getattr__. The python implementation of `checkPermission` uses `hasattr` and `hasattr` has changed between python2 and python3, on python2 it was ignoring all exceptions, including potential Unauthorized errors and just returning False, but on python3 these errors are raised. This change of behavior of python causes checkPermission to behave differently: when using python implementation on python2 or when using C implementation, such Unauthorized errors were gracefully handled and caused checkPermission to return False, but on python3 checkPermission raises. This change make this scenario behave the same between python2, python3 and C implementation: Unauthorized errors raised in __getattr__ are supported. The code is also micro-simplified by doing only one getattr instead of hasattr and then getattr.
- Loading branch information
1 parent
4779653
commit 27d88c4
Showing
4 changed files
with
28 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters