Show More
@@ -274,11 +274,6 b' def includeme(config):' | |||||
274 | config.add_subscriber(write_metadata_if_needed, ApplicationCreated) |
|
274 | config.add_subscriber(write_metadata_if_needed, ApplicationCreated) | |
275 | config.add_subscriber(write_js_routes_if_enabled, ApplicationCreated) |
|
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 | # request custom methods |
|
278 | # request custom methods | |
284 | config.add_request_method( |
|
279 | config.add_request_method( | |
@@ -316,14 +311,15 b' def wrap_app_in_wsgi_middlewares(pyramid' | |||||
316 | """ |
|
311 | """ | |
317 | Apply outer WSGI middlewares around the application. |
|
312 | Apply outer WSGI middlewares around the application. | |
318 | """ |
|
313 | """ | |
319 |
|
|
314 | registry = config.registry | |
|
315 | settings = registry.settings | |||
320 |
|
316 | |||
321 | # enable https redirects based on HTTP_X_URL_SCHEME set by proxy |
|
317 | # enable https redirects based on HTTP_X_URL_SCHEME set by proxy | |
322 | pyramid_app = HttpsFixup(pyramid_app, settings) |
|
318 | pyramid_app = HttpsFixup(pyramid_app, settings) | |
323 |
|
319 | |||
324 | pyramid_app, _ae_client = wrap_in_appenlight_if_enabled( |
|
320 | pyramid_app, _ae_client = wrap_in_appenlight_if_enabled( | |
325 | pyramid_app, settings) |
|
321 | pyramid_app, settings) | |
326 |
|
|
322 | registry.ae_client = _ae_client | |
327 |
|
323 | |||
328 | if settings['gzip_responses']: |
|
324 | if settings['gzip_responses']: | |
329 | pyramid_app = make_gzip_middleware( |
|
325 | pyramid_app = make_gzip_middleware( |
@@ -18,7 +18,7 b'' | |||||
18 |
|
18 | |||
19 | import logging |
|
19 | import logging | |
20 | from pyramid.threadlocal import get_current_registry |
|
20 | from pyramid.threadlocal import get_current_registry | |
21 |
from rhodecode.events.base import Rhode |
|
21 | from rhodecode.events.base import RhodeCodeIntegrationEvent | |
22 |
|
22 | |||
23 |
|
23 | |||
24 | log = logging.getLogger(__name__) |
|
24 | log = logging.getLogger(__name__) | |
@@ -36,17 +36,9 b' def trigger(event, registry=None):' | |||||
36 | registry.notify(event) |
|
36 | registry.notify(event) | |
37 | log.debug('event %s triggered using registry %s', event.__class__, registry) |
|
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 |
|
39 | # Send the events to integrations directly | |
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 |
|
||||
48 | from rhodecode.integrations import integrations_event_handler |
|
40 | from rhodecode.integrations import integrations_event_handler | |
49 |
if isinstance(event, Rhode |
|
41 | if isinstance(event, RhodeCodeIntegrationEvent): | |
50 | integrations_event_handler(event) |
|
42 | integrations_event_handler(event) | |
51 |
|
43 | |||
52 |
|
44 |
@@ -110,3 +110,9 b' class RhodecodeEvent(object):' | |||||
110 | 'server_url': self.server_url |
|
110 | 'server_url': self.server_url | |
111 | } |
|
111 | } | |
112 | return data |
|
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 | from rhodecode.translation import lazy_ugettext |
|
23 | from rhodecode.translation import lazy_ugettext | |
24 | from rhodecode.model.db import User, Repository, Session |
|
24 | from rhodecode.model.db import User, Repository, Session | |
25 |
from rhodecode.events.base import Rhode |
|
25 | from rhodecode.events.base import RhodeCodeIntegrationEvent | |
26 | from rhodecode.lib.vcs.exceptions import CommitDoesNotExistError |
|
26 | from rhodecode.lib.vcs.exceptions import CommitDoesNotExistError | |
27 |
|
27 | |||
28 | log = logging.getLogger(__name__) |
|
28 | log = logging.getLogger(__name__) | |
@@ -147,7 +147,7 b' def _issues_as_dict(commits):' | |||||
147 | return issues |
|
147 | return issues | |
148 |
|
148 | |||
149 |
|
149 | |||
150 |
class RepoEvent(Rhode |
|
150 | class RepoEvent(RhodeCodeIntegrationEvent): | |
151 | """ |
|
151 | """ | |
152 | Base class for events acting on a repository. |
|
152 | Base class for events acting on a repository. | |
153 |
|
153 |
@@ -19,13 +19,13 b'' | |||||
19 | import logging |
|
19 | import logging | |
20 |
|
20 | |||
21 | from rhodecode.translation import lazy_ugettext |
|
21 | from rhodecode.translation import lazy_ugettext | |
22 |
from rhodecode.events.base import Rhode |
|
22 | from rhodecode.events.base import RhodeCodeIntegrationEvent | |
23 |
|
23 | |||
24 |
|
24 | |||
25 | log = logging.getLogger(__name__) |
|
25 | log = logging.getLogger(__name__) | |
26 |
|
26 | |||
27 |
|
27 | |||
28 |
class RepoGroupEvent(Rhode |
|
28 | class RepoGroupEvent(RhodeCodeIntegrationEvent): | |
29 | """ |
|
29 | """ | |
30 | Base class for events acting on a repository group. |
|
30 | Base class for events acting on a repository group. | |
31 |
|
31 |
@@ -20,7 +20,7 b' import logging' | |||||
20 | from zope.interface import implementer |
|
20 | from zope.interface import implementer | |
21 |
|
21 | |||
22 | from rhodecode.translation import lazy_ugettext |
|
22 | from rhodecode.translation import lazy_ugettext | |
23 | from rhodecode.events.base import RhodecodeEvent |
|
23 | from rhodecode.events.base import RhodecodeEvent, RhodeCodeIntegrationEvent | |
24 | from rhodecode.events.interfaces import ( |
|
24 | from rhodecode.events.interfaces import ( | |
25 | IUserRegistered, IUserPreCreate, IUserPreUpdate) |
|
25 | IUserRegistered, IUserPreCreate, IUserPreUpdate) | |
26 |
|
26 | |||
@@ -28,7 +28,7 b' log = logging.getLogger(__name__)' | |||||
28 |
|
28 | |||
29 |
|
29 | |||
30 | @implementer(IUserRegistered) |
|
30 | @implementer(IUserRegistered) | |
31 |
class UserRegistered(Rhode |
|
31 | class UserRegistered(RhodeCodeIntegrationEvent): | |
32 | """ |
|
32 | """ | |
33 | An instance of this class is emitted as an :term:`event` whenever a user |
|
33 | An instance of this class is emitted as an :term:`event` whenever a user | |
34 | account is registered. |
|
34 | account is registered. | |
@@ -43,7 +43,7 b' class UserRegistered(RhodecodeEvent):' | |||||
43 |
|
43 | |||
44 |
|
44 | |||
45 | @implementer(IUserPreCreate) |
|
45 | @implementer(IUserPreCreate) | |
46 |
class UserPreCreate(Rhode |
|
46 | class UserPreCreate(RhodeCodeIntegrationEvent): | |
47 | """ |
|
47 | """ | |
48 | An instance of this class is emitted as an :term:`event` before a new user |
|
48 | An instance of this class is emitted as an :term:`event` before a new user | |
49 | object is created. |
|
49 | object is created. | |
@@ -57,7 +57,7 b' class UserPreCreate(RhodecodeEvent):' | |||||
57 |
|
57 | |||
58 |
|
58 | |||
59 | @implementer(IUserPreCreate) |
|
59 | @implementer(IUserPreCreate) | |
60 |
class UserPostCreate(Rhode |
|
60 | class UserPostCreate(RhodeCodeIntegrationEvent): | |
61 | """ |
|
61 | """ | |
62 | An instance of this class is emitted as an :term:`event` after a new user |
|
62 | An instance of this class is emitted as an :term:`event` after a new user | |
63 | object is created. |
|
63 | object is created. | |
@@ -71,7 +71,7 b' class UserPostCreate(RhodecodeEvent):' | |||||
71 |
|
71 | |||
72 |
|
72 | |||
73 | @implementer(IUserPreUpdate) |
|
73 | @implementer(IUserPreUpdate) | |
74 |
class UserPreUpdate(Rhode |
|
74 | class UserPreUpdate(RhodeCodeIntegrationEvent): | |
75 | """ |
|
75 | """ | |
76 | An instance of this class is emitted as an :term:`event` before a user |
|
76 | An instance of this class is emitted as an :term:`event` before a user | |
77 | object is updated. |
|
77 | object is updated. |
General Comments 0
You need to be logged in to leave comments.
Login now