[PATCH PoC] hacks: the concept of python files that will be loaded and can monkeypatch Kallithea internals
Mads Kiilerich
mads at kiilerich.com
Mon Apr 20 17:28:31 EDT 2015
# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1429565291 -7200
# Mon Apr 20 23:28:11 2015 +0200
# Node ID fcfd593347c8240544996f5516113595c0ff390a
# Parent 7e5a0c784880bf8da968710948f3aa617403bf5a
hacks: the concept of python files that will be loaded and can monkeypatch Kallithea internals
diff --git a/kallithea/config/environment.py b/kallithea/config/environment.py
--- a/kallithea/config/environment.py
+++ b/kallithea/config/environment.py
@@ -16,6 +16,8 @@
"""
import os
+import os.path
+import imp
import logging
import kallithea
import platform
@@ -43,12 +45,25 @@ from kallithea.model.scm import ScmModel
log = logging.getLogger(__name__)
+def load_hacks():
+ """
+ Load hacks - python files dropped in kallithea/hacks that will monkeypatch
+ Kallithea internals
+ """
+ hacksdir = os.path.dirname(__file__) + '/../hacks'
+ if os.path.isdir(hacksdir):
+ for f in os.listdir(hacksdir):
+ if not f.startswith('_') and f.endswith('.py'):
+ _m = imp.load_source('hacks.%s' % f, hacksdir + '/' + f)
+
def load_environment(global_conf, app_conf, initial=False,
test_env=None, test_index=None):
"""
Configure the Pylons environment via the ``pylons.config``
object
"""
+ load_hacks()
+
config = PylonsConfig()
# Pylons paths
diff --git a/kallithea/hacks/nogit.py b/kallithea/hacks/nogit.py
new file mode 100644
--- /dev/null
+++ b/kallithea/hacks/nogit.py
@@ -0,0 +1,5 @@
+"""
+disable adding Git repos
+"""
+import kallithea
+kallithea.BACKENDS.pop('git')
More information about the kallithea-general
mailing list