##// END OF EJS Templates
tg: minimize future diff by some mocking and replacing some pylons imports with tg...
Mads Kiilerich -
r6508:e9ac5698 default
parent child Browse files
Show More
@@ -30,6 +30,10 b' Original author and date, and relevant c'
30 30 import sys
31 31 import platform
32 32
33 # temporary aliasing to allow early introduction of imports like 'from tg import request'
34 import pylons
35 sys.modules['tg'] = pylons
36
33 37 VERSION = (0, 3, 99)
34 38 BACKENDS = {
35 39 'hg': 'Mercurial repository',
@@ -19,7 +19,7 b' may take precedent over the more generic'
19 19 refer to the routes manual at http://routes.groovie.org/docs/
20 20 """
21 21
22 from pylons import request
22 from tg import request
23 23 from routes import Mapper
24 24
25 25 # prefix for non repository related links needs to be prefixed with `/`
@@ -28,7 +28,7 b' Original author and date, and relevant c'
28 28
29 29 import logging
30 30
31 from pylons import request, tmpl_context as c
31 from tg import request, tmpl_context as c
32 32 from sqlalchemy.orm import joinedload
33 33 from whoosh.qparser.default import QueryParser
34 34 from whoosh.qparser.dateparse import DateParserPlugin
@@ -27,8 +27,8 b' import logging'
27 27 import formencode.htmlfill
28 28 import traceback
29 29
30 from pylons import request, tmpl_context as c
31 from pylons.i18n.translation import _
30 from tg import request, tmpl_context as c
31 from tg.i18n import ugettext as _
32 32 from webob.exc import HTTPFound
33 33
34 34 from kallithea.config.routing import url
@@ -30,8 +30,8 b' import traceback'
30 30 import formencode
31 31 from formencode import htmlfill
32 32
33 from pylons import request, tmpl_context as c
34 from pylons.i18n.translation import _
33 from tg import request, tmpl_context as c
34 from tg.i18n import ugettext as _
35 35 from webob.exc import HTTPFound
36 36
37 37 from kallithea.config.routing import url
@@ -30,8 +30,8 b' import logging'
30 30 import traceback
31 31 import formencode.htmlfill
32 32
33 from pylons import request, response, tmpl_context as c
34 from pylons.i18n.translation import _
33 from tg import request, response, tmpl_context as c
34 from tg.i18n import ugettext as _
35 35 from webob.exc import HTTPFound, HTTPNotFound, HTTPForbidden
36 36
37 37 from kallithea.config.routing import url
@@ -31,8 +31,8 b' import formencode'
31 31
32 32 from sqlalchemy import func
33 33 from formencode import htmlfill
34 from pylons import request, tmpl_context as c
35 from pylons.i18n.translation import _
34 from tg import request, tmpl_context as c
35 from tg.i18n import ugettext as _
36 36 from webob.exc import HTTPFound
37 37
38 38 from kallithea.config.routing import url
@@ -28,8 +28,8 b' Original author and date, and relevant c'
28 28 import logging
29 29 import traceback
30 30
31 from pylons import request
32 from pylons import tmpl_context as c
31 from tg import request
32 from tg import tmpl_context as c
33 33 from webob.exc import HTTPBadRequest, HTTPForbidden
34 34
35 35 from kallithea.model.db import Notification
@@ -31,8 +31,8 b' import traceback'
31 31 import formencode
32 32 from formencode import htmlfill
33 33
34 from pylons import request, tmpl_context as c
35 from pylons.i18n.translation import _
34 from tg import request, tmpl_context as c
35 from tg.i18n import ugettext as _
36 36 from webob.exc import HTTPFound
37 37
38 38 from kallithea.config.routing import url
@@ -32,8 +32,8 b' import itertools'
32 32
33 33 from formencode import htmlfill
34 34
35 from pylons import request, tmpl_context as c
36 from pylons.i18n.translation import _, ungettext
35 from tg import request, tmpl_context as c
36 from tg.i18n import ugettext as _, ungettext
37 37 from webob.exc import HTTPFound, HTTPForbidden, HTTPNotFound, HTTPInternalServerError
38 38
39 39 import kallithea
@@ -29,8 +29,8 b' import logging'
29 29 import traceback
30 30 import formencode
31 31 from formencode import htmlfill
32 from pylons import request, tmpl_context as c
33 from pylons.i18n.translation import _
32 from tg import request, tmpl_context as c
33 from tg.i18n import ugettext as _
34 34 from sqlalchemy.sql.expression import func
35 35 from webob.exc import HTTPFound, HTTPInternalServerError, HTTPForbidden, HTTPNotFound
36 36
@@ -30,8 +30,8 b' import traceback'
30 30 import formencode
31 31
32 32 from formencode import htmlfill
33 from pylons import request, tmpl_context as c, config
34 from pylons.i18n.translation import _
33 from tg import request, tmpl_context as c, config
34 from tg.i18n import ugettext as _
35 35 from webob.exc import HTTPFound
36 36
37 37 from kallithea.config.routing import url
@@ -30,8 +30,8 b' import traceback'
30 30 import formencode
31 31
32 32 from formencode import htmlfill
33 from pylons import request, tmpl_context as c, config
34 from pylons.i18n.translation import _
33 from tg import request, tmpl_context as c, config
34 from tg.i18n import ugettext as _
35 35 from webob.exc import HTTPFound
36 36
37 37 from sqlalchemy.orm import joinedload
@@ -30,8 +30,8 b' import traceback'
30 30 import formencode
31 31
32 32 from formencode import htmlfill
33 from pylons import request, tmpl_context as c, config
34 from pylons.i18n.translation import _
33 from tg import request, tmpl_context as c, config
34 from tg.i18n import ugettext as _
35 35 from sqlalchemy.sql.expression import func
36 36 from webob.exc import HTTPFound, HTTPNotFound
37 37
@@ -35,7 +35,7 b' import itertools'
35 35 from paste.response import replace_header
36 36 from pylons.controllers import WSGIController
37 37 from pylons.controllers.util import Response
38 from pylons import request
38 from tg import request
39 39
40 40 from webob.exc import HTTPError
41 41
@@ -30,7 +30,7 b' import traceback'
30 30 import logging
31 31 from sqlalchemy import or_
32 32
33 from pylons import request
33 from tg import request
34 34
35 35 from kallithea.controllers.api import JSONRPCController, JSONRPCError
36 36 from kallithea.lib.auth import (
@@ -28,8 +28,8 b' Original author and date, and relevant c'
28 28 import logging
29 29 import traceback
30 30
31 from pylons import request, session, tmpl_context as c
32 from pylons.i18n.translation import _
31 from tg import request, session, tmpl_context as c
32 from tg.i18n import ugettext as _
33 33 from webob.exc import HTTPFound, HTTPNotFound, HTTPBadRequest
34 34
35 35 import kallithea.lib.helpers as h
@@ -29,8 +29,8 b' import logging'
29 29 import traceback
30 30 from collections import defaultdict
31 31
32 from pylons import tmpl_context as c, request, response
33 from pylons.i18n.translation import _
32 from tg import tmpl_context as c, request, response
33 from tg.i18n import ugettext as _
34 34 from webob.exc import HTTPFound, HTTPForbidden, HTTPBadRequest, HTTPNotFound
35 35
36 36 from kallithea.lib.vcs.exceptions import RepositoryError, \
@@ -30,8 +30,8 b' Original author and date, and relevant c'
30 30 import logging
31 31 import re
32 32
33 from pylons import request, tmpl_context as c
34 from pylons.i18n.translation import _
33 from tg import request, tmpl_context as c
34 from tg.i18n import ugettext as _
35 35 from webob.exc import HTTPFound, HTTPBadRequest, HTTPNotFound
36 36
37 37 from kallithea.config.routing import url
@@ -29,8 +29,8 b' import os'
29 29 import cgi
30 30 import logging
31 31
32 from pylons import tmpl_context as c, request, config
33 from pylons.i18n.translation import _
32 from tg import tmpl_context as c, request, config
33 from tg.i18n import ugettext as _
34 34 from pylons.middleware import media_path
35 35
36 36 from kallithea.lib.base import BaseController, render
@@ -28,8 +28,8 b' Original author and date, and relevant c'
28 28
29 29 import logging
30 30
31 from pylons import response, tmpl_context as c
32 from pylons.i18n.translation import _
31 from tg import response, tmpl_context as c
32 from tg.i18n import ugettext as _
33 33
34 34 from beaker.cache import cache_region, region_invalidate
35 35 from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed
@@ -32,8 +32,8 b' import traceback'
32 32 import tempfile
33 33 import shutil
34 34
35 from pylons import request, response, tmpl_context as c
36 from pylons.i18n.translation import _
35 from tg import request, response, tmpl_context as c
36 from tg.i18n import ugettext as _
37 37 from webob.exc import HTTPFound
38 38
39 39 from kallithea.config.routing import url
@@ -27,7 +27,7 b' Original author and date, and relevant c'
27 27
28 28 import logging
29 29
30 from pylons import tmpl_context as c, request
30 from tg import tmpl_context as c, request
31 31
32 32 from kallithea.lib.auth import LoginRequired, HasRepoPermissionLevelDecorator
33 33 from kallithea.lib.base import BaseRepoController, render
@@ -30,8 +30,8 b' import formencode'
30 30 import traceback
31 31 from formencode import htmlfill
32 32
33 from pylons import tmpl_context as c, request
34 from pylons.i18n.translation import _
33 from tg import tmpl_context as c, request
34 from tg.i18n import ugettext as _
35 35 from webob.exc import HTTPFound
36 36
37 37 import kallithea.lib.helpers as h
@@ -28,8 +28,8 b' Original author and date, and relevant c'
28 28
29 29 import logging
30 30
31 from pylons import tmpl_context as c, request
32 from pylons.i18n.translation import _
31 from tg import tmpl_context as c, request
32 from tg.i18n import ugettext as _
33 33 from webob.exc import HTTPBadRequest
34 34 from sqlalchemy.sql.expression import func
35 35
@@ -37,8 +37,8 b' from sqlalchemy.sql.expression import fu'
37 37 from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed
38 38
39 39 from webob.exc import HTTPBadRequest
40 from pylons import request, tmpl_context as c, response
41 from pylons.i18n.translation import _
40 from tg import request, tmpl_context as c, response
41 from tg.i18n import ugettext as _
42 42
43 43 from kallithea.config.routing import url
44 44 from kallithea.controllers.admin.admin import _journal_filter
@@ -31,8 +31,8 b' import re'
31 31 import formencode
32 32
33 33 from formencode import htmlfill
34 from pylons.i18n.translation import _
35 from pylons import request, session, tmpl_context as c
34 from tg.i18n import ugettext as _
35 from tg import request, session, tmpl_context as c
36 36 from webob.exc import HTTPFound, HTTPBadRequest
37 37
38 38 import kallithea.lib.helpers as h
@@ -29,8 +29,8 b' import logging'
29 29 import traceback
30 30 import formencode
31 31
32 from pylons import request, tmpl_context as c
33 from pylons.i18n.translation import _
32 from tg import request, tmpl_context as c
33 from tg.i18n import ugettext as _
34 34 from webob.exc import HTTPFound, HTTPNotFound, HTTPForbidden, HTTPBadRequest
35 35
36 36 from kallithea.config.routing import url
@@ -28,8 +28,8 b' Original author and date, and relevant c'
28 28 import logging
29 29 import traceback
30 30 import urllib
31 from pylons.i18n.translation import _
32 from pylons import request, config, tmpl_context as c
31 from tg.i18n import ugettext as _
32 from tg import request, config, tmpl_context as c
33 33
34 34 from whoosh.index import open_dir, EmptyIndexError
35 35 from whoosh.qparser import QueryParser, QueryParserError
@@ -32,8 +32,8 b' import itertools'
32 32 from time import mktime
33 33 from datetime import timedelta, date
34 34
35 from pylons import tmpl_context as c, request
36 from pylons.i18n.translation import _
35 from tg import tmpl_context as c, request
36 from tg.i18n import ugettext as _
37 37 from webob.exc import HTTPBadRequest
38 38
39 39 from beaker.cache import cache_region, region_invalidate
@@ -33,8 +33,8 b' import collections'
33 33
34 34 from decorator import decorator
35 35
36 from pylons import request, session
37 from pylons.i18n.translation import _
36 from tg import request, session
37 from tg.i18n import ugettext as _
38 38 from webhelpers.pylonslib import secure_form
39 39 from sqlalchemy.orm.exc import ObjectDeletedError
40 40 from sqlalchemy.orm import joinedload
@@ -41,10 +41,10 b' import paste.auth.basic'
41 41 import paste.httpheaders
42 42 from webhelpers.pylonslib import secure_form
43 43
44 from pylons import config, tmpl_context as c, request, response, session
44 from tg import config, tmpl_context as c, request, response, session
45 45 from pylons.controllers import WSGIController
46 46 from pylons.templating import render_mako as render # don't remove this import
47 from pylons.i18n.translation import _
47 from tg.i18n import ugettext as _
48 48
49 49 from kallithea import __version__, BACKENDS
50 50
@@ -29,7 +29,7 b' Original author and date, and relevant c'
29 29 import os
30 30 import logging
31 31
32 from pylons import config
32 from tg import config
33 33
34 34 from hashlib import md5
35 35 from decorator import decorator
@@ -35,7 +35,7 b' from time import mktime'
35 35 from operator import itemgetter
36 36 from string import lower
37 37
38 from pylons import config
38 from tg import config
39 39
40 40 from kallithea import CELERY_ON
41 41 from kallithea.lib import celerylib
@@ -20,7 +20,7 b' import os'
20 20 import warnings
21 21
22 22 # Verify Pylons configuration has been loaded
23 from pylons import config
23 from tg import config
24 24 assert config['celery.imports'] == 'kallithea.lib.celerylib.tasks', 'Kallithea Celery configuration has not been loaded'
25 25
26 26 # Prepare environment to point at Kallithea Pylons loader
@@ -1,7 +1,7 b''
1 1 # -*- coding: utf-8 -*-
2 2
3 3 from celery.loaders.base import BaseLoader
4 from pylons import config
4 from tg import config
5 5
6 6 # TODO: drop this mangling and just use a separate celery config section
7 7 to_pylons = lambda x: x.replace('_', '.').lower()
@@ -31,7 +31,7 b' import logging'
31 31
32 32 from itertools import tee, imap
33 33
34 from pylons.i18n.translation import _
34 from tg.i18n import ugettext as _
35 35
36 36 from kallithea.lib.vcs.exceptions import VCSError
37 37 from kallithea.lib.vcs.nodes import FileNode, SubModuleNode
@@ -28,7 +28,7 b' import textwrap'
28 28 from beaker.cache import cache_region
29 29 from pygments.formatters.html import HtmlFormatter
30 30 from pygments import highlight as code_highlight
31 from pylons.i18n.translation import _
31 from tg.i18n import ugettext as _
32 32
33 33 from webhelpers.html import literal, HTML, escape
34 34 from webhelpers.html.tags import checkbox, end_form, hidden, link_to, \
@@ -425,7 +425,7 b' class Flash(_Flash):'
425 425
426 426 The return value is a list of ``Message`` objects.
427 427 """
428 from pylons import session
428 from tg import session
429 429 messages = session.pop(self.session_key, [])
430 430 session.save()
431 431 return [_Message(*m) for m in messages]
@@ -835,7 +835,7 b" def gravatar_div(email_address, cls='', "
835 835 and '_' changed to '-' and be used as attributes on the div. The default
836 836 class is 'gravatar'.
837 837 """
838 from pylons import tmpl_context as c
838 from tg import tmpl_context as c
839 839 if not c.visual.use_gravatar:
840 840 return ''
841 841 if 'div_class' not in div_attributes:
@@ -856,7 +856,7 b" def gravatar(email_address, cls='', size"
856 856 empty then we fallback to using an icon.
857 857
858 858 """
859 from pylons import tmpl_context as c
859 from tg import tmpl_context as c
860 860 if not c.visual.use_gravatar:
861 861 return ''
862 862
@@ -879,7 +879,7 b' def gravatar_url(email_address, size=30,'
879 879 # doh, we need to re-import those to mock it later
880 880 from kallithea.config.routing import url
881 881 from kallithea.model.db import User
882 from pylons import tmpl_context as c
882 from tg import tmpl_context as c
883 883 if not c.visual.use_gravatar:
884 884 return ""
885 885
@@ -30,7 +30,7 b' class Command(BasePasterCommand):'
30 30
31 31 def command(self):
32 32 from kallithea.lib import celerypylons
33 from pylons import config
33 from tg import config
34 34 try:
35 35 CELERY_ON = str2bool(config['app_conf'].get('use_celery'))
36 36 except KeyError:
@@ -87,7 +87,7 b' class BasePasterCommand(Command):'
87 87 """
88 88 Loads the app configuration.
89 89 """
90 from pylons import config as pylonsconfig
90 from tg import config as pylonsconfig
91 91
92 92 self.path_to_ini_file = os.path.realpath(conf)
93 93 conf = paste.deploy.appconfig('config:' + self.path_to_ini_file)
@@ -99,7 +99,7 b' class BasePasterCommand(Command):'
99 99 """
100 100 logging.config.fileConfig(self.path_to_ini_file)
101 101
102 from pylons import config
102 from tg import config
103 103 from kallithea.model.base import init_model
104 104 from kallithea.lib.utils2 import engine_from_config
105 105 setup_cache_regions(config)
@@ -50,7 +50,7 b' class Command(BasePasterCommand):'
50 50 def command(self):
51 51 #get SqlAlchemy session
52 52 self._init_session()
53 from pylons import config
53 from tg import config
54 54 index_location = config['index_dir']
55 55 load_rcextensions(config['here'])
56 56
@@ -50,7 +50,7 b' class Command(BasePasterCommand):'
50 50 '''
51 51
52 52 def command(self):
53 from pylons import config
53 from tg import config
54 54
55 55 here = config['here']
56 56 content = pkg_resources.resource_string(
@@ -38,7 +38,7 b' import binascii'
38 38 import webob
39 39 import urlobject
40 40
41 from pylons.i18n.translation import _, ungettext
41 from tg.i18n import ugettext as _, ungettext
42 42 from kallithea.lib.vcs.utils.lazy import LazyProperty
43 43 from kallithea.lib.compat import json
44 44
@@ -623,7 +623,7 b' def get_current_authuser():'
623 623 Gets kallithea user from threadlocal tmpl_context variable if it's
624 624 defined, else returns None.
625 625 """
626 from pylons import tmpl_context
626 from tg import tmpl_context
627 627 if hasattr(tmpl_context, 'authuser'):
628 628 return tmpl_context.authuser
629 629
@@ -27,7 +27,7 b' Original author and date, and relevant c'
27 27
28 28 import logging
29 29
30 from pylons.i18n.translation import _
30 from tg.i18n import ugettext as _
31 31 from collections import defaultdict
32 32
33 33 from kallithea.lib.utils2 import extract_mentioned_users, safe_unicode
@@ -41,7 +41,7 b' from sqlalchemy.orm import relationship,'
41 41 from beaker.cache import cache_region, region_invalidate
42 42 from webob.exc import HTTPNotFound
43 43
44 from pylons.i18n.translation import lazy_ugettext as _
44 from tg.i18n import lazy_ugettext as _
45 45
46 46 from kallithea.lib.exceptions import DefaultUserException
47 47 from kallithea.lib.vcs import get_backend
@@ -1327,7 +1327,7 b' class Repository(Base, BaseDbModel):'
1327 1327 if not uri_tmpl:
1328 1328 uri_tmpl = self.DEFAULT_CLONE_URI
1329 1329 try:
1330 from pylons import tmpl_context as c
1330 from tg import tmpl_context as c
1331 1331 uri_tmpl = c.clone_uri_tmpl
1332 1332 except AttributeError:
1333 1333 # in any case if we call this outside of request context,
@@ -38,7 +38,7 b' import logging'
38 38 import formencode
39 39 from formencode import All
40 40
41 from pylons.i18n.translation import _
41 from tg.i18n import ugettext as _
42 42
43 43 from kallithea import BACKENDS
44 44 from kallithea.model import validators as v
@@ -29,8 +29,8 b' Original author and date, and relevant c'
29 29 import logging
30 30 import traceback
31 31
32 from pylons import tmpl_context as c
33 from pylons.i18n.translation import _
32 from tg import tmpl_context as c
33 from tg.i18n import ugettext as _
34 34 from sqlalchemy.orm import joinedload, subqueryload
35 35
36 36 import kallithea
@@ -29,8 +29,8 b' import logging'
29 29 import datetime
30 30 import re
31 31
32 from pylons import request
33 from pylons.i18n.translation import _
32 from tg import request
33 from tg.i18n import ugettext as _
34 34
35 35 from sqlalchemy.orm import joinedload
36 36
@@ -153,8 +153,8 b' class RepoModel(object):'
153 153 @classmethod
154 154 def _render_datatable(cls, tmpl, *args, **kwargs):
155 155 import kallithea
156 from pylons import tmpl_context as c, request
157 from pylons.i18n.translation import _
156 from tg import tmpl_context as c, request
157 from tg.i18n import ugettext as _
158 158
159 159 _tmpl_lookup = kallithea.CONFIG['pylons.app_globals'].mako_lookup
160 160 template = _tmpl_lookup.get_template('data_table/_dt_elements.html')
@@ -166,7 +166,7 b' class RepoModel(object):'
166 166 def get_repos_as_dict(self, repos_list=None, admin=False, perm_check=True,
167 167 super_user_actions=False, short_name=False):
168 168 _render = self._render_datatable
169 from pylons import tmpl_context as c
169 from tg import tmpl_context as c
170 170
171 171 def repo_lnk(name, rtype, rstate, private, fork_of):
172 172 return _render('repo_name', name, rtype, rstate, private, fork_of,
@@ -36,7 +36,7 b' import cStringIO'
36 36 import pkg_resources
37 37
38 38 from sqlalchemy import func
39 from pylons.i18n.translation import _
39 from tg.i18n import ugettext as _
40 40
41 41 import kallithea
42 42 from kallithea.lib.vcs import get_backend
@@ -333,7 +333,7 b' class ScmModel(object):'
333 333 from kallithea import CONFIG
334 334 from kallithea.lib.base import _get_ip_addr
335 335 try:
336 from pylons import request
336 from tg import request
337 337 environ = request.environ
338 338 except TypeError:
339 339 # we might use this outside of request context, let's fake the
@@ -32,8 +32,8 b' import logging'
32 32 import time
33 33 import traceback
34 34
35 from pylons import config
36 from pylons.i18n.translation import _
35 from tg import config
36 from tg.i18n import ugettext as _
37 37
38 38 from sqlalchemy.exc import DatabaseError
39 39
@@ -20,7 +20,7 b' import re'
20 20 import formencode
21 21 import logging
22 22 from collections import defaultdict
23 from pylons.i18n.translation import _
23 from tg.i18n import ugettext as _
24 24 from webhelpers.pylonslib.secure_form import authentication_token
25 25 import sqlalchemy
26 26
@@ -20,8 +20,9 b' import re'
20 20 import tempfile
21 21 import time
22 22
23 from tg import config
23 24 import pylons
24 from pylons import config, url
25 from pylons import url
25 26 from pylons.i18n.translation import _get_translator
26 27 from pylons.util import ContextObj
27 28 from routes.util import URLGenerator
General Comments 0
You need to be logged in to leave comments. Login now