changeset 4445:f9bc28c44f30

urls: introduce canonical_url config setting All URLs that are shown or persisted or emailed will use this instead of the current url. This is convenient when the server has multiple names - for instance when transitioning from one protocol or domain or hostname to another.
author Mads Kiilerich <madski@unity3d.com>
date Tue, 12 Aug 2014 13:08:23 +0200
parents 52e8c4da4768
children 5e7c69707f08
files kallithea/controllers/feed.py kallithea/controllers/journal.py kallithea/controllers/pullrequests.py kallithea/lib/dbmigrate/schema/db_1_5_2.py kallithea/lib/dbmigrate/schema/db_1_6_0.py kallithea/lib/dbmigrate/schema/db_1_7_0.py kallithea/lib/dbmigrate/schema/db_1_8_0.py kallithea/lib/dbmigrate/schema/db_2_0_0.py kallithea/lib/dbmigrate/schema/db_2_0_1.py kallithea/lib/dbmigrate/schema/db_2_0_2.py kallithea/lib/dbmigrate/schema/db_2_1_0.py kallithea/lib/dbmigrate/schema/db_2_2_0.py kallithea/lib/dbmigrate/schema/db_2_2_3.py kallithea/lib/helpers.py kallithea/model/comment.py kallithea/model/db.py kallithea/model/pull_request.py kallithea/model/user.py kallithea/templates/base/base.html
diffstat 19 files changed, 99 insertions(+), 101 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/feed.py	Tue Aug 12 13:08:23 2014 +0200
+++ b/kallithea/controllers/feed.py	Tue Aug 12 13:08:23 2014 +0200
@@ -28,7 +28,7 @@
 
 import logging
 
-from pylons import url, response, tmpl_context as c
+from pylons import response, tmpl_context as c
 from pylons.i18n.translation import _
 
 from beaker.cache import cache_region, region_invalidate
@@ -102,8 +102,8 @@
             desc_msg.append('tag: %s<br/>' % tag)
         diff_processor, changes = self.__changes(cs)
         # rev link
-        _url = url('changeset_home', repo_name=c.db_repo.repo_name,
-                   revision=cs.raw_id, qualified=True)
+        _url = h.canonical_url('changeset_home', repo_name=c.db_repo.repo_name,
+                   revision=cs.raw_id)
         desc_msg.append('changeset: <a href="%s">%s</a>' % (_url, cs.raw_id[:8]))
 
         desc_msg.append('<pre>')
