panther 4.1.3__py3-none-any.whl → 4.2.0__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 CHANGED
@@ -1,6 +1,6 @@
1
1
  from panther.main import Panther # noqa: F401
2
2
 
3
- __version__ = '4.1.3'
3
+ __version__ = '4.2.0'
4
4
 
5
5
 
6
6
  def version():
panther/app.py CHANGED
@@ -60,6 +60,10 @@ class API:
60
60
  async def wrapper(request: Request) -> Response:
61
61
  self.request = request
62
62
 
63
+ # 0. Preflight
64
+ if self.request.method == 'OPTIONS':
65
+ return self.options()
66
+
63
67
  # 1. Check Method
64
68
  if self.methods and self.request.method not in self.methods:
65
69
  raise MethodNotAllowedAPIError
@@ -141,6 +145,14 @@ class API:
141
145
  if self.input_model:
142
146
  self.request.validated_data = self.validate_input(model=self.input_model, request=self.request)
143
147
 
148
+ @classmethod
149
+ def options(cls):
150
+ headers = {
151
+ 'Access-Control-Allow-Methods': 'DELETE, GET, PATCH, POST, PUT, OPTIONS',
152
+ 'Access-Control-Allow-Headers': 'Accept, Authorization, User-Agent, Content-Type',
153
+ }
154
+ return Response(headers=headers)
155
+
144
156
  @classmethod
145
157
  def validate_input(cls, model, request: Request):
146
158
  if isinstance(request.data, bytes):
@@ -199,6 +211,8 @@ class GenericAPI:
199
211
  func = self.patch
200
212
  case 'DELETE':
201
213
  func = self.delete
214
+ case 'OPTIONS':
215
+ func = API.options
202
216
  case _:
203
217
  raise MethodNotAllowedAPIError
204
218
 
panther/base_request.py CHANGED
@@ -1,5 +1,6 @@
1
1
  from collections import namedtuple
2
2
  from collections.abc import Callable
3
+ from urllib.parse import parse_qsl
3
4
 
4
5
  from panther.db import Model
5
6
  from panther.exceptions import InvalidPathVariableAPIError
@@ -74,11 +75,7 @@ class BaseRequest:
74
75
  @property
75
76
  def query_params(self) -> dict:
76
77
  if self._params is None:
77
- self._params = {}
78
- if (query_string := self.scope['query_string']) != b'':
79
- for param in query_string.decode('utf-8').split('&'):
80
- k, *_, v = param.split('=')
81
- self._params[k] = v
78
+ self._params = {k: v for k, v in parse_qsl(self.scope['query_string'].decode('utf-8'))}
82
79
  return self._params
83
80
 
84
81
  @property
@@ -61,7 +61,7 @@ class CreateProject:
61
61
  },
62
62
  {
63
63
  'field': 'database',
64
- 'message': ' 0: PantherDB (File-Base, No Requirements)\n 1: MongoDB (Required `pymongo`)\n 2: No Database\nChoose Your Database (default is 0)',
64
+ 'message': ' 0: PantherDB (File-Base, No Requirements)\n 1: MongoDB (Required `motor`)\n 2: No Database\nChoose Your Database (default is 0)',
65
65
  'validation_func': lambda x: x in ['0', '1', '2'],
66
66
  'error_message': "Invalid Choice, '{}' not in ['0', '1', '2']",
67
67
  },
panther/cli/template.py CHANGED
@@ -140,6 +140,7 @@ InfoThrottling = Throttling(rate=5, duration=timedelta(minutes=1))
140
140
 
141
141
  TIMEZONE = 'UTC'
142
142
 
143
+
143
144
  @API()
144
145
  async def hello_world_api():
145
146
  return {'detail': 'Hello World'}
@@ -61,7 +61,7 @@ class BaseMongoDBQuery(BaseQuery):
61
61
 
62
62
  @classmethod
63
63
  async def aggregate(cls, pipeline: Sequence[dict]) -> Iterable[dict]:
64
- return await db.session[cls.__name__].aggregate(pipeline)
64
+ return await db.session[cls.__name__].aggregate(pipeline).to_list(None)
65
65
 
