Back to index

plone3  3.1.7
events.py
Go to the documentation of this file.
00001 from Acquisition import aq_parent
00002 from zope.component import adapter
00003 from zope.component import subscribers
00004 from zope.interface import implements
00005 from Products.PluggableAuthService.interfaces.events import *
00006 from Products.PluggableAuthService.interfaces.authservice import IBasicUser
00007 
00008 class PASEvent(object):
00009     implements(IPASEvent)
00010 
00011     def __init__(self, principal):
00012         self.principal=principal
00013         self.object=principal
00014 
00015 
00016 class PrincipalCreated(PASEvent):
00017     implements(IPrincipalCreatedEvent)
00018 
00019 
00020 class PrincipalDeleted(PASEvent):
00021     implements(IPrincipalDeletedEvent)
00022 
00023 
00024 class CredentialsUpdated(PASEvent):
00025     implements(ICredentialsUpdatedEvent)
00026 
00027     def __init__(self, principal, password):
00028         super(CredentialsUpdated, self).__init__(principal)
00029         self.password=password
00030 
00031 
00032 class PropertiesUpdated(PASEvent):
00033     implements(IPropertiesUpdatedEvent)
00034 
00035     def __init__(self, principal, properties):
00036         super(CredentialsUpdated, self).__init__(principal)
00037         self.properties=properties
00038 
00039 
00040 @adapter(IBasicUser, ICredentialsUpdatedEvent)
00041 def userCredentialsUpdatedHandler(principal, event):
00042     pas = aq_parent(principal)
00043     pas.updateCredentials(
00044             pas,
00045             pas.REQUEST,
00046             pas.REQUEST.RESPONSE,
00047             principal.getId(),
00048             event.password)
00049 
00050 
00051 @adapter(IPASEvent)
00052 def PASEventNotify(event):
00053     """Event subscriber to dispatch PASEvent to interested adapters."""
00054     adapters = subscribers((event.principal, event), None)
00055     for adapter in adapters:
00056         pass # getting them does the work
00057