orionis 0.111.0__py3-none-any.whl → 0.113.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.
- orionis/framework.py +1 -1
- orionis/luminate/{app.py → application.py} +89 -8
- orionis/luminate/console/commands/help.py +1 -1
- orionis/luminate/facades/app.py +6 -1
- {orionis-0.111.0.dist-info → orionis-0.113.0.dist-info}/METADATA +1 -1
- {orionis-0.111.0.dist-info → orionis-0.113.0.dist-info}/RECORD +10 -11
- orionis/luminate/app_context.py +0 -35
- {orionis-0.111.0.dist-info → orionis-0.113.0.dist-info}/LICENCE +0 -0
- {orionis-0.111.0.dist-info → orionis-0.113.0.dist-info}/WHEEL +0 -0
- {orionis-0.111.0.dist-info → orionis-0.113.0.dist-info}/entry_points.txt +0 -0
- {orionis-0.111.0.dist-info → orionis-0.113.0.dist-info}/top_level.txt +0 -0
orionis/framework.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
from typing import Any, Callable
|
2
|
+
from contextlib import contextmanager
|
2
3
|
from orionis.contracts.foundation.i_bootstraper import IBootstrapper
|
3
|
-
from orionis.luminate.console.output.console import Console
|
4
4
|
from orionis.luminate.container.container import Container
|
5
5
|
from orionis.luminate.foundation.config.config_bootstrapper import ConfigBootstrapper
|
6
6
|
from orionis.luminate.foundation.console.command_bootstrapper import CommandsBootstrapper
|
@@ -37,6 +37,33 @@ class Application(metaclass=SingletonMeta):
|
|
37
37
|
_afterBootstrapProviders()
|
38
38
|
Registers and boots additional providers after bootstrapping.
|
39
39
|
"""
|
40
|
+
booted = False
|
41
|
+
|
42
|
+
@classmethod
|
43
|
+
def started(cls):
|
44
|
+
"""
|
45
|
+
Marks the application as booted.
|
46
|
+
"""
|
47
|
+
cls.booted = True
|
48
|
+
|
49
|
+
@classmethod
|
50
|
+
def getCurrentInstance(cls):
|
51
|
+
"""
|
52
|
+
Returns the existing application instance if available.
|
53
|
+
|
54
|
+
Returns
|
55
|
+
-------
|
56
|
+
Application
|
57
|
+
The current singleton instance of the application.
|
58
|
+
|
59
|
+
Raises
|
60
|
+
------
|
61
|
+
RuntimeError
|
62
|
+
If no instance has been initialized yet.
|
63
|
+
"""
|
64
|
+
if cls not in SingletonMeta._instances:
|
65
|
+
raise RuntimeError("Application has not been initialized yet. Please create an instance first.")
|
66
|
+
return SingletonMeta._instances[cls]
|
40
67
|
|
41
68
|
def __init__(self, container: Container):
|
42
69
|
"""
|
@@ -58,10 +85,6 @@ class Application(metaclass=SingletonMeta):
|
|
58
85
|
# Initialize the application container
|
59
86
|
self.container = container
|
60
87
|
self.container.instance(container)
|
61
|
-
try:
|
62
|
-
self._boot()
|
63
|
-
except Exception as e:
|
64
|
-
Console.exception(e)
|
65
88
|
|
66
89
|
def isBooted(self) -> bool:
|
67
90
|
"""
|
@@ -189,7 +212,7 @@ class Application(metaclass=SingletonMeta):
|
|
189
212
|
"""
|
190
213
|
return self.container.forgetScopedInstances()
|
191
214
|
|
192
|
-
def
|
215
|
+
def boot(self):
|
193
216
|
"""
|
194
217
|
Bootstraps the application by loading environment configuration and core providers.
|
195
218
|
Notes
|
@@ -207,7 +230,9 @@ class Application(metaclass=SingletonMeta):
|
|
207
230
|
self._bootstrapping()
|
208
231
|
self._afterBootstrapProviders()
|
209
232
|
self._loadCommands()
|
210
|
-
|
233
|
+
|
234
|
+
# Mark the application as booted
|
235
|
+
Application.started()
|
211
236
|
|
212
237
|
def _bootServices(self):
|
213
238
|
"""
|
@@ -303,4 +328,60 @@ class Application(metaclass=SingletonMeta):
|
|
303
328
|
for service in self._after_boot_service_providers:
|
304
329
|
_environment_provider : ServiceProvider = service(app=self.container)
|
305
330
|
_environment_provider.register()
|
306
|
-
_environment_provider.boot()
|
331
|
+
_environment_provider.boot()
|
332
|
+
|
333
|
+
@contextmanager
|
334
|
+
def app_context():
|
335
|
+
"""
|
336
|
+
Context manager for creating an instance of the Orionis application.
|
337
|
+
|
338
|
+
This function initializes the Orionis application with a new container,
|
339
|
+
ensuring that the application is properly set up before use.
|
340
|
+
|
341
|
+
Yields
|
342
|
+
------
|
343
|
+
Application
|
344
|
+
The initialized Orionis application instance.
|
345
|
+
|
346
|
+
Raises
|
347
|
+
------
|
348
|
+
RuntimeError
|
349
|
+
If the application has not been properly initialized.
|
350
|
+
"""
|
351
|
+
try:
|
352
|
+
|
353
|
+
# Check if the application has been booted
|
354
|
+
if not Application.booted:
|
355
|
+
# Create a new application instance
|
356
|
+
app = Application(Container())
|
357
|
+
app.boot()
|
358
|
+
else:
|
359
|
+
# Get the current application instance
|
360
|
+
app = Application.getCurrentInstance()
|
361
|
+
|
362
|
+
# Yield the application instance
|
363
|
+
yield app
|
364
|
+
|
365
|
+
finally:
|
366
|
+
|
367
|
+
# Close Context Manager
|
368
|
+
pass
|
369
|
+
|
370
|
+
def app_booted():
|
371
|
+
"""
|
372
|
+
Context manager for creating an instance of the Orionis application.
|
373
|
+
|
374
|
+
This function initializes the Orionis application with a new container,
|
375
|
+
ensuring that the application is properly set up before use.
|
376
|
+
|
377
|
+
Yields
|
378
|
+
------
|
379
|
+
Application
|
380
|
+
The initialized Orionis application instance.
|
381
|
+
|
382
|
+
Raises
|
383
|
+
------
|
384
|
+
RuntimeError
|
385
|
+
If the application has not been properly initialized.
|
386
|
+
"""
|
387
|
+
return Application.booted
|
orionis/luminate/facades/app.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
from typing import Any
|
2
|
+
from orionis.luminate.application import app_booted
|
3
|
+
from orionis.luminate.console.output.console import Console
|
2
4
|
from orionis.luminate.container.container import Container
|
3
|
-
from orionis.luminate.container.exception import OrionisContainerTypeError
|
5
|
+
from orionis.luminate.container.exception import OrionisContainerException, OrionisContainerTypeError
|
4
6
|
|
5
7
|
def app(concrete: Any = None):
|
6
8
|
"""
|
@@ -27,6 +29,9 @@ def app(concrete: Any = None):
|
|
27
29
|
OrionisContainerException
|
28
30
|
If `concrete` is not bound to the container.
|
29
31
|
"""
|
32
|
+
if not app_booted():
|
33
|
+
Console.error("The application context is not valid.")
|
34
|
+
raise OrionisContainerException("The application context is not valid.")
|
30
35
|
|
31
36
|
# Create a new container instance
|
32
37
|
container : Container = Container()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
orionis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
orionis/cli_manager.py,sha256=0bM-hABXJSoPGuvEgnqeaj9qcLP8VjTQ3z9Mb0TSEUI,1381
|
3
|
-
orionis/framework.py,sha256=
|
3
|
+
orionis/framework.py,sha256=iSTU5g6xH5z5JccKETU1PC7iCtwePfLLf_HXHLM5zPU,1387
|
4
4
|
orionis/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
5
|
orionis/contracts/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
6
|
orionis/contracts/config/i_config.py,sha256=rbeojO2gm8XhSXIPY8EnUt4e0wO633OKF9Nx_tN5y60,785
|
@@ -67,8 +67,7 @@ orionis/installer/installer_manager.py,sha256=Hb6T0bmSl39T30maY-nUWkrLhG77JdrKe4
|
|
67
67
|
orionis/installer/installer_output.py,sha256=LeKxzuXpnHOKbKpUtx3tMGkCi2bGcPV1VNnfBxwfxUU,7161
|
68
68
|
orionis/installer/installer_setup.py,sha256=c2HtVklSa-2_-YVonc7fwtoK-RTDqBS2Ybvbekgfqtc,6970
|
69
69
|
orionis/luminate/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
70
|
-
orionis/luminate/
|
71
|
-
orionis/luminate/app_context.py,sha256=se2xpsGoy_drcuOROC7OHaIAN5Yd0kbm5V1zzsxxyQc,996
|
70
|
+
orionis/luminate/application.py,sha256=C2zBPly4MQYdzb8f7Y1oZTY9iEgGvWiM7UqG37yNimI,14122
|
72
71
|
orionis/luminate/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
73
72
|
orionis/luminate/config/app.py,sha256=7teuVPuaV2ao0M5Bv-jhSgjEwb9DtVwde2saTRmYru4,1737
|
74
73
|
orionis/luminate/config/auth.py,sha256=CG8F0pfVjKz4DY3d1Wi7gscdhnp4TT-Q8SJ2sdsHh18,523
|
@@ -88,7 +87,7 @@ orionis/luminate/console/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
|
|
88
87
|
orionis/luminate/console/base/command.py,sha256=YGHd5xVYILcNhQumi74IRnzvagvjufEO2Bx1CwHRToY,12544
|
89
88
|
orionis/luminate/console/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
90
89
|
orionis/luminate/console/commands/cache_clear.py,sha256=KyXVSwtLaV1O1cTEkNzX9czCwEoeQlAjiT0jUFMO8iE,2684
|
91
|
-
orionis/luminate/console/commands/help.py,sha256=
|
90
|
+
orionis/luminate/console/commands/help.py,sha256=kbE4WiTE1ypGKZl5lGnz_HxRA5moKxOSYvo92IjiuCQ,2288
|
92
91
|
orionis/luminate/console/commands/schedule_work.py,sha256=xbutdJMYL0fIZtABiS_XalNzvRhYvR2tmu8shNiDEW4,2165
|
93
92
|
orionis/luminate/console/commands/tests.py,sha256=Z7e6aM5Vu8C7R8iC8sJgUYVN9aJgtVMkqjUEFxPq91o,1281
|
94
93
|
orionis/luminate/console/commands/version.py,sha256=llVPK6ELtf8dIdPvLbybrtipWwZkzV0EXc9ShL-C-GY,1140
|
@@ -103,7 +102,7 @@ orionis/luminate/container/container.py,sha256=kg1zrvlMrzYCrORbDZ12JVZJ_z81gLDUp
|
|
103
102
|
orionis/luminate/container/exception.py,sha256=ap1SqYEjQEEHXJJTNmL7V1jrmRjgT5_7geZ95MYkhMA,1691
|
104
103
|
orionis/luminate/container/types.py,sha256=BDcXN0__voRNHZ5Gr5dF0sWIYAQyNk4TxAwILBWyDAA,1735
|
105
104
|
orionis/luminate/facades/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
106
|
-
orionis/luminate/facades/app.py,sha256=
|
105
|
+
orionis/luminate/facades/app.py,sha256=8s0CLzGXcfgwXpJDsgde4Zw7CJd7cuwQzPyaSh20iGI,1607
|
107
106
|
orionis/luminate/facades/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
108
107
|
orionis/luminate/facades/commands/commands_facade.py,sha256=xy-5sW5_fDXhS2y0c0CCbBOfrOR0mJQLVTwBe3J8WTk,1561
|
109
108
|
orionis/luminate/facades/commands/scheduler_facade.py,sha256=X1Ox0NVOA9RyiKmw3UYgiF68jdIWU8HNyOf7uD0SZ54,1432
|
@@ -175,9 +174,9 @@ tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
175
174
|
tests/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
176
175
|
tests/tools/class_example.py,sha256=dIPD997Y15n6WmKhWoOFSwEldRm9MdOHTZZ49eF1p3c,1056
|
177
176
|
tests/tools/test_reflection.py,sha256=bhLQ7VGVod4B8sv-rW9AjnOumvaBVsoxieA3sdoM2yM,5244
|
178
|
-
orionis-0.
|
179
|
-
orionis-0.
|
180
|
-
orionis-0.
|
181
|
-
orionis-0.
|
182
|
-
orionis-0.
|
183
|
-
orionis-0.
|
177
|
+
orionis-0.113.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
|
178
|
+
orionis-0.113.0.dist-info/METADATA,sha256=T1C21-uTpYqyGstkpJkpfVOqifHmlcEGr47yBfmqdGk,2979
|
179
|
+
orionis-0.113.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
180
|
+
orionis-0.113.0.dist-info/entry_points.txt,sha256=eef1_CVewfokKjrGBynXa06KabSJYo7LlDKKIKvs1cM,53
|
181
|
+
orionis-0.113.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
|
182
|
+
orionis-0.113.0.dist-info/RECORD,,
|
orionis/luminate/app_context.py
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
from contextlib import contextmanager
|
2
|
-
from orionis.luminate.app import Application
|
3
|
-
from orionis.luminate.container.container import Container
|
4
|
-
|
5
|
-
@contextmanager
|
6
|
-
def app_context():
|
7
|
-
"""
|
8
|
-
Context manager for resolving dependencies within a valid Orionis application context.
|
9
|
-
|
10
|
-
This function ensures that Orionis is properly initialized before resolving dependencies,
|
11
|
-
similar to how Laravel’s `app()` helper works.
|
12
|
-
|
13
|
-
Yields
|
14
|
-
------
|
15
|
-
Application
|
16
|
-
The initialized Orionis application instance.
|
17
|
-
|
18
|
-
Raises
|
19
|
-
------
|
20
|
-
RuntimeError
|
21
|
-
If the application has not been properly initialized.
|
22
|
-
"""
|
23
|
-
container = Container()
|
24
|
-
app = Application(container)
|
25
|
-
|
26
|
-
if not app.isBooted():
|
27
|
-
raise RuntimeError(
|
28
|
-
"Error: Not running within a valid Orionis Framework context. "
|
29
|
-
"Ensure that the Orionis application is correctly initialized."
|
30
|
-
)
|
31
|
-
|
32
|
-
try:
|
33
|
-
yield app
|
34
|
-
finally:
|
35
|
-
pass
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|