66
66
  # # # # # Count # # # # #
67
67
  @classmethod
panther/db/utils.py CHANGED
@@ -54,5 +54,5 @@ def _convert_to_object_id(_id):
54
54
  try:
55
55
  return bson.ObjectId(_id)
56
56
  except bson.objectid.InvalidId:
57
- msg = f'id={_id} is invalid bson.ObjectId'
58
- raise bson.errors.InvalidId(msg)
57
+ logger.warning(f'id={_id} is not a valid bson.ObjectId')
58
+ return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: panther
3
- Version: 4.1.3
3
+ Version: 4.2.0
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,10 +1,10 @@
1
- panther/__init__.py,sha256=QrE4JPnhuhmVTr9unHaojWSt5hVyBwmbJq26yQOSFx8,110
1
+ panther/__init__.py,sha256=sduiFCRbp6Nv6i1LB-sOh5Eb8lOJMR-Plz6Th79QwCs,110
2
2
  panther/_load_configs.py,sha256=AVkoixkUFkBQiTmrLrwCmg0eiPW2U_Uw2EGNEGQRfnI,9281
3
3
  panther/_utils.py,sha256=j0rwIxTf0rtcZAAD-1nGE-_bWpvinyKtnwt3uO0hMmY,4330
4
- panther/app.py,sha256=uoJFc058fiuIu6JWIkpPOpYQ4e9Gcu1iZl7VYxaZf7M,7752
4
+ panther/app.py,sha256=e2eb4sXIaBje5vpcm4pbvvEO_sj83pLfBHCIZJFFX38,8222
5
5
  panther/authentications.py,sha256=gf7BVyQ8vXKhiumJAtD0aAK7uIHWx_snbOKYAKrYuVw,5677
6
6
  panther/background_tasks.py,sha256=HBYubDIiO_673cl_5fqCUP9zzimzRgRkDSkag9Msnbs,7656
7
- panther/base_request.py,sha256=Fwwpm-9bjAZdpzSdakmSas5BD3gh1nrc6iGcBxwa_94,4001
7
+ panther/base_request.py,sha256=XD2v1gLWcCKHePowRxT6_fYnS4tdKFxTLINMX0HQu8M,3880
8
8
  panther/base_websocket.py,sha256=iJUIbrfnh3ZLXlmKxTswMw158eNvtBFi8RZ-aBBmc8w,10643
9
9
  panther/caching.py,sha256=ltuJYdjNiAaKIs3jpO5EBpL8Y6CF1vAIQqh8J_Np10g,4098
10
10
  panther/configs.py,sha256=EaLApT6nYcguBoNXBG_8n6DU6HTNxsulI2943j8UAkE,3174
@@ -27,20 +27,20 @@ panther/throttling.py,sha256=mVa_mGv6w_Ad7LLtV4eG5QpDwwNsk4QjFFi0mIHQBnE,231
27
27
  panther/utils.py,sha256=Iq5q1suIgBBQGO5UctwR4HXs8E6zclXNh5lYc8k1Vjg,3409
28
28
  panther/websocket.py,sha256=5WLw--Oa-6kGYbeRvO79hjbd0ARFcTTF40-hO_bdjmQ,1206
29
29
  panther/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
- panther/cli/create_command.py,sha256=cVhz0VQOvEbpufFsevH9T1rYZ8T_Wsa89cpTiIVKTC0,10294
30
+ panther/cli/create_command.py,sha256=mT5GFzsTYZbzqShNHlw_UIkMcWLw9btm2mTwcg7TlfI,10292
31
31
  panther/cli/main.py,sha256=pCqnOTazgMhTvFHTugutIsiFXueU5kx2VmGngwAl54Q,1679
32
32
  panther/cli/monitor_command.py,sha256=7N1-4W0Lu7yl5maehJowe04WH4nxZ1DumGDRATh82SQ,3139
33
33
  panther/cli/run_command.py,sha256=yWcDoWC-c4ph4M5EDj0jvR9xSjh-apG5r6-NpDdArUo,2195
