panther 4.3.3__tar.gz → 4.3.4__tar.gz

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.
Files changed (81) hide show
  1. {panther-4.3.3 → panther-4.3.4}/PKG-INFO +1 -1
  2. {panther-4.3.3 → panther-4.3.4}/panther/__init__.py +1 -1
  3. {panther-4.3.3 → panther-4.3.4}/panther/_load_configs.py +7 -0
  4. {panther-4.3.3 → panther-4.3.4}/panther/configs.py +4 -1
  5. {panther-4.3.3 → panther-4.3.4}/panther/response.py +2 -6
  6. {panther-4.3.3 → panther-4.3.4}/panther.egg-info/PKG-INFO +1 -1
  7. {panther-4.3.3 → panther-4.3.4}/LICENSE +0 -0
  8. {panther-4.3.3 → panther-4.3.4}/README.md +0 -0
  9. {panther-4.3.3 → panther-4.3.4}/panther/_utils.py +0 -0
  10. {panther-4.3.3 → panther-4.3.4}/panther/app.py +0 -0
  11. {panther-4.3.3 → panther-4.3.4}/panther/authentications.py +0 -0
  12. {panther-4.3.3 → panther-4.3.4}/panther/background_tasks.py +0 -0
  13. {panther-4.3.3 → panther-4.3.4}/panther/base_request.py +0 -0
  14. {panther-4.3.3 → panther-4.3.4}/panther/base_websocket.py +0 -0
  15. {panther-4.3.3 → panther-4.3.4}/panther/caching.py +0 -0
  16. {panther-4.3.3 → panther-4.3.4}/panther/cli/__init__.py +0 -0
  17. {panther-4.3.3 → panther-4.3.4}/panther/cli/create_command.py +0 -0
  18. {panther-4.3.3 → panther-4.3.4}/panther/cli/main.py +0 -0
  19. {panther-4.3.3 → panther-4.3.4}/panther/cli/monitor_command.py +0 -0
  20. {panther-4.3.3 → panther-4.3.4}/panther/cli/run_command.py +0 -0
  21. {panther-4.3.3 → panther-4.3.4}/panther/cli/template.py +0 -0
  22. {panther-4.3.3 → panther-4.3.4}/panther/cli/utils.py +0 -0
  23. {panther-4.3.3 → panther-4.3.4}/panther/db/__init__.py +0 -0
  24. {panther-4.3.3 → panther-4.3.4}/panther/db/connections.py +0 -0
  25. {panther-4.3.3 → panther-4.3.4}/panther/db/cursor.py +0 -0
  26. {panther-4.3.3 → panther-4.3.4}/panther/db/models.py +0 -0
  27. {panther-4.3.3 → panther-4.3.4}/panther/db/queries/__init__.py +0 -0
  28. {panther-4.3.3 → panther-4.3.4}/panther/db/queries/base_queries.py +0 -0
  29. {panther-4.3.3 → panther-4.3.4}/panther/db/queries/mongodb_queries.py +0 -0
  30. {panther-4.3.3 → panther-4.3.4}/panther/db/queries/pantherdb_queries.py +0 -0
  31. {panther-4.3.3 → panther-4.3.4}/panther/db/queries/queries.py +0 -0
  32. {panther-4.3.3 → panther-4.3.4}/panther/db/utils.py +0 -0
  33. {panther-4.3.3 → panther-4.3.4}/panther/events.py +0 -0
  34. {panther-4.3.3 → panther-4.3.4}/panther/exceptions.py +0 -0
  35. {panther-4.3.3 → panther-4.3.4}/panther/file_handler.py +0 -0
  36. {panther-4.3.3 → panther-4.3.4}/panther/generics.py +0 -0
  37. {panther-4.3.3 → panther-4.3.4}/panther/logging.py +0 -0
  38. {panther-4.3.3 → panther-4.3.4}/panther/main.py +0 -0
  39. {panther-4.3.3 → panther-4.3.4}/panther/middlewares/__init__.py +0 -0
  40. {panther-4.3.3 → panther-4.3.4}/panther/middlewares/base.py +0 -0
  41. {panther-4.3.3 → panther-4.3.4}/panther/monitoring.py +0 -0
  42. {panther-4.3.3 → panther-4.3.4}/panther/pagination.py +0 -0
  43. {panther-4.3.3 → panther-4.3.4}/panther/panel/__init__.py +0 -0
  44. {panther-4.3.3 → panther-4.3.4}/panther/panel/apis.py +0 -0
  45. {panther-4.3.3 → panther-4.3.4}/panther/panel/urls.py +0 -0
  46. {panther-4.3.3 → panther-4.3.4}/panther/panel/utils.py +0 -0
  47. {panther-4.3.3 → panther-4.3.4}/panther/permissions.py +0 -0
  48. {panther-4.3.3 → panther-4.3.4}/panther/request.py +0 -0
  49. {panther-4.3.3 → panther-4.3.4}/panther/routings.py +0 -0
  50. {panther-4.3.3 → panther-4.3.4}/panther/serializer.py +0 -0
  51. {panther-4.3.3 → panther-4.3.4}/panther/status.py +0 -0
  52. {panther-4.3.3 → panther-4.3.4}/panther/test.py +0 -0
  53. {panther-4.3.3 → panther-4.3.4}/panther/throttling.py +0 -0
  54. {panther-4.3.3 → panther-4.3.4}/panther/utils.py +0 -0
  55. {panther-4.3.3 → panther-4.3.4}/panther/websocket.py +0 -0
  56. {panther-4.3.3 → panther-4.3.4}/panther.egg-info/SOURCES.txt +0 -0
  57. {panther-4.3.3 → panther-4.3.4}/panther.egg-info/dependency_links.txt +0 -0
  58. {panther-4.3.3 → panther-4.3.4}/panther.egg-info/entry_points.txt +0 -0
  59. {panther-4.3.3 → panther-4.3.4}/panther.egg-info/requires.txt +0 -0
  60. {panther-4.3.3 → panther-4.3.4}/panther.egg-info/top_level.txt +0 -0
  61. {panther-4.3.3 → panther-4.3.4}/pyproject.toml +0 -0
  62. {panther-4.3.3 → panther-4.3.4}/setup.cfg +0 -0
  63. {panther-4.3.3 → panther-4.3.4}/setup.py +0 -0
  64. {panther-4.3.3 → panther-4.3.4}/tests/test_authentication.py +0 -0
  65. {panther-4.3.3 → panther-4.3.4}/tests/test_background_tasks.py +0 -0
  66. {panther-4.3.3 → panther-4.3.4}/tests/test_caching.py +0 -0
  67. {panther-4.3.3 → panther-4.3.4}/tests/test_cli.py +0 -0
  68. {panther-4.3.3 → panther-4.3.4}/tests/test_database.py +0 -0
  69. {panther-4.3.3 → panther-4.3.4}/tests/test_events.py +0 -0
  70. {panther-4.3.3 → panther-4.3.4}/tests/test_generics.py +0 -0
  71. {panther-4.3.3 → panther-4.3.4}/tests/test_multipart.py +0 -0
  72. {panther-4.3.3 → panther-4.3.4}/tests/test_panel_apis.py +0 -0
  73. {panther-4.3.3 → panther-4.3.4}/tests/test_request.py +0 -0
  74. {panther-4.3.3 → panther-4.3.4}/tests/test_response.py +0 -0
  75. {panther-4.3.3 → panther-4.3.4}/tests/test_routing.py +0 -0
  76. {panther-4.3.3 → panther-4.3.4}/tests/test_run.py +0 -0
  77. {panther-4.3.3 → panther-4.3.4}/tests/test_serializer.py +0 -0
  78. {panther-4.3.3 → panther-4.3.4}/tests/test_status.py +0 -0
  79. {panther-4.3.3 → panther-4.3.4}/tests/test_throttling.py +0 -0
  80. {panther-4.3.3 → panther-4.3.4}/tests/test_utils.py +0 -0
  81. {panther-4.3.3 → panther-4.3.4}/tests/test_websockets.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: panther
3
- Version: 4.3.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
@@ -1,6 +1,6 @@
1
1
  from panther.main import Panther # noqa: F401
2
2
 
3
- __version__ = '4.3.3'
3
+ __version__ = '4.3.4'
4
4
 
5
5
 
6
6
  def version():
@@ -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', {})
@@ -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': 'templates',
116
+ 'TEMPLATES_DIR': '.',
117
+ 'JINJA_ENVIRONMENT': None,
115
118
  'AUTO_REFORMAT': False,
116
119
  'QUERY_ENGINE': None,
117
120
  'DATABASE': None,
@@ -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,7 +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
- if not context:
253
- context = {}
254
- template = self.environment.get_template(path) if path is not None else self.environment.from_string(source)
255
- 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
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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes