ohmyapi 0.1.4__tar.gz → 0.1.5__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 (23) hide show
  1. {ohmyapi-0.1.4 → ohmyapi-0.1.5}/PKG-INFO +1 -1
  2. {ohmyapi-0.1.4 → ohmyapi-0.1.5}/pyproject.toml +1 -1
  3. {ohmyapi-0.1.4 → ohmyapi-0.1.5}/src/ohmyapi/core/runtime.py +62 -61
  4. {ohmyapi-0.1.4 → ohmyapi-0.1.5}/src/ohmyapi/core/scaffolding.py +1 -1
  5. ohmyapi-0.1.5/src/ohmyapi/core/templates/app/models.py.j2 +6 -0
  6. {ohmyapi-0.1.4 → ohmyapi-0.1.5}/src/ohmyapi/core/templates/project/settings.py.j2 +3 -1
  7. ohmyapi-0.1.4/src/ohmyapi/core/templates/app/models.py.j2 +0 -6
  8. {ohmyapi-0.1.4 → ohmyapi-0.1.5}/README.md +0 -0
  9. {ohmyapi-0.1.4 → ohmyapi-0.1.5}/src/ohmyapi/__init__.py +0 -0
  10. {ohmyapi-0.1.4 → ohmyapi-0.1.5}/src/ohmyapi/builtin/auth/__init__.py +0 -0
  11. {ohmyapi-0.1.4 → ohmyapi-0.1.5}/src/ohmyapi/builtin/auth/models.py +0 -0
  12. {ohmyapi-0.1.4 → ohmyapi-0.1.5}/src/ohmyapi/builtin/auth/permissions.py +0 -0
  13. {ohmyapi-0.1.4 → ohmyapi-0.1.5}/src/ohmyapi/builtin/auth/routes.py +0 -0
  14. {ohmyapi-0.1.4 → ohmyapi-0.1.5}/src/ohmyapi/cli.py +0 -0
  15. {ohmyapi-0.1.4 → ohmyapi-0.1.5}/src/ohmyapi/core/__init__.py +0 -0
  16. {ohmyapi-0.1.4 → ohmyapi-0.1.5}/src/ohmyapi/core/templates/app/__init__.py.j2 +0 -0
  17. {ohmyapi-0.1.4 → ohmyapi-0.1.5}/src/ohmyapi/core/templates/app/routes.py.j2 +0 -0
  18. {ohmyapi-0.1.4 → ohmyapi-0.1.5}/src/ohmyapi/core/templates/project/pyproject.toml.j2 +0 -0
  19. {ohmyapi-0.1.4 → ohmyapi-0.1.5}/src/ohmyapi/db/__init__.py +0 -0
  20. {ohmyapi-0.1.4 → ohmyapi-0.1.5}/src/ohmyapi/db/migration_manager.py +0 -0
  21. {ohmyapi-0.1.4 → ohmyapi-0.1.5}/src/ohmyapi/db/model/__init__.py +0 -0
  22. {ohmyapi-0.1.4 → ohmyapi-0.1.5}/src/ohmyapi/db/model/model.py +0 -0
  23. {ohmyapi-0.1.4 → ohmyapi-0.1.5}/src/ohmyapi/router.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ohmyapi
3
- Version: 0.1.4
3
+ Version: 0.1.5
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ohmyapi"
3
- version = "0.1.4"
3
+ version = "0.1.5"
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"]
@@ -15,67 +15,6 @@ from fastapi import FastAPI, APIRouter
15
15
  from ohmyapi.db.model import Model
16
16
 
17
17
 
18
- class App:
19
- """App container holding runtime data like detected models and routes."""
20
-
21
- def __init__(self, project: "OhMyAPI Project", name: str):
22
- self.project = project
23
- self.name = name
24
-
25
- # The list of module paths (e.g. "ohmyapi_auth.models") for Tortoise and Aerich
26
- self.model_modules: List[str] = []
27
-
28
- # The APIRouter
29
- self.router: Optional[APIRouter] = None
30
-
31
- # Import the app, so its __init__.py runs.
32
- importlib.import_module(self.name)
33
-
34
- # Load the models
35
- try:
36
- models_mod = importlib.import_module(f"{self.name}.models")
37
- self.model_modules.append(f"{self.name}.models")
38
- except ModuleNotFoundError:
39
- pass
40
-
41
- # Locate the APIRouter
42
- try:
43
- routes_mod = importlib.import_module(f"{self.name}.routes")
44
- router = getattr(routes_mod, "router", None)
45
- if isinstance(router, APIRouter):
46
- self.router = router
47
- except ModuleNotFoundError:
48
- pass
49
-
50
- def __repr__(self):
51
- out = ""
52
- out += f"App: {self.name}\n"
53
- out += f"Models:\n"
54
- for model in self.models:
55
- out += f" - {model.__name__}\n"
56
- out += "Routes:\n"
57
- for route in (self.routes or []):
58
- out += f" - {route}\n"
59
- return out
60
-
61
- def __str__(self):
62
- return self.__repr__()
63
-
64
- @property
65
- def models(self) -> List[Model]:
66
- models: List[Model] = []
67
- for mod in self.model_modules:
68
- models_mod = importlib.import_module(mod)
69
- for obj in models_mod.__dict__.values():
70
- if isinstance(obj, type) and getattr(obj, "_meta", None) is not None and obj.__name__ != 'Model':
71
- models.append(obj)
72
- return models
73
-
74
- @property
75
- def routes(self):
76
- return self.router.routes
77
-
78
-
79
18
  class Project:
