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 2026/07/06 14:00:31 UTC
(allura) 03/03: [#8612] remove some Paste usage: keeping paste.exceptions.errormiddleware.ErrorMiddleware, has no replacement. Keeping PasteDeploy
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch db/8612
in repository https://gitbox.apache.org/repos/asf/allura.git
commit 60c6428f467737552a58e613457faa4e8a581e50
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Fri Jul 3 11:16:28 2026 -0400
[#8612] remove some Paste usage: keeping paste.exceptions.errormiddleware.ErrorMiddleware, has no replacement. Keeping PasteDeploy
---
Allura/allura/controllers/rest.py | 2 +-
Allura/allura/lib/custom_middleware.py | 17 ++++++++++++-----
Allura/allura/scripts/refreshrepo.py | 2 +-
Allura/allura/tests/functional/test_neighborhood.py | 2 +-
requirements.in | 1 +
5 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/Allura/allura/controllers/rest.py b/Allura/allura/controllers/rest.py
index 267855329..b0dbe2e95 100644
--- a/Allura/allura/controllers/rest.py
+++ b/Allura/allura/controllers/rest.py
@@ -25,7 +25,7 @@
import oauthlib.oauth1
import oauthlib.oauth2
import oauthlib.common
-from paste.util.converters import asbool
+from paste.deploy.converters import asbool
from webob import exc
import tg
from tg import expose, flash, redirect, config
diff --git a/Allura/allura/lib/custom_middleware.py b/Allura/allura/lib/custom_middleware.py
index 5767f4ea7..03e1d60f5 100644
--- a/Allura/allura/lib/custom_middleware.py
+++ b/Allura/allura/lib/custom_middleware.py
@@ -20,11 +20,11 @@
import logging
import tg
-from paste import fileapp
from paste.deploy.converters import aslist, asbool
from tg import tmpl_context as c
from timermiddleware import Timer, TimerMiddleware
from webob import exc, Request, Response
+from webob.static import FileApp
import pysolr
import six
from ming.odm import session
@@ -61,10 +61,14 @@ def __call__(self, environ, start_response):
environ['static.script_name'] = self.script_name
if not environ['PATH_INFO'].startswith(self.script_name):
return self.app(environ, start_response)
+
+ def start_response_with_headers(status, headers, exc_info=None):
+ headers.append(('Access-Control-Allow-Origin', '*'))
+ return start_response(status, headers, exc_info)
+
try:
app = self.get_app(environ)
- app.cache_control(public=True, max_age=self.CACHE_MAX_AGE)
- return app(environ, start_response)
+ return app(environ, start_response_with_headers)
except OSError:
return exc.HTTPNotFound()(environ, start_response)
@@ -79,10 +83,13 @@ def get_app(self, environ):
if resource_cls:
package = resource_cls.__module__.split(".")[0]
file_path = pkg_file(package, resource_path)
- return fileapp.FileApp(file_path, [('Access-Control-Allow-Origin', '*')])
+ return self.file_app(file_path)
filename = environ['PATH_INFO'][len(self.script_name):]
file_path = pkg_file('allura', 'public/nf', filename)
- return fileapp.FileApp(file_path, [('Access-Control-Allow-Origin', '*')])
+ return self.file_app(file_path)
+
+ def file_app(self, file_path: str) -> FileApp:
+ return FileApp(file_path, cache_control=f'public, max-age={self.CACHE_MAX_AGE}')
class CORSMiddleware:
diff --git a/Allura/allura/scripts/refreshrepo.py b/Allura/allura/scripts/refreshrepo.py
index af5bee954..e66ef44e3 100644
--- a/Allura/allura/scripts/refreshrepo.py
+++ b/Allura/allura/scripts/refreshrepo.py
@@ -20,7 +20,7 @@
import faulthandler
from datetime import datetime
-from paste.util.converters import asbool
+from paste.deploy.converters import asbool
from tg import tmpl_context as c
from ming.odm import ThreadLocalODMSession
diff --git a/Allura/allura/tests/functional/test_neighborhood.py b/Allura/allura/tests/functional/test_neighborhood.py
index 87dcf3954..294d37a12 100644
--- a/Allura/allura/tests/functional/test_neighborhood.py
+++ b/Allura/allura/tests/functional/test_neighborhood.py
@@ -26,7 +26,7 @@
from mock import patch
from tg import config
from ming.odm.odmsession import ThreadLocalODMSession, session
-from paste.httpexceptions import HTTPFound, HTTPMovedPermanently
+from webob.exc import HTTPFound, HTTPMovedPermanently
from tg import app_globals as g, tmpl_context as c
import allura
diff --git a/requirements.in b/requirements.in
index 1208a8f6c..15d67dd3d 100644
--- a/requirements.in
+++ b/requirements.in
@@ -29,6 +29,7 @@ Ming
oauthlib
paginate
passlib
+# Paste is only used for paste.exceptions.errormiddleware now (also a dependency of EasyWidgets)
Paste
PasteDeploy
Pillow