events: use a distinction between RhodeCodeEvent which is a base class and it used by all events, and
the events that are handled in addition by integration framework.
This commit is contained in:
parent
38cd92a8c0
commit
988ae152de
6 changed files with 21 additions and 27 deletions
|
|
@ -274,11 +274,6 @@ def includeme(config):
|
|||
config.add_subscriber(write_metadata_if_needed, ApplicationCreated)
|
||||
config.add_subscriber(write_js_routes_if_enabled, ApplicationCreated)
|
||||
|
||||
# events
|
||||
# TODO(marcink): this should be done when pyramid migration is finished
|
||||
# config.add_subscriber(
|
||||
# 'rhodecode.integrations.integrations_event_handler',
|
||||
# 'rhodecode.events.RhodecodeEvent')
|
||||
|
||||
# request custom methods
|
||||
config.add_request_method(
|
||||
|
|
@ -316,14 +311,15 @@ def wrap_app_in_wsgi_middlewares(pyramid_app, config):
|
|||
"""
|
||||
Apply outer WSGI middlewares around the application.
|
||||
"""
|
||||
settings = config.registry.settings
|
||||
registry = config.registry
|
||||
settings = registry.settings
|
||||
|
||||
# enable https redirects based on HTTP_X_URL_SCHEME set by proxy
|
||||
pyramid_app = HttpsFixup(pyramid_app, settings)
|
||||
|
||||
pyramid_app, _ae_client = wrap_in_appenlight_if_enabled(
|
||||
pyramid_app, settings)
|
||||
config.registry.ae_client = _ae_client
|
||||
registry.ae_client = _ae_client
|
||||
|
||||
if settings['gzip_responses']:
|
||||
pyramid_app = make_gzip_middleware(
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
import logging
|
||||
from pyramid.threadlocal import get_current_registry
|
||||
from rhodecode.events.base import RhodecodeEvent
|
||||
from rhodecode.events.base import RhodeCodeIntegrationEvent
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
|
@ -36,17 +36,9 @@ def trigger(event, registry=None):
|
|||
registry.notify(event)
|
||||
log.debug('event %s triggered using registry %s', event.__class__, registry)
|
||||
|
||||
# Until we can work around the problem that VCS operations do not have a
|
||||
# pyramid context to work with, we send the events to integrations directly
|
||||
|
||||
# Later it will be possible to use regular pyramid subscribers ie:
|
||||
# config.add_subscriber(
|
||||
# 'rhodecode.integrations.integrations_event_handler',
|
||||
# 'rhodecode.events.RhodecodeEvent')
|
||||
# trigger(event, request.registry)
|
||||
|
||||
# Send the events to integrations directly
|
||||
from rhodecode.integrations import integrations_event_handler
|
||||
if isinstance(event, RhodecodeEvent):
|
||||
if isinstance(event, RhodeCodeIntegrationEvent):
|
||||
integrations_event_handler(event)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -110,3 +110,9 @@ class RhodecodeEvent(object):
|
|||
'server_url': self.server_url
|
||||
}
|
||||
return data
|
||||
|
||||
|
||||
class RhodeCodeIntegrationEvent(RhodecodeEvent):
|
||||
"""
|
||||
Special subclass for Integration events
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import datetime
|
|||
|
||||
from rhodecode.translation import lazy_ugettext
|
||||
from rhodecode.model.db import User, Repository, Session
|
||||
from rhodecode.events.base import RhodecodeEvent
|
||||
from rhodecode.events.base import RhodeCodeIntegrationEvent
|
||||
from rhodecode.lib.vcs.exceptions import CommitDoesNotExistError
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
|
@ -147,7 +147,7 @@ def _issues_as_dict(commits):
|
|||
return issues
|
||||
|
||||
|
||||
class RepoEvent(RhodecodeEvent):
|
||||
class RepoEvent(RhodeCodeIntegrationEvent):
|
||||
"""
|
||||
Base class for events acting on a repository.
|
||||
|
||||
|
|
|
|||
|
|
@ -19,13 +19,13 @@
|
|||
import logging
|
||||
|
||||
from rhodecode.translation import lazy_ugettext
|
||||
from rhodecode.events.base import RhodecodeEvent
|
||||
from rhodecode.events.base import RhodeCodeIntegrationEvent
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class RepoGroupEvent(RhodecodeEvent):
|
||||
class RepoGroupEvent(RhodeCodeIntegrationEvent):
|
||||
"""
|
||||
Base class for events acting on a repository group.
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import logging
|
|||
from zope.interface import implementer
|
||||
|
||||
from rhodecode.translation import lazy_ugettext
|
||||
from rhodecode.events.base import RhodecodeEvent
|
||||
from rhodecode.events.base import RhodecodeEvent, RhodeCodeIntegrationEvent
|
||||
from rhodecode.events.interfaces import (
|
||||
IUserRegistered, IUserPreCreate, IUserPreUpdate)
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ log = logging.getLogger(__name__)
|
|||
|
||||
|
||||
@implementer(IUserRegistered)
|
||||
class UserRegistered(RhodecodeEvent):
|
||||
class UserRegistered(RhodeCodeIntegrationEvent):
|
||||
"""
|
||||
An instance of this class is emitted as an :term:`event` whenever a user
|
||||
account is registered.
|
||||
|
|
@ -43,7 +43,7 @@ class UserRegistered(RhodecodeEvent):
|
|||
|
||||
|
||||
@implementer(IUserPreCreate)
|
||||
class UserPreCreate(RhodecodeEvent):
|
||||
class UserPreCreate(RhodeCodeIntegrationEvent):
|
||||
"""
|
||||
An instance of this class is emitted as an :term:`event` before a new user
|
||||
object is created.
|
||||
|
|
@ -57,7 +57,7 @@ class UserPreCreate(RhodecodeEvent):
|
|||
|
||||
|
||||
@implementer(IUserPreCreate)
|
||||
class UserPostCreate(RhodecodeEvent):
|
||||
class UserPostCreate(RhodeCodeIntegrationEvent):
|
||||
"""
|
||||
An instance of this class is emitted as an :term:`event` after a new user
|
||||
object is created.
|
||||
|
|
@ -71,7 +71,7 @@ class UserPostCreate(RhodecodeEvent):
|
|||
|
||||
|
||||
@implementer(IUserPreUpdate)
|
||||
class UserPreUpdate(RhodecodeEvent):
|
||||
class UserPreUpdate(RhodeCodeIntegrationEvent):
|
||||
"""
|
||||
An instance of this class is emitted as an :term:`event` before a user
|
||||
object is updated.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue