ohmyapi 0.1.13__tar.gz → 0.1.15__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 (25) hide show
  1. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/PKG-INFO +6 -6
  2. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/README.md +5 -5
  3. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/pyproject.toml +1 -1
  4. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/src/ohmyapi/builtin/auth/models.py +12 -13
  5. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/src/ohmyapi/builtin/auth/routes.py +1 -1
  6. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/src/ohmyapi/core/templates/app/routes.py.j2 +1 -1
  7. ohmyapi-0.1.15/src/ohmyapi/db/__init__.py +10 -0
  8. ohmyapi-0.1.13/src/ohmyapi/db/__init__.py +0 -3
  9. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/src/ohmyapi/__init__.py +0 -0
  10. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/src/ohmyapi/__main__.py +0 -0
  11. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/src/ohmyapi/builtin/auth/__init__.py +0 -0
  12. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/src/ohmyapi/builtin/auth/permissions.py +0 -0
  13. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/src/ohmyapi/cli.py +0 -0
  14. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/src/ohmyapi/core/__init__.py +0 -0
  15. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/src/ohmyapi/core/runtime.py +0 -0
  16. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/src/ohmyapi/core/scaffolding.py +0 -0
  17. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/src/ohmyapi/core/templates/app/__init__.py.j2 +0 -0
  18. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/src/ohmyapi/core/templates/app/models.py.j2 +0 -0
  19. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/src/ohmyapi/core/templates/project/README.md.j2 +0 -0
  20. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/src/ohmyapi/core/templates/project/pyproject.toml.j2 +0 -0
  21. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/src/ohmyapi/core/templates/project/settings.py.j2 +0 -0
  22. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/src/ohmyapi/db/exceptions.py +0 -0
  23. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/src/ohmyapi/db/model/__init__.py +0 -0
  24. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/src/ohmyapi/db/model/model.py +0 -0
  25. {ohmyapi-0.1.13 → ohmyapi-0.1.15}/src/ohmyapi/router.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ohmyapi
3
- Version: 0.1.13
3
+ Version: 0.1.15
4
4
  Summary: A Django-like but async web-framework based on FastAPI and TortoiseORM.
5
5
  License-Expression: MIT
6
6
  Keywords: fastapi,tortoise,orm,async,web-framework
@@ -52,11 +52,11 @@ It is ***blazingly fast***, ***fun to use*** and comes with ***batteries include
52
52
  - Highly configurable and customizable
53
53
  - 100% async
54
54
 
55
- OhMyAPI aims to:
55
+ **Goals**
56
56
 
57
57
  - combine FastAPI, TortoiseORM and Aerich migrations into a high-productivity web-application framework
58
- - tying everything neatly together into a project structure consisting of apps with models and a router
59
- - while ***AVOIDING*** to introduce any additional abstractions ontop of Tortoise's model-system or FastAPI's routing
58
+ - tie everything neatly together into a concise API
59
+ - while ***AVOIDING*** any additional abstractions ontop of Tortoise's model-system or FastAPI's routing system
60
60
 
61
61
  ---
62
62
 
@@ -173,8 +173,8 @@ async def list():
173
173
  @router.get("/:id")
174
174
  async def get(id: str):
175
175
  try:
176
- queryset = Tournament.get(pk=id)
177
- return await Tournament.Schema.one(queryset)
176
+ tournament = await Tournament.get(pk=id)
177
+ return await Tournament.Schema.one.form_orm(tournament)
178
178
  except DoesNotExist:
179
179
  raise HTTPException(status_code=404, detail="item not found")
180
180
 
@@ -20,11 +20,11 @@ It is ***blazingly fast***, ***fun to use*** and comes with ***batteries include
20
20
  - Highly configurable and customizable
21
21
  - 100% async
22
22
 
23
- OhMyAPI aims to:
23
+ **Goals**
24
24
 
25
25
  - combine FastAPI, TortoiseORM and Aerich migrations into a high-productivity web-application framework
26
- - tying everything neatly together into a project structure consisting of apps with models and a router
27
- - while ***AVOIDING*** to introduce any additional abstractions ontop of Tortoise's model-system or FastAPI's routing
26
+ - tie everything neatly together into a concise API
27
+ - while ***AVOIDING*** any additional abstractions ontop of Tortoise's model-system or FastAPI's routing system
28
28
 
29
29
  ---
30
30
 
@@ -141,8 +141,8 @@ async def list():
141
141
  @router.get("/:id")
