##// END OF EJS Templates
events: Add events for repository groups....
Martin Bornhold -
r556:58b83ce1 default
parent child Browse files
Show More
@@ -0,0 +1,77 b''
1 # Copyright (C) 2016-2016 RhodeCode GmbH
2 #
3 # This program is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU Affero General Public License, version 3
5 # (only), as published by the Free Software Foundation.
6 #
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
11 #
12 # You should have received a copy of the GNU Affero General Public License
13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 #
15 # This program is dual-licensed. If you wish to learn more about the
16 # RhodeCode Enterprise Edition, including its added features, Support services,
17 # and proprietary license terms, please see https://rhodecode.com/licenses/
18
19 import logging
20
21 from rhodecode.translation import lazy_ugettext
22 from rhodecode.events.base import RhodecodeEvent
23
24 log = logging.getLogger()
25
26
27 class RepoGroupEvent(RhodecodeEvent):
28 """
29 Base class for events acting on a repository group.
30
31 :param repo: a :class:`RepositoryGroup` instance
32 """
33
34 def __init__(self, repo_group):
35 super(RepoGroupEvent, self).__init__()
36 self.repo_group = repo_group
37
38 # TODO: Implement this
39 # def as_dict(self):
40 # from rhodecode.model.repo import RepoModel
41 # data = super(RepoGroupEvent, self).as_dict()
42 # data.update({
43 # 'repo': {
44 # 'repo_id': self.repo.repo_id,
45 # 'repo_name': self.repo.repo_name,
46 # 'repo_type': self.repo.repo_type,
47 # 'url': RepoModel().get_url(self.repo)
48 # }
49 # })
50 # return data
51
52
53 class RepoGroupCreateEvent(RepoGroupEvent):
54 """
55 An instance of this class is emitted as an :term:`event` whenever a
56 repository group is created.
57 """
58 name = 'repo-group-create'
59 display_name = lazy_ugettext('repository group created')
60
61
62 class RepoGroupDeleteEvent(RepoGroupEvent):
63 """
64 An instance of this class is emitted as an :term:`event` whenever a
65 repository group is deleted.
66 """
67 name = 'repo-group-delete'
68 display_name = lazy_ugettext('repository group deleted')
69
70
71 class RepoGroupUpdateEvent(RepoGroupEvent):
72 """
73 An instance of this class is emitted as an :term:`event` whenever a
74 repository group is updated.
75 """
76 name = 'repo-group-update'
77 display_name = lazy_ugettext('repository group update')
@@ -1,71 +1,78 b''
1 1 # Copyright (C) 2016-2016 RhodeCode GmbH
2 2 #
3 3 # This program is free software: you can redistribute it and/or modify
4 4 # it under the terms of the GNU Affero General Public License, version 3
5 5 # (only), as published by the Free Software Foundation.
6 6 #
7 7 # This program is distributed in the hope that it will be useful,
8 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 10 # GNU General Public License for more details.
11 11 #
12 12 # You should have received a copy of the GNU Affero General Public License
13 13 # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 14 #
15 15 # This program is dual-licensed. If you wish to learn more about the
16 16 # RhodeCode Enterprise Edition, including its added features, Support services,
17 17 # and proprietary license terms, please see https://rhodecode.com/licenses/
18 18
19 19 import logging
20 20 from pyramid.threadlocal import get_current_registry
21 21
22 22 log = logging.getLogger(__name__)
23 23
24 24
25 25 def trigger(event, registry=None):
26 26 """
27 27 Helper method to send an event. This wraps the pyramid logic to send an
28 28 event.
29 29 """
30 30 # For the first step we are using pyramids thread locals here. If the
31 31 # event mechanism works out as a good solution we should think about
32 32 # passing the registry as an argument to get rid of it.
33 33 registry = registry or get_current_registry()
34 34 registry.notify(event)
35 35 log.debug('event %s triggered', event)
36 36
37 37 # Until we can work around the problem that VCS operations do not have a
38 38 # pyramid context to work with, we send the events to integrations directly
39 39
40 40 # Later it will be possible to use regular pyramid subscribers ie:
41 41 # config.add_subscriber(integrations_event_handler, RhodecodeEvent)
42 42 from rhodecode.integrations import integrations_event_handler
43 43 if isinstance(event, RhodecodeEvent):
44 44 integrations_event_handler(event)
45 45
46 46
47 47 from rhodecode.events.base import RhodecodeEvent
48 48
49 from rhodecode.events.user import (
49 from rhodecode.events.user import ( # noqa
50 50 UserPreCreate,
51 51 UserPreUpdate,
52 52 UserRegistered
53 53 )
54 54
55 from rhodecode.events.repo import (
55 from rhodecode.events.repo import ( # noqa
56 56 RepoEvent,
57 57 RepoPreCreateEvent, RepoCreateEvent,
58 58 RepoPreDeleteEvent, RepoDeleteEvent,
59 59 RepoPrePushEvent, RepoPushEvent,
60 60 RepoPrePullEvent, RepoPullEvent,
61 61 )
62 62
63 from rhodecode.events.pullrequest import (
63 from rhodecode.events.repo_group import ( # noqa
64 RepoGroupEvent,
65 RepoGroupCreateEvent,
66 RepoGroupUpdateEvent,
67 RepoGroupDeleteEvent,
68 )
69
70 from rhodecode.events.pullrequest import ( # noqa
64 71 PullRequestEvent,
65 72 PullRequestCreateEvent,
66 73 PullRequestUpdateEvent,
67 74 PullRequestCommentEvent,
68 75 PullRequestReviewEvent,
69 76 PullRequestMergeEvent,
70 77 PullRequestCloseEvent,
71 78 )
General Comments 0
You need to be logged in to leave comments. Login now