orionis 0.111.0__py3-none-any.whl → 0.112.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 CHANGED
@@ -5,7 +5,7 @@
5
5
  NAME = "orionis"
6
6
 
7
7
  # Current version of the framework
8
- VERSION = "0.111.0"
8
+ VERSION = "0.112.0"
9
9
 
10
10
  # Full name of the author or maintainer of the project
11
11
  AUTHOR = "Raul Mauricio Uñate Castro"
orionis/luminate/app.py CHANGED
@@ -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 _boot(self):
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
- self._booted = True
233
+
234
+ # Mark the application as booted
235
+ Application.started()
211
236
 
212
237
  def _bootServices(self):
213
238
  """
@@ -5,10 +5,10 @@ from orionis.luminate.container.container import Container
5
5
  @contextmanager
6
6
  def app_context():
7
7
  """
8
- Context manager for resolving dependencies within a valid Orionis application context.
8
+ Context manager for creating an instance of the Orionis application.
9
9
 
10
- This function ensures that Orionis is properly initialized before resolving dependencies,
11
- similar to how Laravel’s `app()` helper works.
10
+ This function initializes the Orionis application with a new container,
11
+ ensuring that the application is properly set up before use.
12
12
 
13
13
  Yields
14
14
  ------
@@ -20,16 +20,41 @@ def app_context():
20
20
  RuntimeError
21
21
  If the application has not been properly initialized.
22
22
  """
23
- container = Container()
24
- app = Application(container)
23
+ try:
25
24
 
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
- )
25
+ # Check if the application has been booted
26
+ if not Application.booted:
27
+ # Create a new application instance
28
+ app = Application(Container())
29
+ app.boot()
30
+ else:
31
+ # Get the current application instance
32
+ app = Application.getCurrentInstance()
31
33
 
32
- try:
34
+ # Yield the application instance
33
35
  yield app
36
+
34
37
  finally:
38
+
39
+ # Close Context Manager
35
40
  pass
41
+
42
+
43
+ def app_booted():
44
+ """
45
+ Context manager for creating an instance of the Orionis application.
46
+
47
+ This function initializes the Orionis application with a new container,
48
+ ensuring that the application is properly set up before use.
49
+
50
+ Yields
51
+ ------
52
+ Application
53
+ The initialized Orionis application instance.
54
+
55
+ Raises
56
+ ------
57
+ RuntimeError
58
+ If the application has not been properly initialized.
59
+ """
60
+ return Application.booted
@@ -1,6 +1,8 @@
1
1
  from typing import Any
2
+ from orionis.luminate.app_context 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
  Metadata-Version: 2.2
2
2
  Name: orionis
3
- Version: 0.111.0
3
+ Version: 0.112.0
4
4
  Summary: Orionis Framework – Elegant, Fast, and Powerful.
5
5
  Home-page: https://github.com/orionis-framework/framework
6
6
  Author: Raul Mauricio Uñate Castro
@@ -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=LJ4bB-pQZajXH743nG2PW3jk3E59MsEaUCkk_24X8Zk,1387
3
+ orionis/framework.py,sha256=D-irTHNRjw1hfyrT7bSHJiOHHtllt5ZYIfV6Pv81ULk,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,8 @@ 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/app.py,sha256=CT_d7yKeYvCSZw09Lj-8muZM87g2sfOs7frk3u2BYBs,12027
71
- orionis/luminate/app_context.py,sha256=se2xpsGoy_drcuOROC7OHaIAN5Yd0kbm5V1zzsxxyQc,996
70
+ orionis/luminate/app.py,sha256=u_QkD3v0wr2ok6QmgyiAMLIDFA72imwI86DBijpM7eo,12705
71
+ orionis/luminate/app_context.py,sha256=0njAnGRjlpCqizGv2_FHs-SHdzeWR0mbUUx7NI_BS18,1584
72
72
  orionis/luminate/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
73
73
  orionis/luminate/config/app.py,sha256=7teuVPuaV2ao0M5Bv-jhSgjEwb9DtVwde2saTRmYru4,1737
74
74
  orionis/luminate/config/auth.py,sha256=CG8F0pfVjKz4DY3d1Wi7gscdhnp4TT-Q8SJ2sdsHh18,523
@@ -103,7 +103,7 @@ orionis/luminate/container/container.py,sha256=kg1zrvlMrzYCrORbDZ12JVZJ_z81gLDUp
103
103
  orionis/luminate/container/exception.py,sha256=ap1SqYEjQEEHXJJTNmL7V1jrmRjgT5_7geZ95MYkhMA,1691
104
104
  orionis/luminate/container/types.py,sha256=BDcXN0__voRNHZ5Gr5dF0sWIYAQyNk4TxAwILBWyDAA,1735
105
105
  orionis/luminate/facades/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
106
- orionis/luminate/facades/app.py,sha256=DHwCdhfU-Mfj0gPX5nwXR_cgnkvg6agMP2WBa-L0JE8,1294
106
+ orionis/luminate/facades/app.py,sha256=oBL9ybLUBK41JS6fenEf8iPyKQebnVFvVe4bGACOYu4,1607
107
107
  orionis/luminate/facades/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
108
108
  orionis/luminate/facades/commands/commands_facade.py,sha256=xy-5sW5_fDXhS2y0c0CCbBOfrOR0mJQLVTwBe3J8WTk,1561
109
109
  orionis/luminate/facades/commands/scheduler_facade.py,sha256=X1Ox0NVOA9RyiKmw3UYgiF68jdIWU8HNyOf7uD0SZ54,1432
@@ -175,9 +175,9 @@ tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
175
175
  tests/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
176
176
  tests/tools/class_example.py,sha256=dIPD997Y15n6WmKhWoOFSwEldRm9MdOHTZZ49eF1p3c,1056
177
177
  tests/tools/test_reflection.py,sha256=bhLQ7VGVod4B8sv-rW9AjnOumvaBVsoxieA3sdoM2yM,5244
178
- orionis-0.111.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
179
- orionis-0.111.0.dist-info/METADATA,sha256=AftUlzF4B0CrF3exdG4h1AcAGAIQ91bkbJ7jNGuZZNI,2979
180
- orionis-0.111.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
181
- orionis-0.111.0.dist-info/entry_points.txt,sha256=eef1_CVewfokKjrGBynXa06KabSJYo7LlDKKIKvs1cM,53
182
- orionis-0.111.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
183
- orionis-0.111.0.dist-info/RECORD,,
178
+ orionis-0.112.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
179
+ orionis-0.112.0.dist-info/METADATA,sha256=_6ekbP2eCdpr6um2wC2v4ZUGubqsyoPfGR6hxbJxGOI,2979
180
+ orionis-0.112.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
181
+ orionis-0.112.0.dist-info/entry_points.txt,sha256=eef1_CVewfokKjrGBynXa06KabSJYo7LlDKKIKvs1cM,53
182
+ orionis-0.112.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
183
+ orionis-0.112.0.dist-info/RECORD,,