events: Add events for pre user create and pre user update.

These events are emitted before a user is created or updated.
This commit is contained in:
Johannes Bornhold 2016-05-30 12:14:00 +02:00
parent d36e50102c
commit e6eecebb7f
2 changed files with 38 additions and 1 deletions

View file

@ -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

View file

@ -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')