##// END OF EJS Templates
imports: always import the whole kallithea module to use top level kallithea variables...
Mads Kiilerich -
r8434:2ff98321 default
parent child Browse files
Show More
@@ -14,7 +14,7 b''
14 14 import os
15 15 import sys
16 16
17 from kallithea import __version__
17 import kallithea
18 18
19 19
20 20 # If extensions (or modules to document with autodoc) are in another directory,
@@ -56,9 +56,9 b" copyright = '2010-2020 by various author"
56 56 # The short X.Y version.
57 57 root = os.path.dirname(os.path.dirname(__file__))
58 58 sys.path.append(root)
59 version = __version__
59 version = kallithea.__version__
60 60 # The full version, including alpha/beta/rc tags.
61 release = __version__
61 release = kallithea.__version__
62 62
63 63 # The language for content autogenerated by Sphinx. Refer to documentation
64 64 # for a list of supported languages.
@@ -43,7 +43,7 b' from tg import TGController, config, ren'
43 43 from tg import tmpl_context as c
44 44 from tg.i18n import ugettext as _
45 45
46 from kallithea import BACKENDS, __version__
46 import kallithea
47 47 from kallithea.config.routing import url
48 48 from kallithea.lib import auth_modules, ext_json
49 49 from kallithea.lib.auth import AuthUser, HasPermissionAnyMiddleware
@@ -368,7 +368,7 b' class BaseController(TGController):'
368 368 log.error('CSRF check failed')
369 369 raise webob.exc.HTTPForbidden()
370 370
371 c.kallithea_version = __version__
371 c.kallithea_version = kallithea.__version__
372 372 rc_config = Setting.get_app_settings()
373 373
374 374 # Visual options
@@ -413,7 +413,7 b' class BaseController(TGController):'
413 413 # END CONFIG VARS
414 414
415 415 c.repo_name = get_repo_slug(request) # can be empty
416 c.backends = list(BACKENDS)
416 c.backends = list(kallithea.BACKENDS)
417 417
418 418 self.cut_off_limit = safe_int(config.get('cut_off_limit'))
419 419
@@ -31,6 +31,7 b' import time'
31 31
32 32 import mercurial.scmutil
33 33
34 import kallithea
34 35 from kallithea.lib import helpers as h
35 36 from kallithea.lib.exceptions import UserCreationError
36 37 from kallithea.lib.utils import action_logger, make_ui
@@ -94,8 +95,7 b' def log_pull_action(ui, repo, **kwargs):'
94 95 action = 'pull'
95 96 action_logger(user, action, ex.repository, ex.ip, commit=True)
96 97 # extension hook call
97 from kallithea import EXTENSIONS
98 callback = getattr(EXTENSIONS, 'PULL_HOOK', None)
98 callback = getattr(kallithea.EXTENSIONS, 'PULL_HOOK', None)
99 99 if callable(callback):
100 100 kw = {}
101 101 kw.update(ex)
@@ -133,8 +133,7 b' def process_pushed_raw_ids(revs):'
133 133 ScmModel().mark_for_invalidation(ex.repository)
134 134
135 135 # extension hook call
136 from kallithea import EXTENSIONS
137 callback = getattr(EXTENSIONS, 'PUSH_HOOK', None)
136 callback = getattr(kallithea.EXTENSIONS, 'PUSH_HOOK', None)
138 137 if callable(callback):
139 138 kw = {'pushed_revs': revs}
140 139 kw.update(ex)
@@ -164,8 +163,7 b' def log_create_repository(repository_dic'
164 163 'repo_name'
165 164
166 165 """
167 from kallithea import EXTENSIONS
168 callback = getattr(EXTENSIONS, 'CREATE_REPO_HOOK', None)
166 callback = getattr(kallithea.EXTENSIONS, 'CREATE_REPO_HOOK', None)
169 167 if callable(callback):
170 168 kw = {}
171 169 kw.update(repository_dict)
@@ -176,8 +174,7 b' def log_create_repository(repository_dic'
176 174
177 175 def check_allowed_create_user(user_dict, created_by, **kwargs):
178 176 # pre create hooks
179 from kallithea import EXTENSIONS
180 callback = getattr(EXTENSIONS, 'PRE_CREATE_USER_HOOK', None)
177 callback = getattr(kallithea.EXTENSIONS, 'PRE_CREATE_USER_HOOK', None)
181 178 if callable(callback):
182 179 allowed, reason = callback(created_by=created_by, **user_dict)
183 180 if not allowed:
@@ -212,8 +209,7 b' def log_create_user(user_dict, created_b'
212 209 'emails',
213 210
214 211 """
215 from kallithea import EXTENSIONS
216 callback = getattr(EXTENSIONS, 'CREATE_USER_HOOK', None)
212 callback = getattr(kallithea.EXTENSIONS, 'CREATE_USER_HOOK', None)
217 213 if callable(callback):
218 214 callback(created_by=created_by, **user_dict)
219 215
@@ -224,8 +220,7 b' def log_create_pullrequest(pullrequest_d'
224 220
225 221 :param pullrequest_dict: dict dump of pull request object
226 222 """
227 from kallithea import EXTENSIONS
228 callback = getattr(EXTENSIONS, 'CREATE_PULLREQUEST_HOOK', None)
223 callback = getattr(kallithea.EXTENSIONS, 'CREATE_PULLREQUEST_HOOK', None)
229 224 if callable(callback):
230 225 return callback(created_by=created_by, **pullrequest_dict)
231 226
@@ -254,8 +249,7 b' def log_delete_repository(repository_dic'
254 249 'repo_name'
255 250
256 251 """
257 from kallithea import EXTENSIONS
258 callback = getattr(EXTENSIONS, 'DELETE_REPO_HOOK', None)
252 callback = getattr(kallithea.EXTENSIONS, 'DELETE_REPO_HOOK', None)
259 253 if callable(callback):
260 254 kw = {}
261 255 kw.update(repository_dict)
@@ -293,8 +287,7 b' def log_delete_user(user_dict, deleted_b'
293 287 'emails',
294 288
295 289 """
296 from kallithea import EXTENSIONS
297 callback = getattr(EXTENSIONS, 'DELETE_USER_HOOK', None)
290 callback = getattr(kallithea.EXTENSIONS, 'DELETE_USER_HOOK', None)
298 291 if callable(callback):
299 292 callback(deleted_by=deleted_by, **user_dict)
300 293
@@ -41,6 +41,7 b' from tg.i18n import ungettext'
41 41 from tg.support.converters import asbool, aslist
42 42 from webhelpers2.text import collapse, remove_formatting, strip_tags
43 43
44 import kallithea
44 45 from kallithea.lib.vcs.utils import ascii_bytes, ascii_str, safe_bytes, safe_str # re-export
45 46 from kallithea.lib.vcs.utils.lazy import LazyProperty
46 47
@@ -442,14 +443,13 b' def set_hook_environment(username, ip_ad'
442 443
443 444 Must always be called before anything with hooks are invoked.
444 445 """
445 from kallithea import CONFIG
446 446 extras = {
447 447 'ip': ip_addr, # used in log_push/pull_action action_logger
448 448 'username': username,
449 449 'action': action or 'push_local', # used in log_push_action_raw_ids action_logger
450 450 'repository': repo_name,
451 451 'scm': repo_alias, # used to pick hack in log_push_action_raw_ids
452 'config': CONFIG['__file__'], # used by git hook to read config
452 'config': kallithea.CONFIG['__file__'], # used by git hook to read config
453 453 }
454 454 os.environ['KALLITHEA_EXTRAS'] = json.dumps(extras)
455 455
@@ -39,7 +39,7 b' import formencode'
39 39 from formencode import All
40 40 from tg.i18n import ugettext as _
41 41
42 from kallithea import BACKENDS
42 import kallithea
43 43 from kallithea.model import validators as v
44 44
45 45
@@ -238,7 +238,7 b' def PasswordResetConfirmationForm():'
238 238 return _PasswordResetConfirmationForm
239 239
240 240
241 def RepoForm(edit=False, old_data=None, supported_backends=BACKENDS,
241 def RepoForm(edit=False, old_data=None, supported_backends=kallithea.BACKENDS,
242 242 repo_groups=None, landing_revs=None):
243 243 old_data = old_data or {}
244 244 repo_groups = repo_groups or []
@@ -315,7 +315,7 b' def RepoFieldForm():'
315 315 return _RepoFieldForm
316 316
317 317
318 def RepoForkForm(edit=False, old_data=None, supported_backends=BACKENDS,
318 def RepoForkForm(edit=False, old_data=None, supported_backends=kallithea.BACKENDS,
319 319 repo_groups=None, landing_revs=None):
320 320 old_data = old_data or {}
321 321 repo_groups = repo_groups or []
@@ -431,7 +431,7 b' def CustomDefaultPermissionsForm():'
431 431 return _CustomDefaultPermissionsForm
432 432
433 433
434 def DefaultsForm(edit=False, old_data=None, supported_backends=BACKENDS):
434 def DefaultsForm(edit=False, old_data=None, supported_backends=kallithea.BACKENDS):
435 435 class _DefaultsForm(formencode.Schema):
436 436 allow_extra_fields = True
437 437 filter_extra_fields = True
@@ -36,7 +36,6 b' import pkg_resources'
36 36 from tg.i18n import ugettext as _
37 37
38 38 import kallithea
39 from kallithea import BACKENDS
40 39 from kallithea.lib.auth import HasPermissionAny, HasRepoGroupPermissionLevel, HasRepoPermissionLevel, HasUserGroupPermissionLevel
41 40 from kallithea.lib.exceptions import IMCCommitError, NonRelativePathError
42 41 from kallithea.lib.hooks import process_pushed_raw_ids
@@ -188,10 +187,10 b' class ScmModel(object):'
188 187
189 188 klass = get_backend(path[0])
190 189
191 if path[0] == 'hg' and path[0] in BACKENDS:
190 if path[0] == 'hg' and path[0] in kallithea.BACKENDS:
192 191 repos[name] = klass(path[1], baseui=baseui)
193 192
194 if path[0] == 'git' and path[0] in BACKENDS:
193 if path[0] == 'git' and path[0] in kallithea.BACKENDS:
195 194 repos[name] = klass(path[1])
196 195 except OSError:
197 196 continue
General Comments 0
You need to be logged in to leave comments. Login now