You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2019/05/21 15:40:03 UTC
[allura] 06/09: [#8286] remove pylons and its transitive deps
This is an automated email from the ASF dual-hosted git repository.
brondsem pushed a commit to branch db/8286
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 53d6ede15948445dff6070d6cfaeab9a6656c25a
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Fri May 17 17:59:11 2019 -0400
[#8286] remove pylons and its transitive deps
---
Allura/allura/config/app_cfg.py | 4 ++--
Allura/allura/config/middleware.py | 2 +-
Allura/allura/controllers/auth.py | 2 +-
Allura/allura/controllers/error.py | 2 +-
Allura/allura/controllers/rest.py | 4 ++--
Allura/allura/lib/base.py | 2 +-
Allura/allura/lib/custom_middleware.py | 9 ++++-----
Allura/allura/lib/utils.py | 2 +-
Allura/development.ini | 9 ++-------
Allura/docker-dev.ini | 7 +------
Allura/docs/development/testing.rst | 6 +++---
Allura/docs/platform/platform_tour.rst | 4 ++--
Allura/production-docker-example.ini | 7 +------
Allura/setup.cfg | 7 -------
Allura/setup.py | 11 +++++------
AlluraTest/alluratest/controller.py | 17 +++++++++++------
ForgeWiki/forgewiki/tests/functional/test_rest.py | 2 --
requirements.txt | 3 ---
18 files changed, 38 insertions(+), 62 deletions(-)
diff --git a/Allura/allura/config/app_cfg.py b/Allura/allura/config/app_cfg.py
index abd4076..690135c 100644
--- a/Allura/allura/config/app_cfg.py
+++ b/Allura/allura/config/app_cfg.py
@@ -33,10 +33,10 @@ convert them into boolean, for example, you should use the
import logging
from functools import partial
+import tg
from tg import app_globals as g
from tg.renderers.jinja import JinjaRenderer
import jinja2
-import pylons
from tg.configuration import AppConfig, config
from routes import Mapper
from webhelpers.html import literal
@@ -115,7 +115,7 @@ class AlluraJinjaRenderer(JinjaRenderer):
bytecode_cache=bcc,
cache_size=config.get('jinja_cache_size', -1),
extensions=['jinja2.ext.do', 'jinja2.ext.i18n'])
- jinja2_env.install_gettext_translations(pylons.i18n)
+ jinja2_env.install_gettext_translations(tg.i18n)
jinja2_env.filters['filesizeformat'] = helpers.do_filesizeformat
jinja2_env.filters['datetimeformat'] = helpers.datetimeformat
jinja2_env.filters['filter'] = lambda s, t=None: filter(t and jinja2_env.tests[t], s)
diff --git a/Allura/allura/config/middleware.py b/Allura/allura/config/middleware.py
index b97353e..7098fcb 100644
--- a/Allura/allura/config/middleware.py
+++ b/Allura/allura/config/middleware.py
@@ -114,7 +114,7 @@ def _make_core_app(root, global_conf, full_stack=True, **app_conf):
# make_base_app = base_config.setup_tg_wsgi_app(load_environment)
# app = make_base_app(global_conf, full_stack=True, **app_conf)
- # Configure the Pylons environment
+ # Configure the TG environment
load_environment(global_conf, app_conf)
app = tg.TGApp()
diff --git a/Allura/allura/controllers/auth.py b/Allura/allura/controllers/auth.py
index 299664d..1fc0bd2 100644
--- a/Allura/allura/controllers/auth.py
+++ b/Allura/allura/controllers/auth.py
@@ -126,7 +126,7 @@ class AuthController(BaseController):
@expose('jinja:allura:templates/login.html')
@with_trailing_slash
def index(self, *args, **kwargs):
- orig_request = request.environ.get('pylons.original_request', None)
+ orig_request = request.environ.get('tg.original_request', None)
if 'return_to' in kwargs:
return_to = kwargs.pop('return_to')
elif orig_request:
diff --git a/Allura/allura/controllers/error.py b/Allura/allura/controllers/error.py
index 682b46d..5cb26d0 100644
--- a/Allura/allura/controllers/error.py
+++ b/Allura/allura/controllers/error.py
@@ -29,7 +29,7 @@ class ErrorController(object):
@expose('jinja:allura:templates/error.html')
def document(self, *args, **kwargs):
"""Render the error document"""
- resp = request.environ.get('pylons.original_response')
+ resp = request.environ.get('tg.original_response')
code = -1
if resp:
code = resp.status_int
diff --git a/Allura/allura/controllers/rest.py b/Allura/allura/controllers/rest.py
index f654d0c..009b51c 100644
--- a/Allura/allura/controllers/rest.py
+++ b/Allura/allura/controllers/rest.py
@@ -140,11 +140,11 @@ class OAuthNegotiator(object):
request.environ.get('HTTP_X_FORWARDED_SSL') == 'on',
request.environ.get('HTTP_X_FORWARDED_PROTO') == 'https',
debug)):
- request.environ['pylons.status_code_redirect'] = True
+ request.environ['tg.status_code_redirect'] = True
raise exc.HTTPUnauthorized('HTTPS is required to use bearer tokens %s' % request.environ)
access_token = M.OAuthAccessToken.query.get(api_key=access_token)
if not (access_token and access_token.is_bearer):
- request.environ['pylons.status_code_redirect'] = True
+ request.environ['tg.status_code_redirect'] = True
raise exc.HTTPUnauthorized
return access_token
req = oauth.Request.from_request(
diff --git a/Allura/allura/lib/base.py b/Allura/allura/lib/base.py
index 374f85a..4c7a2d8 100644
--- a/Allura/allura/lib/base.py
+++ b/Allura/allura/lib/base.py
@@ -34,7 +34,7 @@ class WsgiDispatchController(TGController):
"""
def _setup_request(self):
- '''Responsible for setting all the values we need to be set on pylons.tmpl_context'''
+ '''Responsible for setting all the values we need to be set on tg.tmpl_context'''
raise NotImplementedError, '_setup_request'
def _perform_call(self, context):
diff --git a/Allura/allura/lib/custom_middleware.py b/Allura/allura/lib/custom_middleware.py
index 97b09e5..4f9ab57 100644
--- a/Allura/allura/lib/custom_middleware.py
+++ b/Allura/allura/lib/custom_middleware.py
@@ -24,7 +24,7 @@ import pkg_resources
from paste import fileapp
from paste.deploy.converters import aslist
from tg import tmpl_context as c
-from pylons.util import call_wsgi_application
+from tg.support.middlewares import _call_wsgi_application as call_wsgi_application
from timermiddleware import Timer, TimerMiddleware
from webob import exc, Request
import pysolr
@@ -149,8 +149,7 @@ class LoginRedirectMiddleware(object):
self.app = app
def __call__(self, environ, start_response):
- status, headers, app_iter, exc_info = call_wsgi_application(
- self.app, environ, catch_exc_info=True)
+ status, headers, app_iter, exc_info = call_wsgi_application(self.app, environ)
is_api_request = environ.get('PATH_INFO', '').startswith('/rest/')
if status[:3] == '401' and not is_api_request:
login_url = tg.config.get('auth.login_url', '/auth/')
@@ -247,8 +246,8 @@ class SSLMiddleware(object):
# allura-loggedin is a non-secure cookie as a flag to know that the user has a session over on https
force_ssl = (self._force_ssl_logged_in and req.cookies.get('allura-loggedin')) \
or self._force_ssl_re.match(environ['PATH_INFO'])
- if req.environ.get('pylons.original_request'):
- # if an error occurs, then /error/document is fetched (denoted by pylons.original_request)
+ if req.environ.get('tg.original_request'):
+ # if an error occurs, then /error/document is fetched (denoted by tg.original_request)
# and we don't want to do any redirects within that sub-request
pass
elif not secure and force_ssl:
diff --git a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py
index 59f286f..5d2b4b3 100644
--- a/Allura/allura/lib/utils.py
+++ b/Allura/allura/lib/utils.py
@@ -41,7 +41,7 @@ from collections import OrderedDict
from tg import redirect
from tg.decorators import before_validate
-from pylons.controllers.util import etag_cache
+from tg.controllers.util import etag_cache
from paste.deploy.converters import asbool, asint
from webhelpers.html import literal
from webob import exc
diff --git a/Allura/development.ini b/Allura/development.ini
index ed2cf50..7db097a 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -96,7 +96,7 @@ base_url = http://localhost:8080
; This should be updated each time you deploy (or make significant changes, like new tools, new css)
build_key=1276635823
-; Used by Turbogears / Pylons in some cases. Not particularly relevant for Allura.
+; Used by Turbogears in some cases. Not particularly relevant for Allura.
cache_dir = %(here)s/data
; Template cache settings
@@ -666,7 +666,7 @@ override_root = task ; TurboGears will use controllers/task.py as root controlle
; https://docs.python.org/2/library/logging.config.html#configuration-file-format
;
[loggers]
-keys = root, allura, sqlalchemy, paste, pylons, ew, taskdstatus, timermiddleware, tmw_details
+keys = root, allura, sqlalchemy, paste, ew, taskdstatus, timermiddleware, tmw_details
[handlers]
keys = console, stats, taskdstatus, timermiddleware
@@ -697,11 +697,6 @@ level = INFO
qualname = paste
handlers =
-[logger_pylons]
-level = INFO
-qualname = pylons
-handlers =
-
[logger_ew]
; easy widgets
level = WARN
diff --git a/Allura/docker-dev.ini b/Allura/docker-dev.ini
index 9842d9b..fd9e3e8 100644
--- a/Allura/docker-dev.ini
+++ b/Allura/docker-dev.ini
@@ -69,7 +69,7 @@ use = main
override_root = task ; TurboGears will use controllers/task.py as root controller
[loggers]
-keys = root, allura, sqlalchemy, paste, pylons, ew, taskdstatus, timermiddleware, tmw_details
+keys = root, allura, sqlalchemy, paste, ew, taskdstatus, timermiddleware, tmw_details
[handlers]
keys = console, stats, taskdstatus, timermiddleware
@@ -100,11 +100,6 @@ level = INFO
qualname = paste
handlers =
-[logger_pylons]
-level = INFO
-qualname = pylons
-handlers =
-
[logger_ew]
; easy widgets
level = WARN
diff --git a/Allura/docs/development/testing.rst b/Allura/docs/development/testing.rst
index 69e9c97..0aafb0f 100644
--- a/Allura/docs/development/testing.rst
+++ b/Allura/docs/development/testing.rst
@@ -54,8 +54,8 @@ provided by the `WebTest <http://pythonpaste.org/webtest/>`_ module, where you c
find further documentation for the `.get()` and `.post()` methods.
Testing Allura models is also straightforward, though you will often
-need to setup pylons global objects before your test. If the code under test
-uses pylons globals (like `g` and `c`), but your test doesn't require the
+need to setup global objects before your test. If the code under test
+uses globals (like `g` and `c`), but your test doesn't require the
fully-loaded wsgi app, you can do something like this:
.. code-block:: python
@@ -67,7 +67,7 @@ fully-loaded wsgi app, you can do something like this:
from allura import model as M
def setUp():
- # set up pylons globals
+ # set up globals
setup_unit_test()
# set c.project and c.app
diff --git a/Allura/docs/platform/platform_tour.rst b/Allura/docs/platform/platform_tour.rst
index 6726b89..af7236d 100644
--- a/Allura/docs/platform/platform_tour.rst
+++ b/Allura/docs/platform/platform_tour.rst
@@ -57,7 +57,7 @@ Discussion
The Context Object
------------------
-The Pylons "context" object `c` has several properties which are automatically
+The TurboGears "context" object `c` has several properties which are automatically
set for each request:
project
@@ -204,7 +204,7 @@ are of the form
:samp:`<topic>@<mount_point>[.<subproject>].<project>.mysite.com`.
When a message is received on such an email address, the address is parsed and
the sending user is identified (if possible). Based on the parsed address, the
-pylons context attributes `c.project` and `c.app` are set, and the application is
+TurboGears context attributes `c.project` and `c.app` are set, and the application is
queried to determine whether the identified user has authority to send an email
to the given app/topic combination by calling `c.app.has_access(user, topic)`.
If the user has access, the message is decomposed into its component parts (if a
diff --git a/Allura/production-docker-example.ini b/Allura/production-docker-example.ini
index f5f918d..26949b9 100644
--- a/Allura/production-docker-example.ini
+++ b/Allura/production-docker-example.ini
@@ -89,7 +89,7 @@ override_root = task ; TurboGears will use controllers/task.py as root controlle
[loggers]
-keys = root, allura, sqlalchemy, paste, pylons, ew, taskdstatus, timermiddleware, tmw_details
+keys = root, allura, sqlalchemy, paste, ew, taskdstatus, timermiddleware, tmw_details
[handlers]
keys = console, stats, taskdstatus, timermiddleware
@@ -120,11 +120,6 @@ level = INFO
qualname = paste
handlers =
-[logger_pylons]
-level = INFO
-qualname = pylons
-handlers =
-
[logger_ew]
; easy widgets
level = WARN
diff --git a/Allura/setup.cfg b/Allura/setup.cfg
index 0298938..527abf5 100644
--- a/Allura/setup.cfg
+++ b/Allura/setup.cfg
@@ -24,13 +24,6 @@ max-line-length = 119
[egg_info]
tag_build = dev0
-[easy_install]
-find_links = http://www.pylonshq.com/download/
-find_links = http://www.turbogears.org/2.1/downloads/current/index
-
-[nosetests]
-with-pylons=test.ini
-
# Babel configuration
[compile_catalog]
domain = allura
diff --git a/Allura/setup.py b/Allura/setup.py
index 4de3c6b..194c565 100644
--- a/Allura/setup.py
+++ b/Allura/setup.py
@@ -38,7 +38,7 @@ setup(
long_description=PROJECT_DESCRIPTION,
author='Allura Team',
url='https://allura.apache.org/',
- keywords='allura forge turbogears pylons jinja2 mongodb',
+ keywords='allura forge turbogears jinja2 mongodb',
license='Apache License, http://www.apache.org/licenses/LICENSE-2.0',
platforms=[
'Linux',
@@ -47,17 +47,15 @@ setup(
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Web Environment',
- 'Framework :: Pylons',
'Framework :: TurboGears',
'Intended Audience :: Developers',
- 'Programming Language :: Python :: 2.6',
+ 'Programming Language :: Python :: 2.7',
'Topic :: Internet :: WWW/HTTP :: WSGI :: Application',
'License :: OSI Approved :: Apache Software License',
],
install_requires=[
],
- setup_requires=["PasteScript >= 1.7"],
- paster_plugins=['PasteScript', 'Pylons', 'TurboGears2', 'Ming'],
+ paster_plugins=['PasteScript', 'TurboGears2', 'Ming'],
packages=find_packages(exclude=['ez_setup']),
include_package_data=True,
test_suite='nose.collector',
@@ -81,7 +79,8 @@ setup(
[paste.app_factory]
main = allura.config.middleware:make_app
[paste.app_install]
- main = pylons.util:PylonsInstaller
+ # used from SetupCommand, this will call our setup_app()
+ main = paste.script.appinstall:Installer
[allura]
profile = allura.ext.user_profile:UserProfileApp
diff --git a/AlluraTest/alluratest/controller.py b/AlluraTest/alluratest/controller.py
index 8bf7ab3..b9bc9e7 100644
--- a/AlluraTest/alluratest/controller.py
+++ b/AlluraTest/alluratest/controller.py
@@ -73,14 +73,9 @@ def get_config_file(config=None, current_pkg=None):
return conf_file
-
def setup_config_test(config_file=None, force=False):
'''
- This may be necessary to use within test setup that needs the app config loaded,
- especially so that the tests can be run from any directory.
- When run from the ./Allura/ dir, the setup.cfg file there causes a pylons plugin
- for nose to run, which runs `loadapp` (among other things).
- This function lets a test run from any directory.
+ This may be necessary to use within test setup that needs the app config loaded
'''
if not config_file:
config_file = get_config_file()
@@ -102,8 +97,18 @@ def setup_basic_test(config=None, app_name=DFL_APP_NAME):
except AttributeError:
conf_dir = os.getcwd()
test_file = os.path.join(conf_dir, get_config_file(config))
+ """
+ # setup our app, from TG quickstart example:
+ from tg.util import Bunch
+ from gearbox.commands.setup_app import SetupAppCommand
+ cmd = SetupAppCommand(Bunch(options=Bunch(verbose_level=1)), Bunch())
+ cmd.run(Bunch(config_file='config:{}'.format(test_file), section_name=None))
+ """
+ # setup our app without depending on gearbox (we still depend on Paste anyway)
+ # uses [paste.app_install] entry point which call our setup_app()
cmd = SetupCommand('setup-app')
cmd.run([test_file])
+
ew.TemplateEngine.initialize({})
# remove unnecessary bootstrap tasks, e.g. search indexing
diff --git a/ForgeWiki/forgewiki/tests/functional/test_rest.py b/ForgeWiki/forgewiki/tests/functional/test_rest.py
index 053d2a4..09c9b16 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_rest.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_rest.py
@@ -20,7 +20,6 @@
import json
from nose.tools import assert_equal, assert_in, assert_not_equal
-import simplejson
import tg
from allura.lib import helpers as h
@@ -116,7 +115,6 @@ class TestWikiApi(TestRestApiBase):
assert_equal(tg.jsonify.encode('<'), '"\u003C"')
# make sure these are unchanged
assert_equal(json.dumps('<'), '"<"')
- assert_equal(simplejson.dumps('<'), '"<"')
class TestWikiHasAccess(TestRestApiBase):
diff --git a/requirements.txt b/requirements.txt
index 67a0f49..557799d 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -70,10 +70,7 @@ backlash==0.1.4
crank==0.8.1
Mako==1.0.7
MarkupSafe==1.0
-Pylons==1.0.3
repoze.lru==0.7
-simplejson==3.16.0
-Tempita==0.5.1
Routes==2.4.1
WebHelpers==1.3