34
- panther/cli/template.py,sha256=rsyKOQ0l2v3kdwmLiZxt5ecIhDzmFprCCv0uVAv7eQI,5319
34
+ panther/cli/template.py,sha256=hVkY1A3HZDVGEZzRkMtYte6FagKGTAxoFeG0wot7Zn4,5320
35
35
  panther/cli/utils.py,sha256=Jd4YQ9H6lapVktl7ZmiORt30WVmKI85xcwsY-fMRq3c,5289
36
36
  panther/db/__init__.py,sha256=w9lEL0vRqb18Qx_iUJipUR_fi5GQ5uVX0DWycx14x08,50
37
37
  panther/db/connections.py,sha256=rps48Ic2r3SV2HD3df1OU7C4Pv8j98PVXU1O_FqF9Ak,4210
38
38
  panther/db/cursor.py,sha256=jJ6bhz_Zljt3-AoeVdi563e2q3MSDJPP33WVbQk-goE,1287
39
39
  panther/db/models.py,sha256=GRbKXJiwnxQJ_SjuPfXPzA5miH_djZNTPPyqiRp5DI8,2561
40
- panther/db/utils.py,sha256=Uxh7UebkBv4thMCfooYW1pkuorFgocsbnBZJi-hHtdY,1582
40
+ panther/db/utils.py,sha256=frSekBisjeHUHTiucgeiJNOGdrNcf3mjodupyeZjyKk,1575
41
41
  panther/db/queries/__init__.py,sha256=uF4gvBjLBJ-Yl3WLqoZEVNtHCVhFRKW3_Vi44pJxDNI,45
42
42
  panther/db/queries/base_queries.py,sha256=8HhdlsSW-lgz3-IrZYfOtHNC3TBWbCNErDR4XE718AY,3764
43
- panther/db/queries/mongodb_queries.py,sha256=AUteqnQdqjM3axYahOLDuxrYxgI-hQa72aXcoJx9ItU,5585
43
+ panther/db/queries/mongodb_queries.py,sha256=4CQRdmgmKFIpnv6xijS0BMJO-Sf5beyuzmw8Z9jLtnA,5599
44
44
  panther/db/queries/pantherdb_queries.py,sha256=_dA4gXk1IA5jzIy6_6o1zgdZeeka6SPihvQeSkj7h68,4481
45
45
  panther/db/queries/queries.py,sha256=d6V4whHEYjtufoeqIC5lBNa_FGDW8_7AYeps48ilHDk,11665
46
46
  panther/middlewares/__init__.py,sha256=ydo0bSadGqa2v7Xy1oCTkF2uXrImedXjiyx2vPTwPhE,66
@@ -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.1.3.dist-info/LICENSE,sha256=2aF1hL2aC0zRPjzUkSxJUzZbn2_uLoOkn7DHjzZni-I,1524
53
- panther-4.1.3.dist-info/METADATA,sha256=Fbqyl-q10f5RgrsihqeoywGlRIITbjX3C8vtZi7mQpA,6376
54
- panther-4.1.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
55
- panther-4.1.3.dist-info/entry_points.txt,sha256=6GPxYFGuzVfNB4YpHFJvYex6iWah5_tLnirAHwj2Qsg,51
56
- panther-4.1.3.dist-info/top_level.txt,sha256=VbBs02JGXTIoHMzsX-eLOk2MCbBZzQbLhWiYpI7xI2g,8
57
- panther-4.1.3.dist-info/RECORD,,
52
+ panther-4.2.0.dist-info/LICENSE,sha256=2aF1hL2aC0zRPjzUkSxJUzZbn2_uLoOkn7DHjzZni-I,1524
53
+ panther-4.2.0.dist-info/METADATA,sha256=N0SkpG2_UqpwuGhnGC8zOUdmnMYKNaaJG4sJaYl0UEk,6376
54
+ panther-4.2.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
55
+ panther-4.2.0.dist-info/entry_points.txt,sha256=6GPxYFGuzVfNB4YpHFJvYex6iWah5_tLnirAHwj2Qsg,51
56
+ panther-4.2.0.dist-info/top_level.txt,sha256=VbBs02JGXTIoHMzsX-eLOk2MCbBZzQbLhWiYpI7xI2g,8
57
+ panther-4.2.0.dist-info/RECORD,,