mirror of
https://gitlab.com/tildes/tildes.git
synced 2026-04-17 14:59:11 +02:00
Move tween config into tween module
This commit is contained in:
@@ -32,6 +32,7 @@ def main(global_config: Dict[str, str], **settings: str) -> PrefixMiddleware:
|
||||
config.include("tildes.jinja")
|
||||
config.include("tildes.json")
|
||||
config.include("tildes.routes")
|
||||
config.include("tildes.tweens")
|
||||
|
||||
config.add_webasset("javascript", Bundle(output="js/tildes.js"))
|
||||
config.add_webasset("javascript-third-party", Bundle(output="js/third_party.js"))
|
||||
@@ -39,10 +40,6 @@ def main(global_config: Dict[str, str], **settings: str) -> PrefixMiddleware:
|
||||
|
||||
config.scan("tildes.views")
|
||||
|
||||
config.add_tween("tildes.tweens.http_method_tween_factory")
|
||||
config.add_tween("tildes.tweens.metrics_tween_factory")
|
||||
config.add_tween("tildes.tweens.theme_cookie_tween_factory")
|
||||
|
||||
config.add_static_view("images", "/images")
|
||||
|
||||
config.add_request_method(is_safe_request_method, "is_safe_method", reify=True)
|
||||
|
||||
@@ -7,6 +7,7 @@ from time import time
|
||||
from typing import Callable
|
||||
|
||||
from prometheus_client import Histogram
|
||||
from pyramid.config import Configurator
|
||||
from pyramid.registry import Registry
|
||||
from pyramid.request import Request
|
||||
from pyramid.response import Response
|
||||
@@ -115,3 +116,10 @@ def theme_cookie_tween_factory(handler: Callable, registry: Registry) -> Callabl
|
||||
return response
|
||||
|
||||
return theme_cookie_tween
|
||||
|
||||
|
||||
def includeme(config: Configurator) -> None:
|
||||
"""Attach Tildes tweens to the Pyramid config."""
|
||||
config.add_tween("tildes.tweens.http_method_tween_factory")
|
||||
config.add_tween("tildes.tweens.metrics_tween_factory")
|
||||
config.add_tween("tildes.tweens.theme_cookie_tween_factory")
|
||||
|
||||
Reference in New Issue
Block a user