##// END OF EJS Templates
events: use a distinction between RhodeCodeEvent which is a base class and it used by all events, and...
marcink -
r2921:042146f6 default
parent child Browse files
Show More
@@ -274,11 +274,6 b' def includeme(config):'
274 274 config.add_subscriber(write_metadata_if_needed, ApplicationCreated)
275 275 config.add_subscriber(write_js_routes_if_enabled, ApplicationCreated)
276 276
277 # events
278 # TODO(marcink): this should be done when pyramid migration is finished
279 # config.add_subscriber(
280 # 'rhodecode.integrations.integrations_event_handler',
281 # 'rhodecode.events.RhodecodeEvent')
282 277
283 278 # request custom methods
284 279 config.add_request_method(
@@ -316,14 +311,15 b' def wrap_app_in_wsgi_middlewares(pyramid'
316 311 """
317 312 Apply outer WSGI middlewares around the application.
318 313 """
319 settings = config.registry.settings
314 registry = config.registry
315 settings = registry.settings
320 316
321 317 # enable https redirects based on HTTP_X_URL_SCHEME set by proxy
322 318 pyramid_app = HttpsFixup(pyramid_app, settings)
323 319
324 320 pyramid_app, _ae_client = wrap_in_appenlight_if_enabled(
325 321 pyramid_app, settings)
326 config.registry.ae_client = _ae_client
322 registry.ae_client = _ae_client
327 323
328 324 if settings['gzip_responses']:
329 325 pyramid_app = make_gzip_middleware(
@@ -18,7 +18,7 b''
18 18
19 19 import logging
20 20 from pyramid.threadlocal import get_current_registry
21 from rhodecode.events.base import RhodecodeEvent
21 from rhodecode.events.base import RhodeCodeIntegrationEvent
22 22
23 23
24 24 log = logging.getLogger(__name__)
@@ -36,17 +36,9 b' def trigger(event, registry=None):'
36 36 registry.notify(event)
37 37 log.debug('event %s triggered using registry %s', event.__class__, registry)
38 38
39 # Until we can work around the problem that VCS operations do not have a
40 # pyramid context to work with, we send the events to integrations directly
41
42 # Later it will be possible to use regular pyramid subscribers ie:
43 # config.add_subscriber(
44 # 'rhodecode.integrations.integrations_event_handler',
45 # 'rhodecode.events.RhodecodeEvent')
46 # trigger(event, request.registry)
47
39 # Send the events to integrations directly
48 40 from rhodecode.integrations import integrations_event_handler
49 if isinstance(event, RhodecodeEvent):
41 if isinstance(event, RhodeCodeIntegrationEvent):
50 42 integrations_event_handler(event)
51 43
52 44
@@ -110,3 +110,9 b' class RhodecodeEvent(object):'
110 110 'server_url': self.server_url
111 111 }
112 112 return data
113
114
115 class RhodeCodeIntegrationEvent(RhodecodeEvent):
116 """
117 Special subclass for Integration events
118 """
@@ -22,7 +22,7 b' import datetime'
22 22
23 23 from rhodecode.translation import lazy_ugettext
24 24 from rhodecode.model.db import User, Repository, Session
25 from rhodecode.events.base import RhodecodeEvent
25 from rhodecode.events.base import RhodeCodeIntegrationEvent
26 26 from rhodecode.lib.vcs.exceptions import CommitDoesNotExistError
27 27
28 28 log = logging.getLogger(__name__)
@@ -147,7 +147,7 b' def _issues_as_dict(commits):'
147 147 return issues
148 148
149 149
150 class RepoEvent(RhodecodeEvent):
150 class RepoEvent(RhodeCodeIntegrationEvent):
151 151 """
152 152 Base class for events acting on a repository.
153 153
@@ -19,13 +19,13 b''
19 19 import logging
20 20
21 21 from rhodecode.translation import lazy_ugettext
22 from rhodecode.events.base import RhodecodeEvent
22 from rhodecode.events.base import RhodeCodeIntegrationEvent
23 23
24 24
25 25 log = logging.getLogger(__name__)
26 26
27 27
28 class RepoGroupEvent(RhodecodeEvent):
28 class RepoGroupEvent(RhodeCodeIntegrationEvent):
29 29 """
30 30 Base class for events acting on a repository group.
31 31
@@ -20,7 +20,7 b' import logging'
20 20 from zope.interface import implementer
21 21
22 22 from rhodecode.translation import lazy_ugettext
23 from rhodecode.events.base import RhodecodeEvent
23 from rhodecode.events.base import RhodecodeEvent, RhodeCodeIntegrationEvent
24 24 from rhodecode.events.interfaces import (
25 25 IUserRegistered, IUserPreCreate, IUserPreUpdate)
26 26
@@ -28,7 +28,7 b' log = logging.getLogger(__name__)'
28 28
29 29
30 30 @implementer(IUserRegistered)
31 class UserRegistered(RhodecodeEvent):
31 class UserRegistered(RhodeCodeIntegrationEvent):
32 32 """
33 33 An instance of this class is emitted as an :term:`event` whenever a user
34 34 account is registered.
@@ -43,7 +43,7 b' class UserRegistered(RhodecodeEvent):'
43 43
44 44
45 45 @implementer(IUserPreCreate)
46 class UserPreCreate(RhodecodeEvent):
46 class UserPreCreate(RhodeCodeIntegrationEvent):
47 47 """
48 48 An instance of this class is emitted as an :term:`event` before a new user
49 49 object is created.
@@ -57,7 +57,7 b' class UserPreCreate(RhodecodeEvent):'
57 57
58 58
59 59 @implementer(IUserPreCreate)
60 class UserPostCreate(RhodecodeEvent):
60 class UserPostCreate(RhodeCodeIntegrationEvent):
61 61 """
62 62 An instance of this class is emitted as an :term:`event` after a new user
63 63 object is created.
@@ -71,7 +71,7 b' class UserPostCreate(RhodecodeEvent):'
71 71
72 72
73 73 @implementer(IUserPreUpdate)
74 class UserPreUpdate(RhodecodeEvent):
74 class UserPreUpdate(RhodeCodeIntegrationEvent):
75 75 """
76 76 An instance of this class is emitted as an :term:`event` before a user
77 77 object is updated.
General Comments 0
You need to be logged in to leave comments. Login now