[Checkins] SVN: PluggableAuthService/branches/z3-events/ We can get
to the user folder for a principal through aq_parent,
so use that and remove the acl_users attribute from our events
Wichert Akkerman
wichert at wiggy.net
Sun Jun 10 18:20:14 EDT 2007
Log message for revision 76605:
We can get to the user folder for a principal through aq_parent, so use that and remove the acl_users attribute from our events
Changed:
U PluggableAuthService/branches/z3-events/PluggableAuthService.py
U PluggableAuthService/branches/z3-events/events.py
U PluggableAuthService/branches/z3-events/tests/test_UserFolder.py
-=-
Modified: PluggableAuthService/branches/z3-events/PluggableAuthService.py
===================================================================
--- PluggableAuthService/branches/z3-events/PluggableAuthService.py 2007-06-10 22:11:43 UTC (rev 76604)
+++ PluggableAuthService/branches/z3-events/PluggableAuthService.py 2007-06-10 22:20:14 UTC (rev 76605)
@@ -957,7 +957,7 @@
pass
if user is not None:
- event.notify(PrincipalCreated(self, user))
+ event.notify(PrincipalCreated(user))
security.declarePublic('all_meta_types')
Modified: PluggableAuthService/branches/z3-events/events.py
===================================================================
--- PluggableAuthService/branches/z3-events/events.py 2007-06-10 22:11:43 UTC (rev 76604)
+++ PluggableAuthService/branches/z3-events/events.py 2007-06-10 22:20:14 UTC (rev 76605)
@@ -1,3 +1,4 @@
+from Acquisition import aq_parent
from zope.component import adapter
from zope.component import subscribers
from zope.interface import implements
@@ -6,8 +7,7 @@
class PASEvent(object):
implements(IPASEvent)
- def __init__(self, acl_users, principal):
- self.acl_users=acl_users
+ def __init__(self, principal):
self.principal=principal
self.object=principal
@@ -23,24 +23,25 @@
class CredentialsUpdated(PASEvent):
implements(ICredentialsUpdatedEvent)
- def __init__(self, acl_users, principal, password):
- super(CredentialsUpdated, self).__init__(acl_users, principal)
+ def __init__(self, principal, password):
+ super(CredentialsUpdated, self).__init__(principal)
self.password=password
class PropertiesUpdated(PASEvent):
implements(IPropertiesUpdatedEvent)
- def __init__(self, acl_users, principal, properties):
- super(CredentialsUpdated, self).__init__(acl_users, principal)
+ def __init__(self, principal, properties):
+ super(CredentialsUpdated, self).__init__(principal)
self.properties=properties
def userCredentialsUpdatedHandler(principal, event):
- event.acl_users.updateCredentials(
- event.acl_users,
- event.acl_users.REQUEST,
- event.acl_users.REQUEST.RESPONSE,
+ pas = aq_parent(principal)
+ pas.updateCredentials(
+ pas,
+ pas.REQUEST,
+ pas.REQUEST.RESPONSE,
principal.getId(),
event.password)
Modified: PluggableAuthService/branches/z3-events/tests/test_UserFolder.py
===================================================================
--- PluggableAuthService/branches/z3-events/tests/test_UserFolder.py 2007-06-10 22:11:43 UTC (rev 76604)
+++ PluggableAuthService/branches/z3-events/tests/test_UserFolder.py 2007-06-10 22:20:14 UTC (rev 76605)
@@ -31,10 +31,11 @@
@adapter(IPrincipalCreatedEvent)
def userCreatedHandler(event):
- if not hasattr(event.acl_users, 'events'):
- event.acl_users.events= []
+ pas = event.principal.aq_parent
+ if not hasattr(pas, 'events'):
+ pas.events = []
- event.acl_users.events.append(event)
+ pas.events.append(event)
class UserFolderTests(pastc.PASTestCase):
@@ -318,8 +319,7 @@
self.uf._data=[]
self.uf._original=self.uf.updateCredentials
self.uf.updateCredentials=wrap
- event.notify(CredentialsUpdated(self.uf,
- self.uf.getUserById("user1"), "testpassword"))
+ event.notify(CredentialsUpdated(self.uf.getUserById("user1"), "testpassword"))
self.assertEqual(len(self.uf._data), 1)
self.assertEqual(self.uf._data[0][2], "user1")
self.assertEqual(self.uf._data[0][3], "testpassword")
More information about the Checkins
mailing list