142
142
  async def get(id: str):
143
143
  try:
144
- queryset = Tournament.get(pk=id)
145
- return await Tournament.Schema.one(queryset)
144
+ tournament = await Tournament.get(pk=id)
145
+ return await Tournament.Schema.one.form_orm(tournament)
146
146
  except DoesNotExist:
147
147
  raise HTTPException(status_code=404, detail="item not found")
148
148
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ohmyapi"
3
- version = "0.1.13"
3
+ version = "0.1.15"
4
4
  description = "A Django-like but async web-framework based on FastAPI and TortoiseORM."
5
5
  license = "MIT"
6
6
  keywords = ["fastapi", "tortoise", "orm", "async", "web-framework"]
@@ -1,5 +1,7 @@
1
+ from functools import wraps
1
2
  from typing import Optional, List
2
- from ohmyapi.db import Model, field
3
+ from ohmyapi.router import HTTPException
4
+ from ohmyapi.db import Model, field, pre_save, pre_delete
3
5
  from passlib.context import CryptContext
4
6
  from tortoise.contrib.pydantic import pydantic_queryset_creator
5
7
 
@@ -7,24 +9,22 @@ pwd_context = CryptContext(schemes=["argon2"], deprecated="auto")
7
9
 
8
10
 
9
11
  class Group(Model):
10
- id = field.data.UUIDField(pk=True)
11
- name = field.CharField(max_length=42, index=True)
12
+ id: str = field.data.UUIDField(pk=True)
13
+ name: str = field.CharField(max_length=42, index=True)
12
14
 
13
15
 
14
16
  class User(Model):
15
- id = field.data.UUIDField(pk=True)
16
- email = field.CharField(max_length=255, unique=True, index=True)
17
- username = field.CharField(max_length=150, unique=True)
18
- password_hash = field.CharField(max_length=128)
19
- is_admin = field.BooleanField(default=False)
20
- is_staff = field.BooleanField(default=False)
21
- groups: Optional[List[Group]] = field.ManyToManyField("ohmyapi_auth.Group", related_name="users")
22
-
17
+ id: str = field.data.UUIDField(pk=True)
18
+ email: str = field.CharField(max_length=255, unique=True, index=True)
19
+ username: str = field.CharField(max_length=150, unique=True)
20
+ password_hash: str = field.CharField(max_length=128)
21
+ is_admin: bool = field.BooleanField(default=False)
22
+ is_staff: bool = field.BooleanField(default=False)
23
+ groups: field.ManyToManyRelation[Group] = field.ManyToManyField("ohmyapi_auth.Group", related_name="users", through='user_groups')
23
24
 
24
25
  class Schema:
25
26
  exclude = 'password_hash',
26
27
 
27
-
28
28
  def set_password(self, raw_password: str) -> None:
29
29
  """Hash and store the password."""
30
30
  self.password_hash = pwd_context.hash(raw_password)
@@ -40,4 +40,3 @@ class User(Model):
40
40
  if user and user.verify_password(password):
41
41
  return user
42
42
  return None
43
-
@@ -160,5 +160,5 @@ async def introspect(token: Dict = Depends(get_token)):
160
160
  @router.get("/me")
161
161
  async def me(user: User = Depends(get_current_user)):
162
162
  """Return the currently authenticated user."""
163
- return user
163
+ return User.Schema.one.from_orm(user)
164
164
 
@@ -5,7 +5,7 @@ from . import models
5
5
  # Expose your app's routes via `router = fastapi.APIRouter`.
6
6
  # Use prefixes wisely to avoid cross-app namespace-collisions.
7
7
  # Tags improve the UX of the OpenAPI docs at /docs.
8
- router = APIRouter(prefix="/{{ app_name }}", tags=[{{ app_name }}])
8
+ router = APIRouter(prefix="/{{ app_name }}", tags=['{{ app_name }}'])
9
9
 
10
10
 
11
11
  @router.get("/")
@@ -0,0 +1,10 @@
1
+ from .model import Model, field
2
+ from tortoise.manager import Manager
3
+ from tortoise.queryset import QuerySet
4
+ from tortoise.signals import (
5
+ pre_delete,
6
+ post_delete,
7
+ pre_save,
8
+ post_save,
9
+ )
10
+
@@ -1,3 +0,0 @@
1
- from .model import Model, field
2
- from tortoise.manager import Manager
3
-
File without changes
File without changes