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