events: make the System URL extraction safer.
Prevents any possible errors inside events.
This commit is contained in:
parent
886cc7d28b
commit
dc8777ebe2
3 changed files with 17 additions and 2 deletions
|
|
@ -15,6 +15,7 @@
|
||||||
# This program is dual-licensed. If you wish to learn more about the
|
# This program is dual-licensed. If you wish to learn more about the
|
||||||
# RhodeCode Enterprise Edition, including its added features, Support services,
|
# RhodeCode Enterprise Edition, including its added features, Support services,
|
||||||
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
||||||
|
import logging
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pyramid.threadlocal import get_current_request
|
from pyramid.threadlocal import get_current_request
|
||||||
|
|
@ -26,6 +27,8 @@ SYSTEM_USER = AttributeDict(dict(
|
||||||
username='__SYSTEM__'
|
username='__SYSTEM__'
|
||||||
))
|
))
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class RhodecodeEvent(object):
|
class RhodecodeEvent(object):
|
||||||
"""
|
"""
|
||||||
|
|
@ -66,10 +69,16 @@ class RhodecodeEvent(object):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def server_url(self):
|
def server_url(self):
|
||||||
|
default = '<no server_url available>'
|
||||||
if self.request:
|
if self.request:
|
||||||
from rhodecode.lib import helpers as h
|
from rhodecode.lib import helpers as h
|
||||||
return h.url('home', qualified=True)
|
try:
|
||||||
return '<no server_url available>'
|
return h.url('home', qualified=True)
|
||||||
|
except Exception:
|
||||||
|
log.exception('Failed to fetch URL for server')
|
||||||
|
return default
|
||||||
|
|
||||||
|
return default
|
||||||
|
|
||||||
def as_dict(self):
|
def as_dict(self):
|
||||||
data = {
|
data = {
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,14 @@
|
||||||
# RhodeCode Enterprise Edition, including its added features, Support services,
|
# RhodeCode Enterprise Edition, including its added features, Support services,
|
||||||
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
from rhodecode.translation import lazy_ugettext
|
from rhodecode.translation import lazy_ugettext
|
||||||
from rhodecode.events.repo import (
|
from rhodecode.events.repo import (
|
||||||
RepoEvent, _commits_as_dict, _issues_as_dict)
|
RepoEvent, _commits_as_dict, _issues_as_dict)
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class PullRequestEvent(RepoEvent):
|
class PullRequestEvent(RepoEvent):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
# This program is dual-licensed. If you wish to learn more about the
|
# This program is dual-licensed. If you wish to learn more about the
|
||||||
# RhodeCode Enterprise Edition, including its added features, Support services,
|
# RhodeCode Enterprise Edition, including its added features, Support services,
|
||||||
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
||||||
|
import logging
|
||||||
|
|
||||||
from zope.interface import implementer
|
from zope.interface import implementer
|
||||||
|
|
||||||
|
|
@ -23,6 +24,8 @@ from rhodecode.events.base import RhodecodeEvent
|
||||||
from rhodecode.events.interfaces import (
|
from rhodecode.events.interfaces import (
|
||||||
IUserRegistered, IUserPreCreate, IUserPreUpdate)
|
IUserRegistered, IUserPreCreate, IUserPreUpdate)
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@implementer(IUserRegistered)
|
@implementer(IUserRegistered)
|
||||||
class UserRegistered(RhodecodeEvent):
|
class UserRegistered(RhodecodeEvent):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue