panther 4.3.2__py3-none-any.whl → 4.3.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- panther/__init__.py +1 -1
- panther/_load_configs.py +7 -0
- panther/configs.py +4 -1
- panther/response.py +2 -5
- {panther-4.3.2.dist-info → panther-4.3.4.dist-info}/METADATA +5 -2
- {panther-4.3.2.dist-info → panther-4.3.4.dist-info}/RECORD +10 -10
- {panther-4.3.2.dist-info → panther-4.3.4.dist-info}/WHEEL +1 -1
- {panther-4.3.2.dist-info → panther-4.3.4.dist-info}/LICENSE +0 -0
- {panther-4.3.2.dist-info → panther-4.3.4.dist-info}/entry_points.txt +0 -0
- {panther-4.3.2.dist-info → panther-4.3.4.dist-info}/top_level.txt +0 -0
panther/__init__.py
CHANGED
panther/_load_configs.py
CHANGED
@@ -4,6 +4,8 @@ import types
|
|
4
4
|
from importlib import import_module
|
5
5
|
from multiprocessing import Manager
|
6
6
|
|
7
|
+
import jinja2
|
8
|
+
|
7
9
|
from panther._utils import import_class, check_function_type_endpoint, check_class_type_endpoint
|
8
10
|
from panther.background_tasks import background_tasks
|
9
11
|
from panther.base_websocket import WebsocketConnections
|
@@ -89,6 +91,11 @@ def load_templates_dir(_configs: dict, /) -> None:
|
|
89
91
|
if templates_dir := _configs.get('TEMPLATES_DIR'):
|
90
92
|
config.TEMPLATES_DIR = templates_dir
|
91
93
|
|
94
|
+
if config.TEMPLATES_DIR == '.':
|
95
|
+
config.TEMPLATES_DIR = config.BASE_DIR
|
96
|
+
|
97
|
+
config.JINJA_ENVIRONMENT = jinja2.Environment(loader=jinja2.FileSystemLoader(config.TEMPLATES_DIR))
|
98
|
+
|
92
99
|
|
93
100
|
def load_database(_configs: dict, /) -> None:
|
94
101
|
database_config = _configs.get('DATABASE', {})
|
panther/configs.py
CHANGED
@@ -5,6 +5,7 @@ from datetime import timedelta
|
|
5
5
|
from pathlib import Path
|
6
6
|
from typing import Callable
|
7
7
|
|
8
|
+
import jinja2
|
8
9
|
from pydantic._internal._model_construction import ModelMetaclass
|
9
10
|
|
10
11
|
from panther.throttling import Throttling
|
@@ -68,6 +69,7 @@ class Config:
|
|
68
69
|
SHUTDOWNS: list[Callable]
|
69
70
|
TIMEZONE: str
|
70
71
|
TEMPLATES_DIR: str | list[str]
|
72
|
+
JINJA_ENVIRONMENT: jinja2.Environment | None
|
71
73
|
AUTO_REFORMAT: bool
|
72
74
|
QUERY_ENGINE: typing.Callable | None
|
73
75
|
DATABASE: typing.Callable | None
|
@@ -111,7 +113,8 @@ default_configs = {
|
|
111
113
|
'STARTUPS': [],
|
112
114
|
'SHUTDOWNS': [],
|
113
115
|
'TIMEZONE': 'UTC',
|
114
|
-
'TEMPLATES_DIR': '
|
116
|
+
'TEMPLATES_DIR': '.',
|
117
|
+
'JINJA_ENVIRONMENT': None,
|
115
118
|
'AUTO_REFORMAT': False,
|
116
119
|
'QUERY_ENGINE': None,
|
117
120
|
'DATABASE': None,
|
panther/response.py
CHANGED
@@ -229,8 +229,6 @@ class PlainTextResponse(Response):
|
|
229
229
|
|
230
230
|
|
231
231
|
class TemplateResponse(HTMLResponse):
|
232
|
-
environment = Environment(loader=FileSystemLoader(config.TEMPLATES_DIR))
|
233
|
-
|
234
232
|
def __init__(
|
235
233
|
self,
|
236
234
|
source: str | LiteralString | NoneType = None,
|
@@ -249,6 +247,5 @@ class TemplateResponse(HTMLResponse):
|
|
249
247
|
:param pagination: instance of Pagination or None
|
250
248
|
Its template() method will be used
|
251
249
|
"""
|
252
|
-
|
253
|
-
template
|
254
|
-
super().__init__(template.render(context), headers, status_code, pagination=pagination)
|
250
|
+
template = config.JINJA_ENVIRONMENT.get_template(path) if path is not None else config.JINJA_ENVIRONMENT.from_string(source)
|
251
|
+
super().__init__(template.render(context or {}), headers, status_code, pagination=pagination)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: panther
|
3
|
-
Version: 4.3.
|
3
|
+
Version: 4.3.4
|
4
4
|
Summary: Fast & Friendly, Web Framework For Building Async APIs
|
5
5
|
Home-page: https://github.com/alirn76/panther
|
6
6
|
Author: Ali RajabNezhad
|
@@ -21,12 +21,15 @@ Requires-Dist: uvicorn~=0.27.1
|
|
21
21
|
Requires-Dist: pytz~=2024.1
|
22
22
|
Requires-Dist: Jinja2~=3.1
|
23
23
|
Requires-Dist: httptools~=0.6.1
|
24
|
+
Provides-Extra: dev
|
25
|
+
Requires-Dist: ruff~=0.1.9; extra == "dev"
|
26
|
+
Requires-Dist: pytest~=8.3.3; extra == "dev"
|
24
27
|
Provides-Extra: full
|
25
28
|
Requires-Dist: redis==5.0.1; extra == "full"
|
26
29
|
Requires-Dist: motor~=3.5.0; extra == "full"
|
27
30
|
Requires-Dist: bpython~=0.24; extra == "full"
|
28
|
-
Requires-Dist: ruff~=0.1.9; extra == "full"
|
29
31
|
Requires-Dist: python-jose~=3.3.0; extra == "full"
|
32
|
+
Requires-Dist: ruff~=0.1.9; extra == "full"
|
30
33
|
Requires-Dist: websockets~=12.0; extra == "full"
|
31
34
|
Requires-Dist: cryptography~=42.0.8; extra == "full"
|
32
35
|
Requires-Dist: watchfiles~=0.21.0; extra == "full"
|
@@ -1,5 +1,5 @@
|
|
1
|
-
panther/__init__.py,sha256=
|
2
|
-
panther/_load_configs.py,sha256=
|
1
|
+
panther/__init__.py,sha256=pi--vX1J1xQHzhNFeCOc2PFlgcN6A952z5Na058Avng,110
|
2
|
+
panther/_load_configs.py,sha256=tVzUB8WqwkOcsRbs1T4vhaKICPbDlXelr5h7LVdVupU,10079
|
3
3
|
panther/_utils.py,sha256=R1tsUde1zA5iJtk-ZvWe8hp6JaNhKgNoH2rxpdiQDMc,4449
|
4
4
|
panther/app.py,sha256=e2eb4sXIaBje5vpcm4pbvvEO_sj83pLfBHCIZJFFX38,8222
|
5
5
|
panther/authentications.py,sha256=gf7BVyQ8vXKhiumJAtD0aAK7uIHWx_snbOKYAKrYuVw,5677
|
@@ -7,7 +7,7 @@ panther/background_tasks.py,sha256=HBYubDIiO_673cl_5fqCUP9zzimzRgRkDSkag9Msnbs,7
|
|
7
7
|
panther/base_request.py,sha256=XD2v1gLWcCKHePowRxT6_fYnS4tdKFxTLINMX0HQu8M,3880
|
8
8
|
panther/base_websocket.py,sha256=L0tiQQjg7E3462cd91PMf_SoVMMK4YiwW45yTFdTLhY,10973
|
9
9
|
panther/caching.py,sha256=ltuJYdjNiAaKIs3jpO5EBpL8Y6CF1vAIQqh8J_Np10g,4098
|
10
|
-
panther/configs.py,sha256=
|
10
|
+
panther/configs.py,sha256=0VmXWFnktMGUI8X8o2xoC92872OS1G9ohAzRcvQSD2U,3329
|
11
11
|
panther/events.py,sha256=bxDqrfiNNBlvD03vEk2LDK4xbMzTMFVcgAjx2ein7mI,1158
|
12
12
|
panther/exceptions.py,sha256=7rHdJIES2__kqOStIqbHl3Uxask2lzKgLQlkZvvDwFA,1591
|
13
13
|
panther/file_handler.py,sha256=I94tpbtTVniBnnUMkFr3Eis6kPDt8sLzS5u8TzFrR5I,1323
|
@@ -18,7 +18,7 @@ panther/monitoring.py,sha256=y1F3c8FJlnmooM-m1nSyOTa9eWq0v1nHnmw9zz-4Kls,1314
|
|
18
18
|
panther/pagination.py,sha256=ANJrEF0q1nVAfD33I4nZfUUxFcETzJb01gIhbZX3HEw,1639
|
19
19
|
panther/permissions.py,sha256=9-J5vzvEKa_PITwEVQbZZv8PG2FOu05YBlD5yMrKcfc,348
|
20
20
|
panther/request.py,sha256=F9ZiAWSse7_6moAzqdoFInUN4zTKlzijh9AdU9w3Jfw,1673
|
21
|
-
panther/response.py,sha256=
|
21
|
+
panther/response.py,sha256=vcKyhpjdKNNw8iksTfGSeDO3VJ6_TgvwzIOfmHAdGIc,8794
|
22
22
|
panther/routings.py,sha256=1eqbjubLnUUEQRlz8mIF464ImvCMjyasiekHBtxEQoQ,6218
|
23
23
|
panther/serializer.py,sha256=5O5dypP9ys0qTKrjwaXONmOqCfDHoXY1q5ajsirFjM8,9083
|
24
24
|
panther/status.py,sha256=Gc_PnYrHfInTsZpGbqiCfDB-py1C7Rh8KMdb6Lq9Exs,3346
|
@@ -49,9 +49,9 @@ panther/panel/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
49
49
|
panther/panel/apis.py,sha256=COsbwKZyTgyHvHYbpDfusifAH9ojMS3z1KhZCt9M-Ms,2428
|
50
50
|
panther/panel/urls.py,sha256=JiV-H4dWE-m_bfaTTVxzOxTvJmOWhyLOvcbM7xU3Bn4,240
|
51
51
|
panther/panel/utils.py,sha256=0Rv79oR5IEqalqwpRKQHMn1p5duVY5mxMqDKiA5mWx4,437
|
52
|
-
panther-4.3.
|
53
|
-
panther-4.3.
|
54
|
-
panther-4.3.
|
55
|
-
panther-4.3.
|
56
|
-
panther-4.3.
|
57
|
-
panther-4.3.
|
52
|
+
panther-4.3.4.dist-info/LICENSE,sha256=2aF1hL2aC0zRPjzUkSxJUzZbn2_uLoOkn7DHjzZni-I,1524
|
53
|
+
panther-4.3.4.dist-info/METADATA,sha256=1qZpoxF1s8VPGSwg14Mq24lTKFpg4Txjl0lNHogW93o,6695
|
54
|
+
panther-4.3.4.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
55
|
+
panther-4.3.4.dist-info/entry_points.txt,sha256=6GPxYFGuzVfNB4YpHFJvYex6iWah5_tLnirAHwj2Qsg,51
|
56
|
+
panther-4.3.4.dist-info/top_level.txt,sha256=VbBs02JGXTIoHMzsX-eLOk2MCbBZzQbLhWiYpI7xI2g,8
|
57
|
+
panther-4.3.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|