[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/ Added backward
compatibility for old auth services that raise NotFoundError
Jim Fulton
jim at zope.com
Wed Oct 27 13:05:26 EDT 2004
Log message for revision 28267:
Added backward compatibility for old auth services that raise NotFoundError
Rather than the newer PrincipalLookupError.
Changed:
U Zope3/trunk/src/zope/app/security/principal.py
U Zope3/trunk/src/zope/app/security/vocabulary.py
U Zope3/trunk/src/zope/app/undo/__init__.py
-=-
Modified: Zope3/trunk/src/zope/app/security/principal.py
===================================================================
--- Zope3/trunk/src/zope/app/security/principal.py 2004-10-26 23:07:50 UTC (rev 28266)
+++ Zope3/trunk/src/zope/app/security/principal.py 2004-10-27 17:05:26 UTC (rev 28267)
@@ -19,12 +19,26 @@
from zope.app import zapi
from zope.app.servicenames import Authentication
+# BBB Backward Compatibility
+from zope.exceptions import NotFoundError
+import warnings
+
def checkPrincipal(context, principal_id):
+ auth = zapi.getService(Authentication, context)
try:
- if zapi.getService(Authentication, context).getPrincipal(principal_id):
+ if auth.getPrincipal(principal_id):
return
except PrincipalLookupError:
pass
+ except NotFoundError: # BBB Backward Compatibility
+ warnings.warn(
+ "A %s instance raised a NotFoundError in "
+ "getPrincipals. Raising NotFoundError in this "
+ "method is deprecated and will no-longer be supported "
+ "staring in ZopeX3 3.3. PrincipalLookupError should "
+ "be raised instead."
+ % auth.__class__.__name__,
+ DeprecationWarning)
raise ValueError("Undefined principal id", principal_id)
Modified: Zope3/trunk/src/zope/app/security/vocabulary.py
===================================================================
--- Zope3/trunk/src/zope/app/security/vocabulary.py 2004-10-26 23:07:50 UTC (rev 28266)
+++ Zope3/trunk/src/zope/app/security/vocabulary.py 2004-10-27 17:05:26 UTC (rev 28267)
@@ -26,6 +26,10 @@
from zope.app.security.interfaces import PrincipalLookupError
from zope.app.component.localservice import queryNextService
+# BBB Backward Compatibility
+from zope.exceptions import NotFoundError
+import warnings
+
from interfaces import IPrincipalSource
class PermissionIdsVocabulary(SimpleVocabulary):
@@ -148,6 +152,16 @@
auth.getPrincipal(id)
except PrincipalLookupError:
return False
+ except NotFoundError: # BBB Backward Compatibility
+ warnings.warn(
+ "A %s instance raised a NotFoundError in "
+ "getPrincipals. Raising NotFoundError in this "
+ "method is deprecated and will no-longer be supported "
+ "staring in ZopeX3 3.3. PrincipalLookupError should "
+ "be raised instead."
+ % auth.__class__.__name__,
+ DeprecationWarning)
+ return False
else:
return True
Modified: Zope3/trunk/src/zope/app/undo/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/undo/__init__.py 2004-10-26 23:07:50 UTC (rev 28266)
+++ Zope3/trunk/src/zope/app/undo/__init__.py 2004-10-27 17:05:26 UTC (rev 28267)
@@ -26,6 +26,10 @@
from zope.app.security.principalregistry import principalRegistry
from zope.app.security.interfaces import IPrincipal
+# BBB Backward Compatibility
+from zope.exceptions import NotFoundError
+import warnings
+
def undoSetup(event):
# setup undo functionality
svc = zapi.getGlobalService(Utilities)
@@ -149,6 +153,16 @@
except PrincipalLookupError:
# principals might have passed away
pass
+ except NotFoundError: # BBB Backward Compatibility
+ warnings.warn(
+ "A %s instance raised a NotFoundError in "
+ "getPrincipals. Raising NotFoundError in this "
+ "method is deprecated and will no-longer be supported "
+ "staring in ZopeX3 3.3. PrincipalLookupError should "
+ "be raised instead."
+ % principalRegistry.__class__.__name__,
+ DeprecationWarning)
+
return entries
def undoTransactions(self, ids):
More information about the Zope3-Checkins
mailing list