diff --git a/rhodecode/events.py b/rhodecode/events.py --- a/rhodecode/events.py +++ b/rhodecode/events.py @@ -17,7 +17,8 @@ # and proprietary license terms, please see https://rhodecode.com/licenses/ from zope.interface import implementer -from rhodecode.interfaces import IUserRegistered +from rhodecode.interfaces import ( + IUserRegistered, IUserPreCreate, IUserPreUpdate) @implementer(IUserRegistered) @@ -29,3 +30,24 @@ class UserRegistered(object): def __init__(self, user, session): self.user = user self.session = session + + +@implementer(IUserPreCreate) +class UserPreCreate(object): + """ + An instance of this class is emitted as an :term:`event` before a new user + object is created. + """ + def __init__(self, active): + self.active = active + + +@implementer(IUserPreUpdate) +class UserPreUpdate(object): + """ + An instance of this class is emitted as an :term:`event` before a user + object is updated. + """ + def __init__(self, user, active): + self.user = user + self.active = active diff --git a/rhodecode/interfaces.py b/rhodecode/interfaces.py --- a/rhodecode/interfaces.py +++ b/rhodecode/interfaces.py @@ -26,3 +26,18 @@ class IUserRegistered(Interface): """ user = Attribute('The user object.') session = Attribute('The session while processing the register form post.') + + +class IUserPreCreate(Interface): + """ + An event type that is emitted before a new user object is persisted. + """ + active = Attribute('Value for user.active') + + +class IUserPreUpdate(Interface): + """ + An event type that is emitted before a user object is updated. + """ + user = Attribute('The not yet updated user object') + active = Attribute('New value for user.active')