ohmyapi 0.2.3__py3-none-any.whl → 0.2.5__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.
ohmyapi/core/runtime.py CHANGED
@@ -81,8 +81,8 @@ class Project:
81
81
 
82
82
  # Attach routers from apps
83
83
  for app_name, app_def in self._apps.items():
84
- if app_def.router:
85
- app.include_router(app_def.router)
84
+ for router in app_def.routers:
85
+ app.include_router(router)
86
86
 
87
87
  # Startup / shutdown events
88
88
  @app.on_event("startup")
@@ -257,7 +257,9 @@ class App:
257
257
  and issubclass(value, Model)
258
258
  and not name == Model.__name__
259
259
  ):
260
- self._models[mod_name] = self._models.get(mod_name, []) + [value]
260
+ value.__module__ = value.__module__.replace("ohmyapi.builtin.", "ohmyapi_")
261
+ if value.__module__.startswith(mod_name):
262
+ self._models[mod_name] = self._models.get(mod_name, []) + [value]
261
263
 
262
264
  # if it's a package, recurse into submodules
263
265
  if hasattr(mod, "__path__"):
@@ -300,8 +302,7 @@ class App:
300
302
  for _, subname, _ in pkgutil.iter_modules(
301
303
  mod.__path__, mod.__name__ + "."
302
304
  ):
303
- submod = importlib.import_module(subname)
304
- walk(submod)
305
+ walk(subname)
305
306
 
306
307
  # Walk the walk.
307
308
  walk(mod_name)
@@ -332,16 +333,23 @@ class App:
332
333
  module: out,
333
334
  }
334
335
 
336
+ @property
337
+ def routers(self):
338
+ out = []
339
+ for routes_mod in self._routers:
340
+ for r in self._routers[routes_mod]:
341
+ out.append(r)
342
+ return out
343
+
335
344
  @property
336
345
  def routes(self):
337
346
  """
338
347
  Return an APIRouter with all loaded routes.
339
348
  """
340
- router = APIRouter()
341
- for routes_mod in self._routers:
342
- for r in self._routers[routes_mod]:
343
- router.include_router(r)
344
- return router.routes
349
+ out = []
350
+ for r in self.routers:
351
+ out.extend(r.routes)
352
+ return out
345
353
 
346
354
  def dict(self) -> Dict[str, Any]:
347
355
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ohmyapi
3
- Version: 0.2.3
3
+ Version: 0.2.5
4
4
  Summary: Django-flavored scaffolding and management layer around FastAPI, Pydantic, TortoiseORM and Aerich migrations
5
5
  License-Expression: MIT
6
6
  Keywords: fastapi,tortoise,orm,pydantic,async,web-framework
@@ -9,7 +9,7 @@ ohmyapi/builtin/demo/models.py,sha256=r06rfuhPJaI2fYsQ24L1JCOd67f2GQNfGnkgKAptOX
9
9
  ohmyapi/builtin/demo/routes.py,sha256=1VTlEttrez6Qnhrz_9sTA-emtfXem0s0BkPVcLvg3k0,1801
10
10
  ohmyapi/cli.py,sha256=dJVNgpW5S4rCc619AEEKBKuEIAmQs153Ls0ZVaea48w,4173
11
11
  ohmyapi/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- ohmyapi/core/runtime.py,sha256=6MejxdFxY9zfmAEcFMIly-R5JEhIlzf3hlx9dZWBZrY,11748
12
+ ohmyapi/core/runtime.py,sha256=Zs2080IXOamzs1TIRVCX-oWh93uJHumtYUwMZKtRwFY,11958
13
13
  ohmyapi/core/scaffolding.py,sha256=SA0SYFd7VcqkOn9xuXgj-yOoVqCZMJo68GGFbm34GE4,2663
14
14
  ohmyapi/core/templates/app/__init__.py.j2,sha256=QwVIQVUGZVhdH1d4NrvL7NTsK4-T4cihzYs8UVX2dt4,43
15
15
  ohmyapi/core/templates/app/models.py.j2,sha256=_3w-vFJ5fgsmncsCv34k_wyCMF78jufbSSglns4gbb0,119
@@ -22,7 +22,7 @@ ohmyapi/db/exceptions.py,sha256=vb4IIUoeYAY6sK42zRtjMy-39IFVi_Qb6mWySTY0jYw,34
22
22
  ohmyapi/db/model/__init__.py,sha256=k3StTNuKatpwZo_Z5JBFa-927eJrzibFE8U4SA82asc,32
23
23
  ohmyapi/db/model/model.py,sha256=ui4g78c5xoS06Dj8Cdk7QgTjRnE68zKeL-AdmeYYPuQ,2776
24
24
  ohmyapi/router.py,sha256=5g0U59glu4hxxnIoTSFzb2S2offkOT3eE39aprzVxwo,83
25
- ohmyapi-0.2.3.dist-info/METADATA,sha256=RwdNl_tbHfK7TWcb5tqp2Yb9RSbtHiQDb2gD1scd_ng,2575
26
- ohmyapi-0.2.3.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
27
- ohmyapi-0.2.3.dist-info/entry_points.txt,sha256=wb3lw8-meAlpiv1mqcQ3m25ukL7djagU_w89GkrC37k,43
28
- ohmyapi-0.2.3.dist-info/RECORD,,
25
+ ohmyapi-0.2.5.dist-info/METADATA,sha256=lZw4-WY9rahDJboBp1q0RNAxrzErYkA7p3lnz4RyVYo,2575
26
+ ohmyapi-0.2.5.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
27
+ ohmyapi-0.2.5.dist-info/entry_points.txt,sha256=wb3lw8-meAlpiv1mqcQ3m25ukL7djagU_w89GkrC37k,43
28
+ ohmyapi-0.2.5.dist-info/RECORD,,