@@ -123,8 +123,7 @@
         def _get_feed_from_cache(key, kind):
             feed = Atom1Feed(
                  title=self.title % repo_name,
-                 link=url('summary_home', repo_name=repo_name,
-                          qualified=True),
+                 link=h.canonical_url('summary_home', repo_name=repo_name),
                  description=self.description % repo_name,
                  language=self.language,
                  ttl=self.ttl
@@ -132,8 +131,8 @@
 
             for cs in reversed(list(c.db_repo_scm_instance[-self.feed_nr:])):
                 feed.add_item(title=self._get_title(cs),
-                              link=url('changeset_home', repo_name=repo_name,
-                                       revision=cs.raw_id, qualified=True),
+                              link=h.canonical_url('changeset_home', repo_name=repo_name,
+                                       revision=cs.raw_id),
                               author_name=cs.author,
                               description=''.join(self.__get_desc(cs)),
                               pubdate=cs.date,
@@ -155,8 +154,7 @@
         def _get_feed_from_cache(key, kind):
             feed = Rss201rev2Feed(
                 title=self.title % repo_name,
-                link=url('summary_home', repo_name=repo_name,
-                         qualified=True),
+                link=h.canonical_url('summary_home', repo_name=repo_name),
                 description=self.description % repo_name,
                 language=self.language,
                 ttl=self.ttl
@@ -164,8 +162,8 @@
 
             for cs in reversed(list(c.db_repo_scm_instance[-self.feed_nr:])):
                 feed.add_item(title=self._get_title(cs),
-                              link=url('changeset_home', repo_name=repo_name,
-                                       revision=cs.raw_id, qualified=True),
+                              link=h.canonical_url('changeset_home', repo_name=repo_name,
+                                       revision=cs.raw_id),
                               author_name=cs.author,
                               description=''.join(self.__get_desc(cs)),
                               pubdate=cs.date,
--- a/kallithea/controllers/journal.py	Tue Aug 12 13:08:23 2014 +0200
+++ b/kallithea/controllers/journal.py	Tue Aug 12 13:08:23 2014 +0200
@@ -110,11 +110,11 @@
     def _atom_feed(self, repos, public=True):
         journal = self._get_journal_data(repos)
         if public:
-            _link = url('public_journal_atom', qualified=True)
+            _link = h.canonical_url('public_journal_atom')
             _desc = '%s %s %s' % (c.site_name, _('public journal'),
                                   'atom feed')
         else:
-            _link = url('journal_atom', qualified=True)
+            _link = h.canonical_url('journal_atom')
             _desc = '%s %s %s' % (c.site_name, _('journal'), 'atom feed')
 
         feed = Atom1Feed(title=_desc,
@@ -136,13 +136,12 @@
             desc = action_extra()
             _url = None
             if entry.repository is not None:
-                _url = url('changelog_home',
-                           repo_name=entry.repository.repo_name,
-                           qualified=True)
+                _url = h.canonical_url('changelog_home',
+                           repo_name=entry.repository.repo_name)
 
             feed.add_item(title=title,
                           pubdate=entry.action_date,
-                          link=_url or url('', qualified=True),
+                          link=_url or h.canonical_url(''),
                           author_email=user.email,
                           author_name=user.full_contact,
                           description=desc)
@@ -153,11 +152,11 @@
     def _rss_feed(self, repos, public=True):
         journal = self._get_journal_data(repos)
         if public:
-            _link = url('public_journal_atom', qualified=True)
+            _link = h.canonical_url('public_journal_atom')
             _desc = '%s %s %s' % (c.site_name, _('public journal'),
                                   'rss feed')
         else:
-            _link = url('journal_atom', qualified=True)
+            _link = h.canonical_url('journal_atom')
             _desc = '%s %s %s' % (c.site_name, _('journal'), 'rss feed')
 
         feed = Rss201rev2Feed(title=_desc,
@@ -179,13 +178,12 @@
             desc = action_extra()
             _url = None
             if entry.repository is not None:
-                _url = url('changelog_home',
-                           repo_name=entry.repository.repo_name,
-                           qualified=True)
+                _url = h.canonical_url('changelog_home',
+                           repo_name=entry.repository.repo_name)
 
             feed.add_item(title=title,
                           pubdate=entry.action_date,
-                          link=_url or url('', qualified=True),
+                          link=_url or h.canonical_url(''),
                           author_email=user.email,
                           author_name=user.full_contact,
                           description=desc)
--- a/kallithea/controllers/pullrequests.py	Tue Aug 12 13:08:23 2014 +0200
+++ b/kallithea/controllers/pullrequests.py	Tue Aug 12 13:08:23 2014 +0200
@@ -497,8 +497,8 @@
         lost = old_revisions.difference(revisions)
 
         infos = ['','', 'This is an update of %s "%s".' %
-                 (url('pullrequest_show', repo_name=old_pull_request.other_repo.repo_name,
-                      pull_request_id=pull_request_id, qualified=True),
+                 (h.canonical_url('pullrequest_show', repo_name=old_pull_request.other_repo.repo_name,
+                      pull_request_id=pull_request_id),
                   old_pull_request.title)]
 
         if lost:
@@ -517,11 +517,11 @@
 
             if ancestor_rev == other_rev:
                 infos.append(_("Ancestor didn't change - show diff since previous version: %s .") %
-                             url('compare_url',
+                             h.canonical_url('compare_url',
                                  repo_name=org_repo.repo_name, # other_repo is always same as repo_name
                                  org_ref_type='rev', org_ref_name=h.short_id(org_rev), # use old org_rev as base
                                  other_ref_type='rev', other_ref_name=h.short_id(new_org_rev),
-                                 qualified=True)) # note: linear diff, merge or not doesn't matter
+                                 )) # note: linear diff, merge or not doesn't matter
             else:
                 infos.append(_('This pull request uses another merge ancestor than the previous version and they are not directly comparable.'))
         else:
@@ -559,10 +559,9 @@
                                 pull_request_id=pull_request_id))
 
         ChangesetCommentsModel().create(
-            text=_('Closed, replaced by %s .') % url('pullrequest_show',
+            text=_('Closed, replaced by %s .') % h.canonical_url('pullrequest_show',
                                                    repo_name=old_pull_request.other_repo.repo_name,
-                                                   pull_request_id=pull_request.pull_request_id,
-                                                   qualified=True),
+                                                   pull_request_id=pull_request.pull_request_id),
             repo=old_pull_request.other_repo.repo_id,
             user=c.authuser.user_id,
             pull_request=pull_request_id,
--- a/kallithea/lib/dbmigrate/schema/db_1_5_2.py	Tue Aug 12 13:08:23 2014 +0200
+++ b/kallithea/lib/dbmigrate/schema/db_1_5_2.py	Tue Aug 12 13:08:23 2014 +0200
@@ -936,10 +936,10 @@
         return self.updated_on
 
     def clone_url(self, **override):
-        from pylons import url
+        import kallithea.lib.helpers as h
         from urlparse import urlparse
         import urllib
-        parsed_url = urlparse(url('home', qualified=True))
+        parsed_url = urlparse(h.canonical_url('home'))
         default_clone_uri = '%(scheme)s://%(user)s%(pass)s%(netloc)s%(prefix)s%(path)s'
         decoded_path = safe_unicode(urllib.unquote(parsed_url.path))
         args = {
--- a/kallithea/lib/dbmigrate/schema/db_1_6_0.py	Tue Aug 12 13:08:23 2014 +0200
+++ b/kallithea/lib/dbmigrate/schema/db_1_6_0.py	Tue Aug 12 13:08:23 2014 +0200
@@ -1006,10 +1006,10 @@
         return self.updated_on
 
     def clone_url(self, **override):
-        from pylons import url
+        import kallithea.lib.helpers as h
         from urlparse import urlparse
         import urllib
-        parsed_url = urlparse(url('home', qualified=True))
+        parsed_url = urlparse(h.canonical_url('home'))
         default_clone_uri = '%(scheme)s://%(user)s%(pass)s%(netloc)s%(prefix)s%(path)s'
         decoded_path = safe_unicode(urllib.unquote(parsed_url.path))
         args = {
--- a/kallithea/lib/dbmigrate/schema/db_1_7_0.py	Tue Aug 12 13:08:23 2014 +0200
+++ b/kallithea/lib/dbmigrate/schema/db_1_7_0.py	Tue Aug 12 13:08:23 2014 +0200
@@ -1037,10 +1037,10 @@
         return self.updated_on
 
     def clone_url(self, **override):
-        from pylons import url
+        import kallithea.lib.helpers as h
         from urlparse import urlparse
         import urllib
-        parsed_url = urlparse(url('home', qualified=True))
+        parsed_url = urlparse(h.canonical_url('home'))
         default_clone_uri = '%(scheme)s://%(user)s%(pass)s%(netloc)s%(prefix)s%(path)s'
         decoded_path = safe_unicode(urllib.unquote(parsed_url.path))
         args = {
@@ -2168,8 +2168,8 @@
         if alias_url:
             return alias_url.replace('{gistid}', self.gist_access_id)
 
-        from pylons import url
-        return url('gist', gist_id=self.gist_access_id, qualified=True)
+        import kallithea.lib.helpers as h
+        return h.canonical_url('gist', gist_id=self.gist_access_id)
 
     @classmethod
     def base_path(cls):
--- a/kallithea/lib/dbmigrate/schema/db_1_8_0.py	Tue Aug 12 13:08:23 2014 +0200
+++ b/kallithea/lib/dbmigrate/schema/db_1_8_0.py	Tue Aug 12 13:08:23 2014 +0200
@@ -1067,10 +1067,10 @@
         return self.updated_on
 
     def clone_url(self, **override):
-        from pylons import url
+        import kallithea.lib.helpers as h
         from urlparse import urlparse
         import urllib
-        parsed_url = urlparse(url('home', qualified=True))
+        parsed_url = urlparse(h.canonical_url('home'))
         default_clone_uri = '%(scheme)s://%(user)s%(pass)s%(netloc)s%(prefix)s%(path)s'
         decoded_path = safe_unicode(urllib.unquote(parsed_url.path))
         args = {
@@ -2215,8 +2215,8 @@
         if alias_url:
             return alias_url.replace('{gistid}', self.gist_access_id)
 
-        from pylons import url
-        return url('gist', gist_id=self.gist_access_id, qualified=True)
+        import kallithea.lib.helpers as h
+        return h.canonical_url('gist', gist_id=self.gist_access_id)
 
     @classmethod
     def base_path(cls):
--- a/kallithea/lib/dbmigrate/schema/db_2_0_0.py	Tue Aug 12 13:08:23 2014 +0200
+++ b/kallithea/lib/dbmigrate/schema/db_2_0_0.py	Tue Aug 12 13:08:23 2014 +0200
@@ -1124,10 +1124,10 @@
         return self.updated_on
 
     def clone_url(self, **override):
-        from pylons import url
+        import kallithea.lib.helpers as h
         from urlparse import urlparse
         import urllib
-        parsed_url = urlparse(url('home', qualified=True))
+        parsed_url = urlparse(h.canonical_url('home'))
         default_clone_uri = '%(scheme)s://%(user)s%(pass)s%(netloc)s%(prefix)s%(path)s'
         decoded_path = safe_unicode(urllib.unquote(parsed_url.path))
         args = {
@@ -2275,8 +2275,8 @@
         if alias_url:
             return alias_url.replace('{gistid}', self.gist_access_id)
 
-        from pylons import url
-        return url('gist', gist_id=self.gist_access_id, qualified=True)
+        import kallithea.lib.helpers as h
+        return h.canonical_url('gist', gist_id=self.gist_access_id)
 
     @classmethod
     def base_path(cls):
--- a/kallithea/lib/dbmigrate/schema/db_2_0_1.py	Tue Aug 12 13:08:23 2014 +0200
+++ b/kallithea/lib/dbmigrate/schema/db_2_0_1.py	Tue Aug 12 13:08:23 2014 +0200
@@ -1123,10 +1123,10 @@
         return self.updated_on
 
     def clone_url(self, **override):
-        from pylons import url
+        import kallithea.lib.helpers as h
         from urlparse import urlparse
         import urllib
-        parsed_url = urlparse(url('home', qualified=True))
+        parsed_url = urlparse(h.canonical_url('home'))
         default_clone_uri = '%(scheme)s://%(user)s%(pass)s%(netloc)s%(prefix)s%(path)s'
         decoded_path = safe_unicode(urllib.unquote(parsed_url.path))
         args = {
@@ -2276,8 +2276,8 @@
         if alias_url:
             return alias_url.replace('{gistid}', self.gist_access_id)
 
-        from pylons import url
-        return url('gist', gist_id=self.gist_access_id, qualified=True)
+        import kallithea.lib.helpers as h
+        return h.canonical_url('gist', gist_id=self.gist_access_id)
 
     @classmethod
     def base_path(cls):
--- a/kallithea/lib/dbmigrate/schema/db_2_0_2.py	Tue Aug 12 13:08:23 2014 +0200
+++ b/kallithea/lib/dbmigrate/schema/db_2_0_2.py	Tue Aug 12 13:08:23 2014 +0200
@@ -1140,10 +1140,10 @@
         return self.updated_on
 
     def clone_url(self, **override):
-        from pylons import url
+        import kallithea.lib.helpers as h
         from urlparse import urlparse
         import urllib
-        parsed_url = urlparse(url('home', qualified=True))
+        parsed_url = urlparse(h.canonical_url('home'))
         default_clone_uri = '%(scheme)s://%(user)s%(pass)s%(netloc)s%(prefix)s%(path)s'
         decoded_path = safe_unicode(urllib.unquote(parsed_url.path))
         args = {
@@ -2297,8 +2297,8 @@
         if alias_url:
             return alias_url.replace('{gistid}', self.gist_access_id)
 
-        from pylons import url
-        return url('gist', gist_id=self.gist_access_id, qualified=True)
+        import kallithea.lib.helpers as h
+        return h.canonical_url('gist', gist_id=self.gist_access_id)
 
     @classmethod
     def base_path(cls):
--- a/kallithea/lib/dbmigrate/schema/db_2_1_0.py	Tue Aug 12 13:08:23 2014 +0200
+++ b/kallithea/lib/dbmigrate/schema/db_2_1_0.py	Tue Aug 12 13:08:23 2014 +0200
@@ -1179,10 +1179,10 @@
         return self.updated_on
 
     def clone_url(self, **override):
-        from pylons import url
+        import kallithea.lib.helpers as h
         from urlparse import urlparse
         import urllib
-        parsed_url = urlparse(url('home', qualified=True))
+        parsed_url = urlparse(h.canonical_url('home'))
         default_clone_uri = '%(scheme)s://%(user)s%(pass)s%(netloc)s%(prefix)s%(path)s'
         decoded_path = safe_unicode(urllib.unquote(parsed_url.path))
         args = {
@@ -2336,8 +2336,8 @@
         if alias_url:
             return alias_url.replace('{gistid}', self.gist_access_id)
 
-        from pylons import url
-        return url('gist', gist_id=self.gist_access_id, qualified=True)
+        import kallithea.lib.helpers as h
+        return h.canonical_url('gist', gist_id=self.gist_access_id)
 
     @classmethod
     def base_path(cls):
--- a/kallithea/lib/dbmigrate/schema/db_2_2_0.py	Tue Aug 12 13:08:23 2014 +0200
+++ b/kallithea/lib/dbmigrate/schema/db_2_2_0.py	Tue Aug 12 13:08:23 2014 +0200
@@ -1219,8 +1219,8 @@
         return self.updated_on
 
     def clone_url(self, **override):
-        from pylons import url
-        qualified_home_url = url('home', qualified=True)
+        import kallithea.lib.helpers as h
+        qualified_home_url = h.canonical_url('home')
 
         uri_tmpl = None
         if 'uri_tmpl' in override:
@@ -2393,8 +2393,8 @@
         if alias_url:
             return alias_url.replace('{gistid}', self.gist_access_id)
 
-        from pylons import url
-        return url('gist', gist_id=self.gist_access_id, qualified=True)
+        import kallithea.lib.helpers as h
+        return h.canonical_url('gist', gist_id=self.gist_access_id)
 
     @classmethod
     def base_path(cls):
--- a/kallithea/lib/dbmigrate/schema/db_2_2_3.py	Tue Aug 12 13:08:23 2014 +0200
+++ b/kallithea/lib/dbmigrate/schema/db_2_2_3.py	Tue Aug 12 13:08:23 2014 +0200
@@ -1239,8 +1239,8 @@
         return self.updated_on
 
     def clone_url(self, **override):
-        from pylons import url
-        qualified_home_url = url('home', qualified=True)
+        import kallithea.lib.helpers as h
+        qualified_home_url = h.canonical_url('home')
 
         uri_tmpl = None
         if 'with_id' in override:
@@ -2439,8 +2439,8 @@
         if alias_url:
             return alias_url.replace('{gistid}', self.gist_access_id)
 
-        from pylons import url
-        return url('gist', gist_id=self.gist_access_id, qualified=True)
+        import kallithea.lib.helpers as h
+        return h.canonical_url('gist', gist_id=self.gist_access_id)
 
     @classmethod
     def base_path(cls):
--- a/kallithea/lib/helpers.py	Tue Aug 12 13:08:23 2014 +0200
+++ b/kallithea/lib/helpers.py	Tue Aug 12 13:08:23 2014 +0200
@@ -67,6 +67,18 @@
 log = logging.getLogger(__name__)
 
 
+def canonical_url(*args, **kargs):
+    '''Like url(x, qualified=True), but returns url that not only is qualified
+    but also canonical, as configured in canonical_url'''
+    from kallithea import CONFIG
+    try:
+        parts = CONFIG.get('canonical_url', '').split('://', 1)
+        kargs['host'] = parts[1].split('/', 1)[0]
+        kargs['protocol'] = parts[0]
+    except IndexError:
+        kargs['qualified'] = True
+    return url(*args, **kargs)
+
 def html_escape(text, html_escape_table=None):
     """Produce entities within text."""
     if not html_escape_table:
--- a/kallithea/model/comment.py	Tue Aug 12 13:08:23 2014 +0200
+++ b/kallithea/model/comment.py	Tue Aug 12 13:08:23 2014 +0200
@@ -81,16 +81,13 @@
             cs = repo.scm_instance.get_changeset(revision)
             desc = "%s" % (cs.short_id)
 
-            revision_url = h.url('changeset_home',
+            revision_url = h.canonical_url('changeset_home',
+                repo_name=repo.repo_name,
+                revision=revision)
+            comment_url = h.canonical_url('changeset_home',
                 repo_name=repo.repo_name,
                 revision=revision,
-                qualified=True,)
-            comment_url = h.url('changeset_home',
-                repo_name=repo.repo_name,
-                revision=revision,
-                anchor='comment-%s' % comment.comment_id,
-                qualified=True,
-            )
+                anchor='comment-%s' % comment.comment_id)
             subj = safe_unicode(
                 h.link_to('Re changeset: %(desc)s %(line)s' % \
                           {'desc': desc, 'line': line},
@@ -107,8 +104,7 @@
             email_kwargs = {
                 'status_change': status_change,
                 'cs_comment_user': h.person(user),
-                'cs_target_repo': h.url('summary_home', repo_name=repo.repo_name,
-                                        qualified=True),
+                'cs_target_repo': h.canonical_url('summary_home', repo_name=repo.repo_name),
                 'cs_comment_url': comment_url,
                 'raw_id': revision,
                 'message': cs.message,
@@ -123,16 +119,13 @@
             notification_type = Notification.TYPE_PULL_REQUEST_COMMENT
             desc = comment.pull_request.title
             _org_ref_type, org_ref_name, _org_rev = comment.pull_request.org_ref.split(':')
-            pr_url = h.url('pullrequest_show',
+            pr_url = h.canonical_url('pullrequest_show',
+                repo_name=pull_request.other_repo.repo_name,
+                pull_request_id=pull_request.pull_request_id)
+            comment_url = h.canonical_url('pullrequest_show',
                 repo_name=pull_request.other_repo.repo_name,
                 pull_request_id=pull_request.pull_request_id,
-                qualified=True,)
-            comment_url = h.url('pullrequest_show',
-                repo_name=pull_request.other_repo.repo_name,
-                pull_request_id=pull_request.pull_request_id,
-                anchor='comment-%s' % comment.comment_id,
-                qualified=True,
-            )
+                anchor='comment-%s' % comment.comment_id)
             subj = safe_unicode(
                 h.link_to('Re pull request #%(pr_id)s: %(desc)s %(line)s' % \
                           {'desc': desc,
@@ -157,9 +150,8 @@
                 'closing_pr': closing_pr,
                 'pr_comment_url': comment_url,
                 'pr_comment_user': h.person(user),
-                'pr_target_repo': h.url('summary_home',
-                                   repo_name=pull_request.other_repo.repo_name,
-                                   qualified=True),
+                'pr_target_repo': h.canonical_url('summary_home',
+                                   repo_name=pull_request.other_repo.repo_name),
                 'repo_name': pull_request.other_repo.repo_name,
                 'ref': org_ref_name,
                 'comment_username': user.username,
--- a/kallithea/model/db.py	Tue Aug 12 13:08:23 2014 +0200
+++ b/kallithea/model/db.py	Tue Aug 12 13:08:23 2014 +0200
@@ -1248,8 +1248,8 @@
         return clone_uri
 
     def clone_url(self, **override):
-        from pylons import url
-        qualified_home_url = url('home', qualified=True)
+        import kallithea.lib.helpers as h
+        qualified_home_url = h.canonical_url('home')
 
         uri_tmpl = None
         if 'with_id' in override:
@@ -2447,8 +2447,8 @@
         if alias_url:
             return alias_url.replace('{gistid}', self.gist_access_id)
 
-        from pylons import url
-        return url('gist', gist_id=self.gist_access_id, qualified=True)
+        import kallithea.lib.helpers as h
+        return h.canonical_url('gist', gist_id=self.gist_access_id)
 
     @classmethod
     def base_path(cls):
--- a/kallithea/model/pull_request.py	Tue Aug 12 13:08:23 2014 +0200
+++ b/kallithea/model/pull_request.py	Tue Aug 12 13:08:23 2014 +0200
@@ -124,9 +124,8 @@
                          for x in map(pr.org_repo.get_changeset, pr.revisions)]
 
         #notification to reviewers
-        pr_url = h.url('pullrequest_show', repo_name=pr.other_repo.repo_name,
-                       pull_request_id=pr.pull_request_id,
-                       qualified=True)
+        pr_url = h.canonical_url('pullrequest_show', repo_name=pr.other_repo.repo_name,
+                       pull_request_id=pr.pull_request_id)
         subject = safe_unicode(
             h.link_to(
               _('%(user)s wants you to review pull request #%(pr_id)s: %(pr_title)s') % \
@@ -140,8 +139,7 @@
         email_kwargs = {
             'pr_title': pr.title,
             'pr_user_created': h.person(pr.author),
-            'pr_repo_url': h.url('summary_home', repo_name=pr.other_repo.repo_name,
-                                 qualified=True,),
+            'pr_repo_url': h.canonical_url('summary_home', repo_name=pr.other_repo.repo_name),
             'pr_url': pr_url,
             'pr_revisions': revision_data,
             'repo_name': pr.other_repo.repo_name,
--- a/kallithea/model/user.py	Tue Aug 12 13:08:23 2014 +0200
+++ b/kallithea/model/user.py	Tue Aug 12 13:08:23 2014 +0200
@@ -28,7 +28,6 @@
 
 import logging
 import traceback
-from pylons import url
 from pylons.i18n.translation import _
 
 from sqlalchemy.exc import DatabaseError
@@ -184,6 +183,7 @@
 
     def create_registration(self, form_data):
         from kallithea.model.notification import NotificationModel
+        import kallithea.lib.helpers as h
 
         try:
             form_data['admin'] = False
@@ -202,7 +202,7 @@
                     '- Full Name: %s\n'
                     '- Email: %s\n')
             body = body % (new_user.username, new_user.full_name, new_user.email)
-            edit_url = url('edit_user', id=new_user.user_id, qualified=True)
+            edit_url = h.canonical_url('edit_user', id=new_user.user_id)
             email_kwargs = {'registered_user_url': edit_url, 'new_username': new_user.username}
             NotificationModel().create(created_by=new_user, subject=subject,
                                        body=body, recipients=None,
@@ -287,13 +287,14 @@
     def reset_password_link(self, data):
         from kallithea.lib.celerylib import tasks, run_task
         from kallithea.model.notification import EmailNotificationModel
+        import kallithea.lib.helpers as h
+
         user_email = data['email']
         try:
             user = User.get_by_email(user_email)
             if user:
                 log.debug('password reset user found %s' % user)
-                link = url('reset_password_confirmation', key=user.api_key,
-                           qualified=True)
+                link = h.canonical_url('reset_password_confirmation', key=user.api_key)
                 reg_type = EmailNotificationModel.TYPE_PASSWORD_RESET
                 body = EmailNotificationModel().get_email_tmpl(reg_type,
                                                                user=user.short_contact,
--- a/kallithea/templates/base/base.html	Tue Aug 12 13:08:23 2014 +0200
+++ b/kallithea/templates/base/base.html	Tue Aug 12 13:08:23 2014 +0200
@@ -46,7 +46,7 @@
                    <a href="${h.url('kallithea_project_url')}" target="_blank">Kallithea</a>,
                %endif
                which is
-               <a href="${h.url('about')}#copyright">&copy; 2010&ndash;2014 by various authors &amp; licensed under GPLv3</a>.
+               <a href="${h.canonical_url('about')}#copyright">&copy; 2010&ndash;2014 by various authors &amp; licensed under GPLv3</a>.
                %if c.issues_url:
                    &ndash; <a href="${c.issues_url}" target="_blank">${_('Support')}</a>
                %endif