orionis 0.42.0__py3-none-any.whl → 0.44.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of orionis might be problematic. Click here for more details.

orionis/framework.py CHANGED
@@ -5,7 +5,7 @@
5
5
  NAME = "orionis"
6
6
 
7
7
  # Current version of the framework
8
- VERSION = "0.42.0"
8
+ VERSION = "0.44.0"
9
9
 
10
10
  # Full name of the author or maintainer of the project
11
11
  AUTHOR = "Raul Mauricio Uñate Castro"
@@ -0,0 +1,99 @@
1
+ import traceback
2
+ from orionis.luminate.container.container import Container
3
+ from orionis.luminate.cache.app.config import CacheConfig
4
+ from orionis.luminate.bootstrap.config.register import Register
5
+ from orionis.luminate.bootstrap.config.bootstrapper import Bootstrapper
6
+ from orionis.luminate.patterns.singleton import SingletonMeta
7
+
8
+ class Application(metaclass=SingletonMeta):
9
+ """
10
+ The main service container for the Orionis Framework, ensuring persistent dependency resolution.
11
+
12
+ This class acts as a singleton service container, similar to Laravel's Application class.
13
+ It maintains service bindings, ensures proper initialization, and prevents unnecessary re-instantiation.
14
+
15
+ Attributes
16
+ ----------
17
+ container : Container
18
+ The IoC container that holds all service bindings.
19
+ booted : bool
20
+ Indicates whether the application has been initialized.
21
+ error_info : tuple or None
22
+ Stores error information if an exception occurs during boot.
23
+
24
+ Methods
25
+ -------
26
+ boot()
27
+ Initializes the application and registers all necessary dependencies.
28
+ isBooted()
29
+ Checks if the application is currently running.
30
+ getError()
31
+ Retrieves stored error information, if any.
32
+ """
33
+
34
+ def __init__(self):
35
+ """Initializes the application with an empty dependency container."""
36
+ self.container = Container()
37
+ self.booted = False
38
+ self.error_info = None
39
+
40
+ def boot(self):
41
+ """
42
+ Boots the application and registers necessary dependencies.
43
+
44
+ This method ensures that all required services are bound to the container and instantiated.
45
+ If the application is already booted, it returns immediately.
46
+
47
+ Returns
48
+ -------
49
+ Application
50
+ The current instance of the application.
51
+
52
+ Raises
53
+ ------
54
+ Exception
55
+ If an error occurs during the boot process.
56
+ """
57
+ if self.booted:
58
+ return self
59
+
60
+ try:
61
+ # Register core services as singletons
62
+ self.container.singleton(CacheConfig)
63
+ self.container.singleton(Register)
64
+ self.container.singleton(Bootstrapper)
65
+
66
+ # Resolve the registered dependencies
67
+ self.container.make(Register)
68
+ self.container.make(Bootstrapper)
69
+
70
+ self.booted = True
71
+ return self
72
+
73
+ except Exception as e:
74
+ # Capture and store exception details
75
+ self.error_info = (e, traceback.format_exc())
76
+ raise
77
+
78
+ def isBooted(self):
79
+ """
80
+ Checks if the application has been successfully initialized.
81
+
82
+ Returns
83
+ -------
84
+ bool
85
+ True if the application has been booted, False otherwise.
86
+ """
87
+ return self.booted
88
+
89
+ def getError(self):
90
+ """
91
+ Retrieves the last stored error details.
92
+
93
+ Returns
94
+ -------
95
+ tuple or None
96
+ A tuple containing the exception instance and its formatted traceback if an error occurred;
97
+ otherwise, None.
98
+ """
99
+ return self.error_info
@@ -0,0 +1,58 @@
1
+ from orionis.luminate.app import Application
2
+
3
+ class AppContext:
4
+ """
5
+ Context manager for resolving dependencies within a valid Orionis application context.
6
+
7
+ This class ensures that Orionis is properly initialized before resolving dependencies,
8
+ similar to how Laravel’s `app()` helper works.
9
+
10
+ Methods
11
+ -------
12
+ __enter__()
13
+ Validates the application state and provides access to the service container.
14
+ __exit__(exc_type, exc_val, exc_tb)
15
+ Ensures exceptions propagate naturally.
16
+ """
17
+
18
+ def __enter__(self):
19
+ """
20
+ Validates that the Orionis application is booted before allowing access to the container.
21
+
22
+ Returns
23
+ -------
24
+ Container
25
+ The application’s IoC container instance.
26
+
27
+ Raises
28
+ ------
29
+ RuntimeError
30
+ If the application has not been properly initialized.
31
+ """
32
+ app = Application()
33
+ if not app.isBooted():
34
+ raise RuntimeError(
35
+ "Error: Not running within a valid Orionis Framework context. "
36
+ "Ensure that the Orionis application is correctly initialized."
37
+ )
38
+ return app
39
+
40
+ def __exit__(self, exc_type, exc_val, exc_tb):
41
+ """
42
+ Allows exceptions to propagate naturally.
43
+
44
+ Parameters
45
+ ----------
46
+ exc_type : type
47
+ The exception type, if an error occurred.
48
+ exc_val : Exception
49
+ The exception instance, if an error occurred.
50
+ exc_tb : traceback
51
+ The traceback object associated with the exception, if an error occurred.
52
+
53
+ Returns
54
+ -------
55
+ bool
56
+ Always returns False to ensure exceptions are not suppressed.
57
+ """
58
+ return False
@@ -1,10 +1,10 @@
1
- from orionis.luminate.container.container import Container
1
+ from orionis.luminate.app_context import AppContext
2
2
  from orionis.luminate.cache.app.config import CacheConfig
