##// END OF EJS Templates
events: make the System URL extraction safer....
marcink -
r1424:5c92e9f4 default
parent child Browse files
Show More
@@ -15,6 +15,7 b''
15 # This program is dual-licensed. If you wish to learn more about the
15 # This program is dual-licensed. If you wish to learn more about the
16 # RhodeCode Enterprise Edition, including its added features, Support services,
16 # RhodeCode Enterprise Edition, including its added features, Support services,
17 # and proprietary license terms, please see https://rhodecode.com/licenses/
17 # and proprietary license terms, please see https://rhodecode.com/licenses/
18 import logging
18
19
19 from datetime import datetime
20 from datetime import datetime
20 from pyramid.threadlocal import get_current_request
21 from pyramid.threadlocal import get_current_request
@@ -26,6 +27,8 b' SYSTEM_USER = AttributeDict(dict('
26 username='__SYSTEM__'
27 username='__SYSTEM__'
27 ))
28 ))
28
29
30 log = logging.getLogger(__name__)
31
29
32
30 class RhodecodeEvent(object):
33 class RhodecodeEvent(object):
31 """
34 """
@@ -66,10 +69,16 b' class RhodecodeEvent(object):'
66
69
67 @property
70 @property
68 def server_url(self):
71 def server_url(self):
72 default = '<no server_url available>'
69 if self.request:
73 if self.request:
70 from rhodecode.lib import helpers as h
74 from rhodecode.lib import helpers as h
71 return h.url('home', qualified=True)
75 try:
72 return '<no server_url available>'
76 return h.url('home', qualified=True)
77 except Exception:
78 log.exception('Failed to fetch URL for server')
79 return default
80
81 return default
73
82
74 def as_dict(self):
83 def as_dict(self):
75 data = {
84 data = {
@@ -16,11 +16,14 b''
16 # RhodeCode Enterprise Edition, including its added features, Support services,
16 # RhodeCode Enterprise Edition, including its added features, Support services,
17 # and proprietary license terms, please see https://rhodecode.com/licenses/
17 # and proprietary license terms, please see https://rhodecode.com/licenses/
18
18
19 import logging
19
20
20 from rhodecode.translation import lazy_ugettext
21 from rhodecode.translation import lazy_ugettext
21 from rhodecode.events.repo import (
22 from rhodecode.events.repo import (
22 RepoEvent, _commits_as_dict, _issues_as_dict)
23 RepoEvent, _commits_as_dict, _issues_as_dict)
23
24
25 log = logging.getLogger(__name__)
26
24
27
25 class PullRequestEvent(RepoEvent):
28 class PullRequestEvent(RepoEvent):
26 """
29 """
@@ -15,6 +15,7 b''
15 # This program is dual-licensed. If you wish to learn more about the
15 # This program is dual-licensed. If you wish to learn more about the
16 # RhodeCode Enterprise Edition, including its added features, Support services,
16 # RhodeCode Enterprise Edition, including its added features, Support services,
17 # and proprietary license terms, please see https://rhodecode.com/licenses/
17 # and proprietary license terms, please see https://rhodecode.com/licenses/
18 import logging
18
19
19 from zope.interface import implementer
20 from zope.interface import implementer
20
21
@@ -23,6 +24,8 b' from rhodecode.events.base import Rhodec'
23 from rhodecode.events.interfaces import (
24 from rhodecode.events.interfaces import (
24 IUserRegistered, IUserPreCreate, IUserPreUpdate)
25 IUserRegistered, IUserPreCreate, IUserPreUpdate)
25
26
27 log = logging.getLogger(__name__)
28
26
29
27 @implementer(IUserRegistered)
30 @implementer(IUserRegistered)
28 class UserRegistered(RhodecodeEvent):
31 class UserRegistered(RhodecodeEvent):
General Comments 0
You need to be logged in to leave comments. Login now