80
19
  """
81
20
  Project runtime loader + Tortoise/Aerich integration.
@@ -244,3 +183,65 @@ class Project:
244
183
  # No migrations yet, initialize then retry upgrade
245
184
  await c.init_db(safe=True)
246
185
  await c.upgrade()
186
+
187
+
188
+ class App:
189
+ """App container holding runtime data like detected models and routes."""
190
+
191
+ def __init__(self, project: Project, name: str):
192
+ self.project = project
193
+ self.name = name
194
+
195
+ # The list of module paths (e.g. "ohmyapi_auth.models") for Tortoise and Aerich
196
+ self.model_modules: List[str] = []
197
+
198
+ # The APIRouter
199
+ self.router: Optional[APIRouter] = None
200
+
201
+ # Import the app, so its __init__.py runs.
202
+ importlib.import_module(self.name)
203
+
204
+ # Load the models
205
+ try:
206
+ models_mod = importlib.import_module(f"{self.name}.models")
207
+ self.model_modules.append(f"{self.name}.models")
208
+ except ModuleNotFoundError:
209
+ pass
210
+
211
+ # Locate the APIRouter
212
+ try:
213
+ routes_mod = importlib.import_module(f"{self.name}.routes")
214
+ router = getattr(routes_mod, "router", None)
215
+ if isinstance(router, APIRouter):
216
+ self.router = router
217
+ except ModuleNotFoundError:
218
+ pass
219
+
220
+ def __repr__(self):
221
+ out = ""
222
+ out += f"App: {self.name}\n"
223
+ out += f"Models:\n"
224
+ for model in self.models:
225
+ out += f" - {model.__name__}\n"
226
+ out += "Routes:\n"
227
+ for route in (self.routes or []):
228
+ out += f" - {route}\n"
229
+ return out
230
+
231
+ def __str__(self):
232
+ return self.__repr__()
233
+
234
+ @property
235
+ def models(self) -> List[Model]:
236
+ models: List[Model] = []
237
+ for mod in self.model_modules:
238
+ models_mod = importlib.import_module(mod)
239
+ for obj in models_mod.__dict__.values():
240
+ if isinstance(obj, type) and getattr(obj, "_meta", None) is not None and obj.__name__ != 'Model':
241
+ models.append(obj)
242
+ return models
243
+
244
+ @property
245
+ def routes(self):
246
+ return self.router.routes
247
+
@@ -55,7 +55,7 @@ def startapp(name: str, project: str):
55
55
  """Create a new app inside a project: templates go into <project_dir>/<name>/"""
56
56
  target_dir = Path(project)
57
57
  os.makedirs(target_dir, exist_ok=True)
58
- render_template_dir("app", target_dir, {"project_name": project, "app_name": name}, subdir_name=name)
58
+ render_template_dir("app", target_dir, {"project_name": target_dir.resolve().name, "app_name": name}, subdir_name=name)
59
59
  print(f"✅ App '{name}' created in project '{target_dir}' successfully.")
60
60
  print(f"🔧 Remember to add '{name}' to your INSTALLED_APPS!")
61
61
 
@@ -0,0 +1,6 @@
1
+ from ohmyapi.db import Model, field
2
+
3
+
4
+ # class MyModel(Model):
5
+ # id: int = field.IntField(min=1, pk=True)
6
+ # ...
@@ -1,5 +1,7 @@
1
1
  # {{ project_name }} settings.py
2
2
  PROJECT_NAME = "MyProject"
3
3
  DATABASE_URL = "sqlite://db.sqlite3"
4
- INSTALLED_APPS = []
4
+ INSTALLED_APPS = [
5
+ #'ohmyapi_auth',
6
+ ]
5
7
 
@@ -1,6 +0,0 @@
1
- from ohmyapi.db import Model, field
2
-
3
-
4
- class MyModel(Model):
5
- id: int = field.IntField(min=1, pk=True)
6
- ...
File without changes
File without changes
File without changes
File without changes