##// END OF EJS Templates
imports: always use CONFIG as kallithea.CONFIG
Mads Kiilerich -
r8433:072c0352 default
parent child Browse files
Show More
@@ -33,7 +33,7 b' from tg import response'
33 33 from tg import tmpl_context as c
34 34 from tg.i18n import ugettext as _
35 35
36 from kallithea import CONFIG
36 import kallithea
37 37 from kallithea.lib import feeds
38 38 from kallithea.lib import helpers as h
39 39 from kallithea.lib.auth import HasRepoPermissionLevelDecorator, LoginRequired
@@ -67,7 +67,7 b' class FeedController(BaseRepoController)'
67 67 desc_msg.append('tag: %s<br/>' % tag)
68 68
69 69 changes = []
70 diff_limit = safe_int(CONFIG.get('rss_cut_off_limit', 32 * 1024))
70 diff_limit = safe_int(kallithea.CONFIG.get('rss_cut_off_limit', 32 * 1024))
71 71 raw_diff = cs.diff()
72 72 diff_processor = DiffProcessor(raw_diff,
73 73 diff_limit=diff_limit,
@@ -92,7 +92,7 b' class FeedController(BaseRepoController)'
92 92 desc_msg.append(h.urlify_text(cs.message))
93 93 desc_msg.append('\n')
94 94 desc_msg.extend(changes)
95 if asbool(CONFIG.get('rss_include_diff', False)):
95 if asbool(kallithea.CONFIG.get('rss_include_diff', False)):
96 96 desc_msg.append('\n\n')
97 97 desc_msg.append(safe_str(raw_diff))
98 98 desc_msg.append('</pre>')
@@ -109,7 +109,7 b' class FeedController(BaseRepoController)'
109 109 description=_('Changes on %s repository') % repo_name,
110 110 )
111 111
112 rss_items_per_page = safe_int(CONFIG.get('rss_items_per_page', 20))
112 rss_items_per_page = safe_int(kallithea.CONFIG.get('rss_items_per_page', 20))
113 113 entries=[]
114 114 for cs in reversed(list(c.db_repo_scm_instance[-rss_items_per_page:])):
115 115 entries.append(dict(
@@ -38,6 +38,7 b' from tg import tmpl_context as c'
38 38 from tg.i18n import ugettext as _
39 39 from webob.exc import HTTPFound, HTTPNotFound
40 40
41 import kallithea
41 42 from kallithea.config.routing import url
42 43 from kallithea.lib import diffs
43 44 from kallithea.lib import helpers as h
@@ -504,13 +505,12 b' class FilesController(BaseRepoController'
504 505 except (ImproperArchiveTypeError, KeyError):
505 506 return _('Unknown archive type')
506 507
507 from kallithea import CONFIG
508 508 rev_name = cs.raw_id[:12]
509 509 archive_name = '%s-%s%s' % (repo_name.replace('/', '_'), rev_name, ext)
510 510
511 511 archive_path = None
512 512 cached_archive_path = None
513 archive_cache_dir = CONFIG.get('archive_cache_dir')
513 archive_cache_dir = kallithea.CONFIG.get('archive_cache_dir')
514 514 if archive_cache_dir and not subrepos: # TODO: subrepo caching?
515 515 if not os.path.isdir(archive_cache_dir):
516 516 os.makedirs(archive_cache_dir)
@@ -38,6 +38,7 b' from webhelpers2.html.tags import submit'
38 38 from webhelpers2.number import format_byte_size
39 39 from webhelpers2.text import chop_at, truncate, wrap_paragraphs
40 40
41 import kallithea
41 42 from kallithea.config.routing import url
42 43 from kallithea.lib.annotate import annotate_highlight
43 44 #==============================================================================
@@ -82,9 +83,8 b' log = logging.getLogger(__name__)'
82 83 def canonical_url(*args, **kargs):
83 84 '''Like url(x, qualified=True), but returns url that not only is qualified
84 85 but also canonical, as configured in canonical_url'''
85 from kallithea import CONFIG
86 86 try:
87 parts = CONFIG.get('canonical_url', '').split('://', 1)
87 parts = kallithea.CONFIG.get('canonical_url', '').split('://', 1)
88 88 kargs['host'] = parts[1]
89 89 kargs['protocol'] = parts[0]
90 90 except IndexError:
@@ -94,9 +94,8 b' def canonical_url(*args, **kargs):'
94 94
95 95 def canonical_hostname():
96 96 '''Return canonical hostname of system'''
97 from kallithea import CONFIG
98 97 try:
99 parts = CONFIG.get('canonical_url', '').split('://', 1)
98 parts = kallithea.CONFIG.get('canonical_url', '').split('://', 1)
100 99 return parts[1].split('/', 1)[0]
101 100 except IndexError:
102 101 parts = url('home', qualified=True).split('://', 1)
@@ -560,9 +559,8 b' def show_id(cs):'
560 559
561 560 :param cs: changeset instance
562 561 """
563 from kallithea import CONFIG
564 def_len = safe_int(CONFIG.get('show_sha_length', 12))
565 show_rev = asbool(CONFIG.get('show_revision_number', False))
562 def_len = safe_int(kallithea.CONFIG.get('show_sha_length', 12))
563 show_rev = asbool(kallithea.CONFIG.get('show_revision_number', False))
566 564
567 565 raw_id = cs.raw_id[:def_len]
568 566 if show_rev:
@@ -1212,25 +1210,24 b' def urlify_issues(newtext, repo_name):'
1212 1210 """Urlify issue references according to .ini configuration"""
1213 1211 global _urlify_issues_f
1214 1212 if _urlify_issues_f is None:
1215 from kallithea import CONFIG
1216 1213 from kallithea.model.db import URL_SEP
1217 assert CONFIG['sqlalchemy.url'] # make sure config has been loaded
1214 assert kallithea.CONFIG['sqlalchemy.url'] # make sure config has been loaded
1218 1215
1219 1216 # Build chain of urlify functions, starting with not doing any transformation
1220 1217 def tmp_urlify_issues_f(s):
1221 1218 return s
1222 1219
1223 1220 issue_pat_re = re.compile(r'issue_pat(.*)')
1224 for k in CONFIG:
1221 for k in kallithea.CONFIG:
1225 1222 # Find all issue_pat* settings that also have corresponding server_link and prefix configuration
1226 1223 m = issue_pat_re.match(k)
1227 1224 if m is None:
1228 1225 continue
1229 1226 suffix = m.group(1)
1230 issue_pat = CONFIG.get(k)
1231 issue_server_link = CONFIG.get('issue_server_link%s' % suffix)
1232 issue_sub = CONFIG.get('issue_sub%s' % suffix)
1233 issue_prefix = CONFIG.get('issue_prefix%s' % suffix)
1227 issue_pat = kallithea.CONFIG.get(k)
1228 issue_server_link = kallithea.CONFIG.get('issue_server_link%s' % suffix)
1229 issue_sub = kallithea.CONFIG.get('issue_sub%s' % suffix)
1230 issue_prefix = kallithea.CONFIG.get('issue_prefix%s' % suffix)
1234 1231 if issue_prefix:
1235 1232 log.error('found unsupported issue_prefix%s = %r - use issue_sub%s instead', suffix, issue_prefix, suffix)
1236 1233 if not issue_pat:
@@ -1,6 +1,6 b''
1 1 import mock
2 2
3 from kallithea import CONFIG
3 import kallithea
4 4 from kallithea.config.conf import INDEX_FILENAMES
5 5 from kallithea.model.meta import Session
6 6 from kallithea.model.repo import RepoModel
@@ -66,7 +66,7 b' def rebuild_index(full_index):'
66 66 # (FYI, ENOMEM occurs at forking "git" with python 2.7.3,
67 67 # Linux 3.2.78-1 x86_64, 3GB memory, and no ulimit
68 68 # configuration for memory)
69 create_test_index(base.TESTS_TMP_PATH, CONFIG, full_index=full_index)
69 create_test_index(base.TESTS_TMP_PATH, kallithea.CONFIG, full_index=full_index)
70 70
71 71
72 72 class TestSearchControllerIndexing(base.TestController):
@@ -36,7 +36,7 b' from tempfile import _RandomNameSequence'
36 36
37 37 import pytest
38 38
39 from kallithea import CONFIG
39 import kallithea
40 40 from kallithea.lib.utils2 import ascii_bytes, safe_str
41 41 from kallithea.model.db import Repository, Ui, User, UserIpMap, UserLog
42 42 from kallithea.model.meta import Session
@@ -101,7 +101,7 b' class HgSshVcsTest(HgVcsTest, SshVcsTest'
101 101 # Specify a custom ssh command on the command line
102 102 return r"""--config ui.ssh="bash -c 'SSH_ORIGINAL_COMMAND=\"\$2\" SSH_CONNECTION=\"%s 1024 127.0.0.1 22\" kallithea-cli ssh-serve -c %s %s %s' --" ssh://someuser@somehost/%s""" % (
103 103 client_ip,
104 CONFIG['__file__'],
104 kallithea.CONFIG['__file__'],
105 105 user.user_id,
106 106 ssh_key.user_ssh_key_id,
107 107 repo_name)
@@ -112,7 +112,7 b' class GitSshVcsTest(GitVcsTest, SshVcsTe'
112 112 # Set a custom ssh command in the global environment
113 113 os.environ['GIT_SSH_COMMAND'] = r"""bash -c 'SSH_ORIGINAL_COMMAND="$2" SSH_CONNECTION="%s 1024 127.0.0.1 22" kallithea-cli ssh-serve -c %s %s %s' --""" % (
114 114 client_ip,
115 CONFIG['__file__'],
115 kallithea.CONFIG['__file__'],
116 116 user.user_id,
117 117 ssh_key.user_ssh_key_id)
118 118 return "ssh://someuser@somehost/%s""" % repo_name
General Comments 0
You need to be logged in to leave comments. Login now