orionis 0.632.0__py3-none-any.whl → 0.634.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/foundation/application.py +165 -122
- orionis/foundation/contracts/application.py +66 -26
- orionis/metadata/framework.py +1 -1
- {orionis-0.632.0.dist-info → orionis-0.634.0.dist-info}/METADATA +1 -1
- {orionis-0.632.0.dist-info → orionis-0.634.0.dist-info}/RECORD +8 -8
- {orionis-0.632.0.dist-info → orionis-0.634.0.dist-info}/WHEEL +0 -0
- {orionis-0.632.0.dist-info → orionis-0.634.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.632.0.dist-info → orionis-0.634.0.dist-info}/top_level.txt +0 -0
|
@@ -131,15 +131,14 @@ class Application(Container, IApplication):
|
|
|
131
131
|
# Propierty to store service providers.
|
|
132
132
|
self.__providers: List[IServiceProvider, Any] = []
|
|
133
133
|
|
|
134
|
-
# Property to store configurators and paths
|
|
135
|
-
self.__configurators : dict = {}
|
|
136
|
-
|
|
137
134
|
# Property to indicate if the application has been booted
|
|
138
135
|
self.__booted: bool = False
|
|
136
|
+
self.__configured: bool = False
|
|
139
137
|
|
|
140
|
-
#
|
|
141
|
-
# This will be initialized with default values or from configurators
|
|
138
|
+
# Properties to store configuration and runtime configuration
|
|
142
139
|
self.__config: dict = {}
|
|
140
|
+
self.__runtime_config: dict = {}
|
|
141
|
+
self.__runtime_path_config: dict = {}
|
|
143
142
|
|
|
144
143
|
# Property to store the scheduler instance
|
|
145
144
|
self.__scheduler: BaseScheduler = None
|
|
@@ -205,6 +204,7 @@ class Application(Container, IApplication):
|
|
|
205
204
|
ensure core framework services are available before any user-defined
|
|
206
205
|
providers are registered.
|
|
207
206
|
"""
|
|
207
|
+
|
|
208
208
|
# Import core framework providers
|
|
209
209
|
from orionis.foundation.providers.catch_provider import CathcProvider
|
|
210
210
|
from orionis.foundation.providers.cli_request_provider import CLRequestProvider
|
|
@@ -278,6 +278,10 @@ class Application(Container, IApplication):
|
|
|
278
278
|
registration.
|
|
279
279
|
"""
|
|
280
280
|
|
|
281
|
+
# Validate providers parameter
|
|
282
|
+
if not isinstance(providers, list):
|
|
283
|
+
raise OrionisTypeError(f"Expected list of IServiceProvider classes, got {type(providers).__name__}")
|
|
284
|
+
|
|
281
285
|
# Add each provider class
|
|
282
286
|
for provider_cls in providers:
|
|
283
287
|
|
|
@@ -413,7 +417,7 @@ class Application(Container, IApplication):
|
|
|
413
417
|
- This method is called automatically during application bootstrapping, after all providers
|
|
414
418
|
have been registered.
|
|
415
419
|
- Supports both synchronous and asynchronous `boot()` methods on providers.
|
|
416
|
-
- The providers list is
|
|
420
|
+
- The providers list is deleted after booting to optimize memory usage.
|
|
417
421
|
|
|
418
422
|
Returns
|
|
419
423
|
-------
|
|
@@ -437,8 +441,8 @@ class Application(Container, IApplication):
|
|
|
437
441
|
else:
|
|
438
442
|
boot_method()
|
|
439
443
|
|
|
440
|
-
#
|
|
441
|
-
self.__providers
|
|
444
|
+
# Delete the providers list property to free memory after booting is complete
|
|
445
|
+
del self.__providers
|
|
442
446
|
|
|
443
447
|
# === Application Skeleton Configuration Methods ===
|
|
444
448
|
# The Orionis framework provides methods to configure each component of the application,
|
|
@@ -786,7 +790,7 @@ class Application(Container, IApplication):
|
|
|
786
790
|
raise OrionisTypeError(f"Expected App instance or dict, got {type(app).__name__}")
|
|
787
791
|
|
|
788
792
|
# Store the configuration dictionary in internal configurators
|
|
789
|
-
self.
|
|
793
|
+
self.__config['app'] = _app
|
|
790
794
|
|
|
791
795
|
# Return self for method chaining
|
|
792
796
|
return self
|
|
@@ -882,7 +886,7 @@ class Application(Container, IApplication):
|
|
|
882
886
|
raise OrionisTypeError(f"Expected Auth instance or dict, got {type(auth).__name__}")
|
|
883
887
|
|
|
884
888
|
# Store the configuration dictionary in internal configurators
|
|
885
|
-
self.
|
|
889
|
+
self.__config['auth'] = _auth
|
|
886
890
|
|
|
887
891
|
# Return self for method chaining
|
|
888
892
|
return self
|
|
@@ -978,7 +982,7 @@ class Application(Container, IApplication):
|
|
|
978
982
|
raise OrionisTypeError(f"Expected Cache instance or dict, got {type(cache).__name__}")
|
|
979
983
|
|
|
980
984
|
# Store the configuration dictionary in internal configurators
|
|
981
|
-
self.
|
|
985
|
+
self.__config['cache'] = _cache
|
|
982
986
|
|
|
983
987
|
# Return self for method chaining
|
|
984
988
|
return self
|
|
@@ -1074,7 +1078,7 @@ class Application(Container, IApplication):
|
|
|
1074
1078
|
raise OrionisTypeError(f"Expected Cors instance or dict, got {type(cors).__name__}")
|
|
1075
1079
|
|
|
1076
1080
|
# Store the configuration dictionary in internal configurators
|
|
1077
|
-
self.
|
|
1081
|
+
self.__config['cors'] = _cors
|
|
1078
1082
|
|
|
1079
1083
|
# Return self for method chaining
|
|
1080
1084
|
return self
|
|
@@ -1170,7 +1174,7 @@ class Application(Container, IApplication):
|
|
|
1170
1174
|
raise OrionisTypeError(f"Expected Database instance or dict, got {type(database).__name__}")
|
|
1171
1175
|
|
|
1172
1176
|
# Store the configuration dictionary in internal configurators
|
|
1173
|
-
self.
|
|
1177
|
+
self.__config['database'] = _database
|
|
1174
1178
|
|
|
1175
1179
|
# Return self for method chaining
|
|
1176
1180
|
return self
|
|
@@ -1266,7 +1270,7 @@ class Application(Container, IApplication):
|
|
|
1266
1270
|
raise OrionisTypeError(f"Expected Filesystems instance or dict, got {type(filesystems).__name__}")
|
|
1267
1271
|
|
|
1268
1272
|
# Store the configuration dictionary in internal configurators
|
|
1269
|
-
self.
|
|
1273
|
+
self.__config['filesystems'] = _filesystems
|
|
1270
1274
|
|
|
1271
1275
|
# Return self for method chaining
|
|
1272
1276
|
return self
|
|
@@ -1362,7 +1366,7 @@ class Application(Container, IApplication):
|
|
|
1362
1366
|
raise OrionisTypeError(f"Expected Logging instance or dict, got {type(logging).__name__}")
|
|
1363
1367
|
|
|
1364
1368
|
# Store the configuration dictionary in internal configurators
|
|
1365
|
-
self.
|
|
1369
|
+
self.__config['logging'] = _logging
|
|
1366
1370
|
|
|
1367
1371
|
# Return self for method chaining
|
|
1368
1372
|
return self
|
|
@@ -1458,7 +1462,7 @@ class Application(Container, IApplication):
|
|
|
1458
1462
|
raise OrionisTypeError(f"Expected Mail instance or dict, got {type(mail).__name__}")
|
|
1459
1463
|
|
|
1460
1464
|
# Store the configuration dictionary in internal configurators
|
|
1461
|
-
self.
|
|
1465
|
+
self.__config['mail'] = _mail
|
|
1462
1466
|
|
|
1463
1467
|
# Return self for method chaining
|
|
1464
1468
|
return self
|
|
@@ -1554,7 +1558,7 @@ class Application(Container, IApplication):
|
|
|
1554
1558
|
raise OrionisTypeError(f"Expected Queue instance or dict, got {type(queue).__name__}")
|
|
1555
1559
|
|
|
1556
1560
|
# Store the configuration dictionary in internal configurators
|
|
1557
|
-
self.
|
|
1561
|
+
self.__config['queue'] = _queue
|
|
1558
1562
|
|
|
1559
1563
|
# Return self for method chaining
|
|
1560
1564
|
return self
|
|
@@ -1650,7 +1654,7 @@ class Application(Container, IApplication):
|
|
|
1650
1654
|
raise OrionisTypeError(f"Expected Session instance or dict, got {type(session).__name__}")
|
|
1651
1655
|
|
|
1652
1656
|
# Store the configuration dictionary in internal configurators
|
|
1653
|
-
self.
|
|
1657
|
+
self.__config['session'] = _session
|
|
1654
1658
|
|
|
1655
1659
|
# Return self for method chaining
|
|
1656
1660
|
return self
|
|
@@ -1746,7 +1750,7 @@ class Application(Container, IApplication):
|
|
|
1746
1750
|
raise OrionisTypeError(f"Expected Testing instance or dict, got {type(testing).__name__}")
|
|
1747
1751
|
|
|
1748
1752
|
# Store the configuration dictionary in internal configurators
|
|
1749
|
-
self.
|
|
1753
|
+
self.__config['testing'] = _testing
|
|
1750
1754
|
|
|
1751
1755
|
# Return self for method chaining
|
|
1752
1756
|
return self
|
|
@@ -1802,25 +1806,25 @@ class Application(Container, IApplication):
|
|
|
1802
1806
|
Returns the current Application instance to enable method chaining.
|
|
1803
1807
|
"""
|
|
1804
1808
|
|
|
1805
|
-
self.
|
|
1806
|
-
'root':
|
|
1807
|
-
'app':
|
|
1808
|
-
'console':
|
|
1809
|
-
'exceptions':
|
|
1810
|
-
'http':
|
|
1811
|
-
'models':
|
|
1812
|
-
'providers':
|
|
1813
|
-
'notifications':
|
|
1814
|
-
'services':
|
|
1815
|
-
'jobs':
|
|
1816
|
-
'bootstrap':
|
|
1817
|
-
'config':
|
|
1818
|
-
'database':
|
|
1819
|
-
'resources':
|
|
1820
|
-
'routes':
|
|
1821
|
-
'storage':
|
|
1822
|
-
'tests':
|
|
1823
|
-
}
|
|
1809
|
+
self.loadConfigPaths({
|
|
1810
|
+
'root': root,
|
|
1811
|
+
'app': app,
|
|
1812
|
+
'console': console,
|
|
1813
|
+
'exceptions': exceptions,
|
|
1814
|
+
'http': http,
|
|
1815
|
+
'models': models,
|
|
1816
|
+
'providers': providers,
|
|
1817
|
+
'notifications': notifications,
|
|
1818
|
+
'services': services,
|
|
1819
|
+
'jobs': jobs,
|
|
1820
|
+
'bootstrap': bootstrap,
|
|
1821
|
+
'config': config,
|
|
1822
|
+
'database': database,
|
|
1823
|
+
'resources': resources,
|
|
1824
|
+
'routes': routes,
|
|
1825
|
+
'storage': storage,
|
|
1826
|
+
'tests': tests
|
|
1827
|
+
})
|
|
1824
1828
|
|
|
1825
1829
|
return self
|
|
1826
1830
|
|
|
@@ -1878,7 +1882,7 @@ class Application(Container, IApplication):
|
|
|
1878
1882
|
raise OrionisTypeError(f"Expected Paths instance or dict, got {type(paths).__name__}")
|
|
1879
1883
|
|
|
1880
1884
|
# Store the configuration dictionary in internal configurators
|
|
1881
|
-
self.
|
|
1885
|
+
self.__config['path'] = _paths
|
|
1882
1886
|
|
|
1883
1887
|
# Return self for method chaining
|
|
1884
1888
|
return self
|
|
@@ -1911,17 +1915,16 @@ class Application(Container, IApplication):
|
|
|
1911
1915
|
# Try to load the configuration
|
|
1912
1916
|
try:
|
|
1913
1917
|
|
|
1914
|
-
# Check if
|
|
1918
|
+
# Check if there are any configurators set
|
|
1915
1919
|
if not self.__config:
|
|
1920
|
+
self.__config = Configuration().toDict()
|
|
1916
1921
|
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1922
|
+
# Store copy of the config as runtime config
|
|
1923
|
+
# Copy all config except the 'path' key
|
|
1924
|
+
self.__runtime_config = {k: v for k, v in self.__config.items() if k != 'path'}
|
|
1920
1925
|
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
self.__config = self.__configurators
|
|
1924
|
-
del self.__configurators
|
|
1926
|
+
# Copy contains only the 'path' key
|
|
1927
|
+
self.__runtime_path_config = self.__config.get('path', {})
|
|
1925
1928
|
|
|
1926
1929
|
except Exception as e:
|
|
1927
1930
|
|
|
@@ -1936,87 +1939,101 @@ class Application(Container, IApplication):
|
|
|
1936
1939
|
|
|
1937
1940
|
def config(
|
|
1938
1941
|
self,
|
|
1939
|
-
key: str = None
|
|
1942
|
+
key: str = None,
|
|
1943
|
+
value: Any = None
|
|
1940
1944
|
) -> Any:
|
|
1941
1945
|
"""
|
|
1942
|
-
Retrieve application configuration values using dot notation.
|
|
1946
|
+
Retrieve or set application configuration values using dot notation.
|
|
1943
1947
|
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
If
|
|
1947
|
-
If no key is provided, it returns the entire configuration dictionary, excluding
|
|
1948
|
-
path-related configuration (which should be accessed via the `path()` method).
|
|
1948
|
+
If only `key` is provided, returns the configuration value for that key.
|
|
1949
|
+
If both `key` and `value` are provided, sets the configuration value.
|
|
1950
|
+
If neither is provided, returns the entire configuration dictionary (excluding 'path').
|
|
1949
1951
|
|
|
1950
1952
|
Parameters
|
|
1951
1953
|
----------
|
|
1952
1954
|
key : str, optional
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
the
|
|
1956
|
-
Default is None.
|
|
1955
|
+
Dot-notated configuration key (e.g., "database.default"). If None, returns all config.
|
|
1956
|
+
value : Any, optional
|
|
1957
|
+
Value to set for the given key. If None, performs a get operation.
|
|
1957
1958
|
|
|
1958
1959
|
Returns
|
|
1959
1960
|
-------
|
|
1960
1961
|
Any
|
|
1961
|
-
|
|
1962
|
-
If `key` is None, returns the entire configuration dictionary (excluding 'path').
|
|
1963
|
-
If the key is not found, returns None.
|
|
1962
|
+
The configuration value, or None if not found.
|
|
1964
1963
|
|
|
1965
1964
|
Raises
|
|
1966
1965
|
------
|
|
1967
1966
|
OrionisRuntimeError
|
|
1968
|
-
If
|
|
1969
|
-
has not been called before accessing configuration).
|
|
1967
|
+
If configuration is not initialized.
|
|
1970
1968
|
OrionisValueError
|
|
1971
|
-
If
|
|
1972
|
-
|
|
1973
|
-
Notes
|
|
1974
|
-
-----
|
|
1975
|
-
The method traverses nested configuration structures by splitting the key
|
|
1976
|
-
on dots and navigating through dictionary levels. Path configurations are
|
|
1977
|
-
excluded from full configuration returns and should be accessed via the
|
|
1978
|
-
`path()` method instead.
|
|
1969
|
+
If key is not a string.
|
|
1979
1970
|
"""
|
|
1980
1971
|
|
|
1981
|
-
|
|
1982
|
-
if not hasattr(self, '_Application__runtime_config') or self.__runtime_config is None:
|
|
1983
|
-
self.__runtime_config = self.__config.copy()
|
|
1984
|
-
|
|
1985
|
-
# Remove 'path' from the local copy to ensure path config is not returned here
|
|
1986
|
-
if 'path' in self.__runtime_config:
|
|
1987
|
-
del self.__runtime_config['path']
|
|
1988
|
-
|
|
1989
|
-
# Ensure the application is booted before accessing configuration
|
|
1990
|
-
if not self.__runtime_config:
|
|
1972
|
+
if not self.__configured:
|
|
1991
1973
|
raise OrionisRuntimeError(
|
|
1992
1974
|
"Application configuration is not initialized. Please call create() before accessing configuration."
|
|
1993
1975
|
)
|
|
1994
1976
|
|
|
1995
|
-
#
|
|
1996
|
-
if key is None:
|
|
1977
|
+
# Return all config if no key is provided
|
|
1978
|
+
if key is None and value is None:
|
|
1997
1979
|
return self.__runtime_config
|
|
1998
1980
|
|
|
1999
|
-
# Ensure the key is a string
|
|
2000
1981
|
if not isinstance(key, str):
|
|
2001
1982
|
raise OrionisValueError(
|
|
2002
|
-
"
|
|
1983
|
+
"The configuration key must be a string. To retrieve the entire configuration, call config() without any arguments."
|
|
2003
1984
|
)
|
|
2004
1985
|
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
#
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
1986
|
+
key_parts = key.split('.')
|
|
1987
|
+
config_dict = self.__runtime_config
|
|
1988
|
+
|
|
1989
|
+
# If setting a value
|
|
1990
|
+
if value is not None:
|
|
1991
|
+
current_dict = config_dict
|
|
1992
|
+
for part in key_parts[:-1]:
|
|
1993
|
+
if part not in current_dict or not isinstance(current_dict[part], dict):
|
|
1994
|
+
current_dict[part] = {}
|
|
1995
|
+
current_dict = current_dict[part]
|
|
1996
|
+
current_dict[key_parts[-1]] = value
|
|
1997
|
+
return value
|
|
1998
|
+
|
|
1999
|
+
# Getting a value
|
|
2000
|
+
current_dict = config_dict
|
|
2001
|
+
for part in key_parts:
|
|
2002
|
+
if isinstance(current_dict, dict) and part in current_dict:
|
|
2003
|
+
current_dict = current_dict[part]
|
|
2014
2004
|
else:
|
|
2015
|
-
# If any part is missing, return None
|
|
2016
2005
|
return None
|
|
2006
|
+
return current_dict
|
|
2007
|
+
|
|
2008
|
+
def resetConfig(
|
|
2009
|
+
self
|
|
2010
|
+
) -> 'Application':
|
|
2011
|
+
"""
|
|
2012
|
+
Reset the application configuration to an uninitialized state.
|
|
2013
|
+
|
|
2014
|
+
This method clears the current runtime configuration and marks the application
|
|
2015
|
+
as unconfigured, allowing for re-initialization of the configuration by calling
|
|
2016
|
+
`create()` again. This is useful in scenarios such as testing or when dynamic
|
|
2017
|
+
reloading of configuration is required.
|
|
2018
|
+
|
|
2019
|
+
Notes
|
|
2020
|
+
-----
|
|
2021
|
+
- After calling this method, you must call `create()` to reinitialize
|
|
2022
|
+
the configuration before accessing it again.
|
|
2023
|
+
- This method does not affect other aspects of the application state,
|
|
2024
|
+
such as registered providers or boot status.
|
|
2025
|
+
|
|
2026
|
+
Returns
|
|
2027
|
+
-------
|
|
2028
|
+
Application
|
|
2029
|
+
Returns the current `Application` instance to enable method chaining.
|
|
2030
|
+
"""
|
|
2031
|
+
|
|
2032
|
+
# Reset the runtime configuration to match the current config (excluding 'path')
|
|
2033
|
+
self.__runtime_config = {k: v for k, v in self.__config.items() if k != 'path'}
|
|
2017
2034
|
|
|
2018
|
-
# Return the
|
|
2019
|
-
return
|
|
2035
|
+
# Return the application instance for method chaining
|
|
2036
|
+
return self
|
|
2020
2037
|
|
|
2021
2038
|
# === Path Configuration Access Method ===
|
|
2022
2039
|
# The path() method provides access to application path configurations.
|
|
@@ -2030,7 +2047,7 @@ class Application(Container, IApplication):
|
|
|
2030
2047
|
"""
|
|
2031
2048
|
Retrieve application path configuration values using dot notation.
|
|
2032
2049
|
|
|
2033
|
-
|
|
2050
|
+
This method provides access to the application's path configuration, allowing retrieval of either a specific path value or the entire paths configuration dictionary. If a key is provided, the corresponding path is returned as a `Path` object. If no key is provided, a dictionary mapping all path configuration keys to their resolved `Path` objects is returned.
|
|
2034
2051
|
|
|
2035
2052
|
Parameters
|
|
2036
2053
|
----------
|
|
@@ -2042,7 +2059,7 @@ class Application(Container, IApplication):
|
|
|
2042
2059
|
-------
|
|
2043
2060
|
Path or dict
|
|
2044
2061
|
If `key` is provided and found, returns the resolved `Path` object for that key.
|
|
2045
|
-
If `key` is None, returns a dictionary mapping all path keys to their `Path` objects.
|
|
2062
|
+
If `key` is None, returns a dictionary mapping all path keys to their resolved `Path` objects.
|
|
2046
2063
|
If `key` is not found, returns None.
|
|
2047
2064
|
|
|
2048
2065
|
Raises
|
|
@@ -2058,23 +2075,21 @@ class Application(Container, IApplication):
|
|
|
2058
2075
|
- This method is specifically designed for path-related configuration access, separate from general application configuration.
|
|
2059
2076
|
- All returned paths are resolved as `Path` objects for consistency and ease of use.
|
|
2060
2077
|
"""
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
if not hasattr(self, '_Application__runtime_path_config') or self.__runtime_path_config is None:
|
|
2064
|
-
self.__runtime_path_config = self.__config.get('path', {}).copy() if self.__config else {}
|
|
2065
|
-
|
|
2066
|
-
# Ensure the application is booted before accessing configuration
|
|
2067
|
-
if not self.__runtime_path_config:
|
|
2078
|
+
# Ensure the application configuration has been initialized
|
|
2079
|
+
if not self.__configured:
|
|
2068
2080
|
raise OrionisRuntimeError(
|
|
2069
|
-
"Application configuration is not initialized. Please call create() before accessing
|
|
2081
|
+
"Application configuration is not initialized. Please call create() before accessing configuration."
|
|
2070
2082
|
)
|
|
2071
2083
|
|
|
2072
2084
|
# If no key is provided, return all paths as a dictionary of Path objects
|
|
2073
2085
|
if key is None:
|
|
2074
2086
|
path_resolved: Dict[str, Path] = {}
|
|
2087
|
+
# Convert all path values to Path objects
|
|
2075
2088
|
for k, v in self.__runtime_path_config.items():
|
|
2076
|
-
|
|
2077
|
-
|
|
2089
|
+
if not isinstance(v, Path):
|
|
2090
|
+
path_resolved[k] = Path(v)
|
|
2091
|
+
else:
|
|
2092
|
+
path_resolved[k] = v
|
|
2078
2093
|
return path_resolved
|
|
2079
2094
|
|
|
2080
2095
|
# Ensure the key is a string
|
|
@@ -2117,9 +2132,8 @@ class Application(Container, IApplication):
|
|
|
2117
2132
|
1. Load and process all configuration from configurators
|
|
2118
2133
|
2. Register core framework service providers
|
|
2119
2134
|
3. Register and boot all service providers
|
|
2120
|
-
4. Initialize framework kernels
|
|
2121
|
-
5.
|
|
2122
|
-
6. Mark application as booted to prevent re-initialization
|
|
2135
|
+
4. Initialize framework kernels
|
|
2136
|
+
5. Mark application as booted to prevent re-initialization
|
|
2123
2137
|
|
|
2124
2138
|
This method is idempotent - calling it multiple times will not cause
|
|
2125
2139
|
duplicate initialization. The startup time is calculated and logged
|
|
@@ -2139,6 +2153,7 @@ class Application(Container, IApplication):
|
|
|
2139
2153
|
|
|
2140
2154
|
# Load configuration if not already set
|
|
2141
2155
|
self.__loadConfig()
|
|
2156
|
+
self.__configured = True
|
|
2142
2157
|
|
|
2143
2158
|
# Load framework providers and register them
|
|
2144
2159
|
self.__loadFrameworkProviders()
|
|
@@ -2151,15 +2166,6 @@ class Application(Container, IApplication):
|
|
|
2151
2166
|
# Load core framework kernels with app booted
|
|
2152
2167
|
self.__loadFrameworksKernel()
|
|
2153
2168
|
|
|
2154
|
-
# Retrieve logger and console instances from the container
|
|
2155
|
-
logger: ILogger = self.make(ILogger)
|
|
2156
|
-
|
|
2157
|
-
# Calculate elapsed time in milliseconds since application start
|
|
2158
|
-
elapsed_ms = (time.time_ns() - self.startAt) // 1_000_000
|
|
2159
|
-
|
|
2160
|
-
# Log message to the logger
|
|
2161
|
-
logger.info(f"Orionis Framework has been successfully booted. Startup time: {elapsed_ms} ms. Started at: {self.startAt} ns")
|
|
2162
|
-
|
|
2163
2169
|
# Return the application instance for method chaining
|
|
2164
2170
|
return self
|
|
2165
2171
|
|
|
@@ -2198,4 +2204,41 @@ class Application(Container, IApplication):
|
|
|
2198
2204
|
)
|
|
2199
2205
|
|
|
2200
2206
|
# Return True if the environment is 'production', otherwise False
|
|
2201
|
-
return str(app_env).lower() == 'production'
|
|
2207
|
+
return str(app_env).lower() == 'production'
|
|
2208
|
+
|
|
2209
|
+
def isDebug(
|
|
2210
|
+
self
|
|
2211
|
+
) -> bool:
|
|
2212
|
+
"""
|
|
2213
|
+
Check if the application is running in debug mode.
|
|
2214
|
+
|
|
2215
|
+
This method determines whether the current application is set to run in debug mode.
|
|
2216
|
+
It checks the 'app.debug' configuration value to make this determination.
|
|
2217
|
+
|
|
2218
|
+
Returns
|
|
2219
|
+
-------
|
|
2220
|
+
bool
|
|
2221
|
+
True if the application is in debug mode, False otherwise.
|
|
2222
|
+
|
|
2223
|
+
Raises
|
|
2224
|
+
------
|
|
2225
|
+
OrionisRuntimeError
|
|
2226
|
+
If the application configuration has not been initialized (i.e., if `create()` has not been called).
|
|
2227
|
+
|
|
2228
|
+
Notes
|
|
2229
|
+
-----
|
|
2230
|
+
The debug mode is typically defined in the application configuration and can be enabled or disabled based on the environment or specific settings.
|
|
2231
|
+
This method is useful for conditionally executing code based on whether debugging features should be active, such as detailed error reporting or verbose logging.
|
|
2232
|
+
"""
|
|
2233
|
+
|
|
2234
|
+
# Retrieve the current debug setting from configuration
|
|
2235
|
+
app_debug = self.config('app.debug')
|
|
2236
|
+
|
|
2237
|
+
# Ensure the application is booted before accessing configuration
|
|
2238
|
+
if app_debug is None:
|
|
2239
|
+
raise OrionisRuntimeError(
|
|
2240
|
+
"Application configuration is not initialized. Please call create() before checking the debug mode."
|
|
2241
|
+
)
|
|
2242
|
+
|
|
2243
|
+
# Return True if the debug mode is enabled, otherwise False
|
|
2244
|
+
return bool(app_debug)
|
|
@@ -1133,46 +1133,60 @@ class IApplication(IContainer):
|
|
|
1133
1133
|
@abstractmethod
|
|
1134
1134
|
def config(
|
|
1135
1135
|
self,
|
|
1136
|
-
key: str = None
|
|
1136
|
+
key: str = None,
|
|
1137
|
+
value: Any = None
|
|
1137
1138
|
) -> Any:
|
|
1138
1139
|
"""
|
|
1139
|
-
Retrieve application configuration values using dot notation.
|
|
1140
|
+
Retrieve or set application configuration values using dot notation.
|
|
1140
1141
|
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
If
|
|
1144
|
-
If no key is provided, it returns the entire configuration dictionary, excluding
|
|
1145
|
-
path-related configuration (which should be accessed via the `path()` method).
|
|
1142
|
+
If only `key` is provided, returns the configuration value for that key.
|
|
1143
|
+
If both `key` and `value` are provided, sets the configuration value.
|
|
1144
|
+
If neither is provided, returns the entire configuration dictionary (excluding 'path').
|
|
1146
1145
|
|
|
1147
1146
|
Parameters
|
|
1148
1147
|
----------
|
|
1149
1148
|
key : str, optional
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
the
|
|
1153
|
-
Default is None.
|
|
1149
|
+
Dot-notated configuration key (e.g., "database.default"). If None, returns all config.
|
|
1150
|
+
value : Any, optional
|
|
1151
|
+
Value to set for the given key. If None, performs a get operation.
|
|
1154
1152
|
|
|
1155
1153
|
Returns
|
|
1156
1154
|
-------
|
|
1157
1155
|
Any
|
|
1158
|
-
|
|
1159
|
-
If `key` is None, returns the entire configuration dictionary (excluding 'path').
|
|
1160
|
-
If the key is not found, returns None.
|
|
1156
|
+
The configuration value, or None if not found.
|
|
1161
1157
|
|
|
1162
1158
|
Raises
|
|
1163
1159
|
------
|
|
1164
1160
|
OrionisRuntimeError
|
|
1165
|
-
If
|
|
1166
|
-
has not been called before accessing configuration).
|
|
1161
|
+
If configuration is not initialized.
|
|
1167
1162
|
OrionisValueError
|
|
1168
|
-
If
|
|
1163
|
+
If key is not a string.
|
|
1164
|
+
"""
|
|
1165
|
+
pass
|
|
1166
|
+
|
|
1167
|
+
@abstractmethod
|
|
1168
|
+
def resetConfig(
|
|
1169
|
+
self
|
|
1170
|
+
) -> 'IApplication':
|
|
1171
|
+
"""
|
|
1172
|
+
Reset the application configuration to an uninitialized state.
|
|
1173
|
+
|
|
1174
|
+
This method clears the current runtime configuration and marks the application
|
|
1175
|
+
as unconfigured, allowing for re-initialization of the configuration by calling
|
|
1176
|
+
`create()` again. This is useful in scenarios such as testing or when dynamic
|
|
1177
|
+
reloading of configuration is required.
|
|
1169
1178
|
|
|
1170
1179
|
Notes
|
|
1171
1180
|
-----
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1181
|
+
- After calling this method, you must call `create()` to reinitialize
|
|
1182
|
+
the configuration before accessing it again.
|
|
1183
|
+
- This method does not affect other aspects of the application state,
|
|
1184
|
+
such as registered providers or boot status.
|
|
1185
|
+
|
|
1186
|
+
Returns
|
|
1187
|
+
-------
|
|
1188
|
+
Application
|
|
1189
|
+
Returns the current `Application` instance to enable method chaining.
|
|
1176
1190
|
"""
|
|
1177
1191
|
pass
|
|
1178
1192
|
|
|
@@ -1184,7 +1198,7 @@ class IApplication(IContainer):
|
|
|
1184
1198
|
"""
|
|
1185
1199
|
Retrieve application path configuration values using dot notation.
|
|
1186
1200
|
|
|
1187
|
-
|
|
1201
|
+
This method provides access to the application's path configuration, allowing retrieval of either a specific path value or the entire paths configuration dictionary. If a key is provided, the corresponding path is returned as a `Path` object. If no key is provided, a dictionary mapping all path configuration keys to their resolved `Path` objects is returned.
|
|
1188
1202
|
|
|
1189
1203
|
Parameters
|
|
1190
1204
|
----------
|
|
@@ -1196,7 +1210,7 @@ class IApplication(IContainer):
|
|
|
1196
1210
|
-------
|
|
1197
1211
|
Path or dict
|
|
1198
1212
|
If `key` is provided and found, returns the resolved `Path` object for that key.
|
|
1199
|
-
If `key` is None, returns a dictionary mapping all path keys to their `Path` objects.
|
|
1213
|
+
If `key` is None, returns a dictionary mapping all path keys to their resolved `Path` objects.
|
|
1200
1214
|
If `key` is not found, returns None.
|
|
1201
1215
|
|
|
1202
1216
|
Raises
|
|
@@ -1237,9 +1251,8 @@ class IApplication(IContainer):
|
|
|
1237
1251
|
1. Load and process all configuration from configurators
|
|
1238
1252
|
2. Register core framework service providers
|
|
1239
1253
|
3. Register and boot all service providers
|
|
1240
|
-
4. Initialize framework kernels
|
|
1241
|
-
5.
|
|
1242
|
-
6. Mark application as booted to prevent re-initialization
|
|
1254
|
+
4. Initialize framework kernels
|
|
1255
|
+
5. Mark application as booted to prevent re-initialization
|
|
1243
1256
|
|
|
1244
1257
|
This method is idempotent - calling it multiple times will not cause
|
|
1245
1258
|
duplicate initialization. The startup time is calculated and logged
|
|
@@ -1272,4 +1285,31 @@ class IApplication(IContainer):
|
|
|
1272
1285
|
The environment is typically defined in the application configuration and can be set to values such as 'development', 'testing', or 'production'.
|
|
1273
1286
|
This method is useful for conditionally executing code based on the environment, such as enabling/disabling debug features or logging verbosity.
|
|
1274
1287
|
"""
|
|
1288
|
+
pass
|
|
1289
|
+
|
|
1290
|
+
@abstractmethod
|
|
1291
|
+
def isDebug(
|
|
1292
|
+
self
|
|
1293
|
+
) -> bool:
|
|
1294
|
+
"""
|
|
1295
|
+
Check if the application is running in debug mode.
|
|
1296
|
+
|
|
1297
|
+
This method determines whether the current application is set to run in debug mode.
|
|
1298
|
+
It checks the 'app.debug' configuration value to make this determination.
|
|
1299
|
+
|
|
1300
|
+
Returns
|
|
1301
|
+
-------
|
|
1302
|
+
bool
|
|
1303
|
+
True if the application is in debug mode, False otherwise.
|
|
1304
|
+
|
|
1305
|
+
Raises
|
|
1306
|
+
------
|
|
1307
|
+
OrionisRuntimeError
|
|
1308
|
+
If the application configuration has not been initialized (i.e., if `create()` has not been called).
|
|
1309
|
+
|
|
1310
|
+
Notes
|
|
1311
|
+
-----
|
|
1312
|
+
The debug mode is typically defined in the application configuration and can be enabled or disabled based on the environment or specific settings.
|
|
1313
|
+
This method is useful for conditionally executing code based on whether debugging features should be active, such as detailed error reporting or verbose logging.
|
|
1314
|
+
"""
|
|
1275
1315
|
pass
|
orionis/metadata/framework.py
CHANGED
|
@@ -103,7 +103,7 @@ orionis/failure/contracts/handler.py,sha256=AeJfkJfD3hTkOIYAtADq6GnQfq-qWgDfUc7b
|
|
|
103
103
|
orionis/failure/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
104
104
|
orionis/failure/entities/throwable.py,sha256=1zD-awcuAyEtlR-L7V7ZIfPSF4GpXkf-neL5sXul7dc,1240
|
|
105
105
|
orionis/foundation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
106
|
-
orionis/foundation/application.py,sha256=
|
|
106
|
+
orionis/foundation/application.py,sha256=DTg5NdUcW9ACtXNF53KOzfRcqck3JlhjwHTpCzb8wE0,91465
|
|
107
107
|
orionis/foundation/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
108
108
|
orionis/foundation/config/startup.py,sha256=btqvryeIf9lLNQ9fBff7bJMrfraEY8qrWi4y_5YAR0Q,9681
|
|
109
109
|
orionis/foundation/config/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -197,7 +197,7 @@ orionis/foundation/config/testing/enums/drivers.py,sha256=mwv47FcKDXEOxydQXAGtkd
|
|
|
197
197
|
orionis/foundation/config/testing/enums/mode.py,sha256=IbFpauu7J-iSAfmC8jDbmTEYl8eZr-AexL-lyOh8_74,337
|
|
198
198
|
orionis/foundation/config/testing/enums/verbosity.py,sha256=Z-FQ6C3rxbRwP8HoVibbgRMGcsen2SwTuEy3wnjdIhc,486
|
|
199
199
|
orionis/foundation/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
200
|
-
orionis/foundation/contracts/application.py,sha256=
|
|
200
|
+
orionis/foundation/contracts/application.py,sha256=CalEKcEKDWB6zawr0XQrNVL7ap768IpfdhE7CVY3Kjg,47884
|
|
201
201
|
orionis/foundation/exceptions/__init__.py,sha256=ufomZK6am2-QAaj9peXW549xy_qflcbwj0ECuZz-1Kc,263
|
|
202
202
|
orionis/foundation/exceptions/application.py,sha256=jeNToFG7msej2Ow6A7Zqj7cNLoI4NVpN2b5fdbhOiCI,1638
|
|
203
203
|
orionis/foundation/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -216,7 +216,7 @@ orionis/foundation/providers/scheduler_provider.py,sha256=IrPQJwvQVLRm5Qnz0Cxon4
|
|
|
216
216
|
orionis/foundation/providers/testing_provider.py,sha256=eI1p2lUlxl25b5Z487O4nmqLE31CTDb4c3Q21xFadkE,1615
|
|
217
217
|
orionis/foundation/providers/workers_provider.py,sha256=GdHENYV_yGyqmHJHn0DCyWmWId5xWjD48e6Zq2PGCWY,1674
|
|
218
218
|
orionis/metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
219
|
-
orionis/metadata/framework.py,sha256=
|
|
219
|
+
orionis/metadata/framework.py,sha256=2u03E596rKTeHd7PSCHu1sFCOs1DeAICYgWPH437NKY,4089
|
|
220
220
|
orionis/metadata/package.py,sha256=k7Yriyp5aUcR-iR8SK2ec_lf0_Cyc-C7JczgXa-I67w,16039
|
|
221
221
|
orionis/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
222
222
|
orionis/services/asynchrony/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -403,8 +403,8 @@ orionis/test/validators/workers.py,sha256=rWcdRexINNEmGaO7mnc1MKUxkHKxrTsVuHgbnI
|
|
|
403
403
|
orionis/test/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
404
404
|
orionis/test/view/render.py,sha256=R55ykeRs0wDKcdTf4O1YZ8GDHTFmJ0IK6VQkbJkYUvo,5571
|
|
405
405
|
orionis/test/view/report.stub,sha256=QLqqCdRoENr3ECiritRB3DO_MOjRQvgBh5jxZ3Hs1r0,28189
|
|
406
|
-
orionis-0.
|
|
407
|
-
orionis-0.
|
|
408
|
-
orionis-0.
|
|
409
|
-
orionis-0.
|
|
410
|
-
orionis-0.
|
|
406
|
+
orionis-0.634.0.dist-info/licenses/LICENCE,sha256=JhC-z_9mbpUrCfPjcl3DhDA8trNDMzb57cvRSam1avc,1463
|
|
407
|
+
orionis-0.634.0.dist-info/METADATA,sha256=AWSbDqTVxG2q4LtH6EG3F-9SENQYjx4gUsRztYNScUo,4772
|
|
408
|
+
orionis-0.634.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
409
|
+
orionis-0.634.0.dist-info/top_level.txt,sha256=lyXi6jArpqJ-0zzNqd_uwsH-z9TCEBVBL-pC3Ekv7hU,8
|
|
410
|
+
orionis-0.634.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|