3
- from orionis.luminate.orionis import OrionisContext
4
3
 
5
4
  class Config:
6
5
 
7
6
  @staticmethod
8
7
  def get():
9
- with OrionisContext() as ctx:
10
- return ctx.container.make(CacheConfig).config
8
+ with AppContext() as app:
9
+ cache = app.container.make(CacheConfig)
10
+ return cache.config
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: orionis
3
- Version: 0.42.0
3
+ Version: 0.44.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,8 +1,9 @@
1
1
  orionis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  orionis/cli_manager.py,sha256=9wNVJxB0HyqUbNesUvkwlsqTyUbZwK6R46iVLE5WVBQ,1715
3
- orionis/framework.py,sha256=TlT7nkQG2E_adhasSB1bze9IufktITLC1x24P5H2Ubo,1386
3
+ orionis/framework.py,sha256=Wj1HoxN9EW_Vg3x2CXs8VpUC7sNRu-SnSmRw41kR6NI,1386
4
4
  orionis/luminate/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- orionis/luminate/orionis.py,sha256=HojY14tDsDZ38CeyOaQFMDsXz3hiTCbq8zscVsUmYls,3150
5
+ orionis/luminate/app.py,sha256=w7uUYbbLiGcpf_dOao6t0k0BJzXEJ2KC2zbfBHO3tvo,3231
6
+ orionis/luminate/app_context.py,sha256=XREVkOHU6aP8UB2daA2QbFcOCB8HRmcGXjVbrlW1AHQ,1827
6
7
  orionis/luminate/bootstrap/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
8
  orionis/luminate/bootstrap/cli_exception.py,sha256=wDKfEW295c7-bavr7YUHK2CLYcTSZgjT9ZRSBne6GOE,1356
8
9
  orionis/luminate/bootstrap/commands/bootstrapper.py,sha256=TuXuQUzeaiDL8sJyZNdqnFl2h2MfxcnSU045IeIKVQE,4016
@@ -108,7 +109,7 @@ orionis/luminate/contracts/tools/exception_to_dict_interface.py,sha256=rCuhx2tmU
108
109
  orionis/luminate/contracts/tools/reflection_interface.py,sha256=k9y7So3Z-_QFBBaCl-4t50ZRixt1pcxPtpwlo1NrSGk,8140
109
110
  orionis/luminate/contracts/tools/std_interface.py,sha256=VtOlmz7c1llBRVzKnEBA4aJE5m0Y0w7pFJ_1TgG1-G0,1408
110
111
  orionis/luminate/facades/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
111
- orionis/luminate/facades/config.py,sha256=5x-m8XNz_IEGNtnLqQ0rkRkVR2NCs_vPocbDOxZygow,324
112
+ orionis/luminate/facades/config.py,sha256=irQ42Ax_sNZR6iLz23PlFHy_vDxy4j-8nbx3F6YItRE,287
112
113
  orionis/luminate/facades/environment.py,sha256=HFnePQKzbBuJxKuL2bv3-6Fwm2xXeJdqDIpGTeY2HUM,2225
113
114
  orionis/luminate/facades/log.py,sha256=yHht-ok-eseVmwZgsAiHuFOS3MRLJ-YJrbG7VmHguMU,1643
114
115
  orionis/luminate/facades/paths.py,sha256=qXU9KvgNw54IsNc82_S66o198CA9bMZqO8wuCMW1Rnk,7300
@@ -147,9 +148,9 @@ tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
147
148
  tests/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
