xn-model 1.0.0__tar.gz → 1.0.1__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.
@@ -1,15 +1,16 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: xn-model
3
- Version: 1.0.0
3
+ Version: 1.0.1
4
4
  Summary: Base model for xn-api
5
5
  Author-email: Mike Artemiev <mixartemev@gmail.com>
6
6
  License: MIT
7
7
  Project-URL: Homepage, https://github.com/XyncNet/x-model
8
8
  Project-URL: Repository, https://github.com/XyncNet/x-model
9
9
  Keywords: tortoise,model,crud,generator,api,admin
10
- Requires-Python: >=3.12
10
+ Requires-Python: >=3.11
11
11
  Description-Content-Type: text/markdown
12
12
  Requires-Dist: tortoise-orm[accel,asyncpg]
13
+ Requires-Dist: fastapi
13
14
  Provides-Extra: dev
14
15
  Requires-Dist: pytest; extra == "dev"
15
16
  Requires-Dist: python-dotenv; extra == "dev"
@@ -1,10 +1,10 @@
1
1
  [project]
2
2
  name = "xn-model"
3
- requires-python = ">=3.12"
3
+ requires-python = ">=3.11"
4
4
  authors = [
5
5
  {name = "Mike Artemiev", email = "mixartemev@gmail.com"},
6
6
  ]
7
- dependencies = ['tortoise-orm[accel,asyncpg]']
7
+ dependencies = ['tortoise-orm[accel,asyncpg]', 'fastapi']
8
8
  keywords = ["tortoise", "model", "crud", "generator", "api", "admin"]
9
9
  description = 'Base model for xn-api'
10
10
  readme = "README.md"
@@ -5,6 +5,8 @@ from tortoise import Model as BaseModel
5
5
  from tortoise.contrib.pydantic import pydantic_model_creator, PydanticModel
6
6
  from tortoise.fields import DatetimeField, IntField
7
7
 
8
+ from x_model import HTTPException, FailReason
9
+
8
10
 
9
11
  class DatetimeSecField(DatetimeField):
10
12
  class _db_postgres:
@@ -39,9 +41,10 @@ class Model(BaseModel):
39
41
 
40
42
  # # # CRUD Methods # # #
41
43
  @classmethod
42
- async def one_pyd(cls, uid: int, **filters) -> PydanticModel:
43
- q = cls.get(id=uid, **filters)
44
- return await cls.pyd().from_queryset_single(q)
44
+ async def get_one(cls, id_: int, **filters) -> PydanticModel:
45
+ if obj := await cls.get_or_none(id=id_, **filters):
46
+ return await cls.pyd().from_tortoise_orm(obj)
47
+ raise HTTPException(reason=FailReason.path, status_=404, parent=f"{cls.__name__}#{id_} not found")
45
48
 
46
49
  @classmethod
47
50
  async def get_or_create_by_name(cls, name: str, attr_name: str = None, def_dict: dict = None) -> "Model":
@@ -1,15 +1,16 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: xn-model
3
- Version: 1.0.0
3
+ Version: 1.0.1
4
4
  Summary: Base model for xn-api
5
5
  Author-email: Mike Artemiev <mixartemev@gmail.com>
6
6
  License: MIT
7
7
  Project-URL: Homepage, https://github.com/XyncNet/x-model
8
8
  Project-URL: Repository, https://github.com/XyncNet/x-model
9
9
  Keywords: tortoise,model,crud,generator,api,admin
10
- Requires-Python: >=3.12
10
+ Requires-Python: >=3.11
11
11
  Description-Content-Type: text/markdown
12
12
  Requires-Dist: tortoise-orm[accel,asyncpg]
13
+ Requires-Dist: fastapi
13
14
  Provides-Extra: dev
14
15
  Requires-Dist: pytest; extra == "dev"
15
16
  Requires-Dist: python-dotenv; extra == "dev"
@@ -1,4 +1,5 @@
1
1
  tortoise-orm[accel,asyncpg]
2
+ fastapi
2
3
 
3
4
  [dev]
4
5
  pytest
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