148
149
  tests/tools/class_example.py,sha256=dIPD997Y15n6WmKhWoOFSwEldRm9MdOHTZZ49eF1p3c,1056
149
150
  tests/tools/test_reflection.py,sha256=dNN5p_xAosyEf0ddAElmmmTfhcTtBd4zBNl7qzgnsc0,5242
150
- orionis-0.42.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
151
- orionis-0.42.0.dist-info/METADATA,sha256=4pDDzZVrM92tNXgB5Uv7WfdTmpyoBOW6iUCyv7fKsT0,2978
152
- orionis-0.42.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
153
- orionis-0.42.0.dist-info/entry_points.txt,sha256=eef1_CVewfokKjrGBynXa06KabSJYo7LlDKKIKvs1cM,53
154
- orionis-0.42.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
155
- orionis-0.42.0.dist-info/RECORD,,
151
+ orionis-0.44.0.dist-info/LICENCE,sha256=-_4cF2EBKuYVS_SQpy1uapq0oJPUU1vl_RUWSy2jJTo,1111
152
+ orionis-0.44.0.dist-info/METADATA,sha256=QM-a3AHCmNAm1mBdiGC6p2CrHx8C03S3YAVEF8kWi8o,2978
153
+ orionis-0.44.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
154
+ orionis-0.44.0.dist-info/entry_points.txt,sha256=eef1_CVewfokKjrGBynXa06KabSJYo7LlDKKIKvs1cM,53
155
+ orionis-0.44.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
156
+ orionis-0.44.0.dist-info/RECORD,,
@@ -1,109 +0,0 @@
1
- import traceback
2
- from orionis.luminate.container.container import Container
3
- from orionis.luminate.cache.app.config import CacheConfig
4
- from orionis.luminate.bootstrap.config.register import Register
5
- from orionis.luminate.bootstrap.config.bootstrapper import Bootstrapper
6
- from orionis.luminate.patterns.singleton import SingletonMeta
7
-
8
- class Orionis(metaclass=SingletonMeta):
9
- """
10
- Manages the Orionis application lifecycle, ensuring proper initialization
11
- and cleanup while handling exceptions.
12
- """
13
-
14
- def __init__(self):
15
- """Initialize Orionis with a container and setup state tracking."""
16
- self.container = None
17
- self.is_started = False
18
- self.error_info = None
19
-
20
- def __enter__(self):
21
- """
22
- Starts the Orionis application and registers required dependencies.
23
-
24
- Returns
25
- -------
26
- Orionis
27
- The initialized Orionis instance.
28
-
29
- Raises
30
- ------
31
- Exception
32
- If an error occurs during startup.
33
- """
34
- try:
35
- if self.is_started:
36
- return self
37
-
38
- self.container = Container()
39
-
40
- self.container.singleton(CacheConfig)
41
- self.container.singleton(Register)
42
- self.container.singleton(Bootstrapper)
43
-
44
- self.container.make(Register)
45
- self.container.make(Bootstrapper)
46
-
47
- self.is_started = True
48
- return self
49
-
50
- except Exception as e:
51
- self.error_info = (e, traceback.format_exc())
52
- raise
53
-
54
- def __exit__(self, exc_type, exc_val, exc_tb):
55
- """
56
- Cleans up resources and ensures proper shutdown.
57
-
58
- Returns
59
- -------
60
- bool
61
- False to propagate exceptions.
62
- """
63
- self.container = None
64
- self.is_started = False
65
-
66
- if exc_type:
67
- self.error_info = (exc_val, traceback.format_exc())
68
- return False
69
-
70
- def isStarted(self):
71
- """Check if Orionis is currently active."""
72
- return self.is_started
73
-
74
- def getError(self):
75
- """Retrieve stored error information."""
76
- return self.error_info
77
-
78
-
79
- class OrionisContext:
80
- """
81
- Ensures that Orionis is running within a valid context before allowing access
82
- to the dependency container.
83
- """
84
-
85
- def __enter__(self):
86
- """
87
- Validates that Orionis is active and provides access to its container.
88
-
89
- Returns
90
- -------
91
- Container
92
- The Orionis container instance.
93
-
94
- Raises
95
- ------
96
- RuntimeError
97
- If Orionis is not running.
98
- """
99
- orionis = Orionis()
100
- if not orionis.isStarted():
101
- raise RuntimeError(
102
- "Error: Not running within a valid Orionis Framework context. "
103
- "Ensure that the Orionis application is correctly initialized."
104
- )
105
- return orionis
106
-
107
- def __exit__(self, exc_type, exc_val, exc_tb):
108
- """Ensures exceptions propagate naturally."""
109
- return False