orionis 0.583.0__py3-none-any.whl → 0.584.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/console/core/reactor.py +4 -18
- orionis/container/facades/facade.py +2 -3
- orionis/foundation/application.py +181 -319
- orionis/foundation/config/roots/paths.py +40 -140
- orionis/foundation/contracts/application.py +742 -401
- orionis/metadata/framework.py +1 -1
- orionis/services/file/contracts/directory.py +43 -199
- orionis/services/file/directory.py +58 -197
- {orionis-0.583.0.dist-info → orionis-0.584.0.dist-info}/METADATA +1 -1
- {orionis-0.583.0.dist-info → orionis-0.584.0.dist-info}/RECORD +13 -14
- orionis/app.py +0 -17
- {orionis-0.583.0.dist-info → orionis-0.584.0.dist-info}/WHEEL +0 -0
- {orionis-0.583.0.dist-info → orionis-0.584.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.583.0.dist-info → orionis-0.584.0.dist-info}/top_level.txt +0 -0
@@ -123,9 +123,6 @@ class Application(Container, IApplication):
|
|
123
123
|
# Property to store the exception handler class
|
124
124
|
self.__exception_handler: Type[BaseExceptionHandler] = None
|
125
125
|
|
126
|
-
# Base path for the application, used for relative paths
|
127
|
-
self.__bootstrap_base_path: str | Path = None
|
128
|
-
|
129
126
|
# Flag to prevent re-initialization
|
130
127
|
self.__initialized = True
|
131
128
|
|
@@ -164,7 +161,11 @@ class Application(Container, IApplication):
|
|
164
161
|
|
165
162
|
# Register each kernel instance
|
166
163
|
for abstract, concrete in core_kernels.items():
|
167
|
-
self.instance(
|
164
|
+
self.instance(
|
165
|
+
abstract,
|
166
|
+
concrete(self),
|
167
|
+
alias=f"x-{abstract.__module__}.{abstract.__name__}"
|
168
|
+
)
|
168
169
|
|
169
170
|
def __loadFrameworkProviders(
|
170
171
|
self
|
@@ -695,7 +696,7 @@ class Application(Container, IApplication):
|
|
695
696
|
path = extractor(path)
|
696
697
|
if not isinstance(path, (Paths, dict)):
|
697
698
|
raise OrionisTypeError(f"Expected Paths instance or dict, got {type(path).__name__}")
|
698
|
-
self.
|
699
|
+
self.loadConfigPaths(path)
|
699
700
|
|
700
701
|
# Load queue configurator
|
701
702
|
if (isinstance(queue, type) and issubclass(queue, Queue)):
|
@@ -1425,261 +1426,6 @@ class Application(Container, IApplication):
|
|
1425
1426
|
# Return the application instance for method chaining
|
1426
1427
|
return self
|
1427
1428
|
|
1428
|
-
def setPaths(
|
1429
|
-
self,
|
1430
|
-
*,
|
1431
|
-
console: str | Path = (Path.cwd() / 'app' / 'console').resolve(),
|
1432
|
-
controllers: str | Path = (Path.cwd() / 'app' / 'http' / 'controllers').resolve(),
|
1433
|
-
middleware: str | Path = (Path.cwd() / 'app' / 'http' / 'middleware').resolve(),
|
1434
|
-
requests: str | Path = (Path.cwd() / 'app' / 'http' / 'requests').resolve(),
|
1435
|
-
models: str | Path = (Path.cwd() / 'app' / 'models').resolve(),
|
1436
|
-
providers: str | Path = (Path.cwd() / 'app' / 'providers').resolve(),
|
1437
|
-
events: str | Path = (Path.cwd() / 'app' / 'events').resolve(),
|
1438
|
-
listeners: str | Path = (Path.cwd() / 'app' / 'listeners').resolve(),
|
1439
|
-
notifications: str | Path = (Path.cwd() / 'app' / 'notifications').resolve(),
|
1440
|
-
jobs: str | Path = (Path.cwd() / 'app' / 'jobs').resolve(),
|
1441
|
-
policies: str | Path = (Path.cwd() / 'app' / 'policies').resolve(),
|
1442
|
-
exceptions: str | Path = (Path.cwd() / 'app' / 'exceptions').resolve(),
|
1443
|
-
services: str | Path = (Path.cwd() / 'app' / 'services').resolve(),
|
1444
|
-
views: str | Path = (Path.cwd() / 'resources' / 'views').resolve(),
|
1445
|
-
lang: str | Path = (Path.cwd() / 'resources' / 'lang').resolve(),
|
1446
|
-
assets: str | Path = (Path.cwd() / 'resources' / 'assets').resolve(),
|
1447
|
-
routes: str | Path = (Path.cwd() / 'routes').resolve(),
|
1448
|
-
config: str | Path = (Path.cwd() / 'config').resolve(),
|
1449
|
-
migrations: str | Path = (Path.cwd() / 'database' / 'migrations').resolve(),
|
1450
|
-
seeders: str | Path = (Path.cwd() / 'database' / 'seeders').resolve(),
|
1451
|
-
factories: str | Path = (Path.cwd() / 'database' / 'factories').resolve(),
|
1452
|
-
logs: str | Path = (Path.cwd() / 'storage' / 'logs').resolve(),
|
1453
|
-
sessions: str | Path = (Path.cwd() / 'storage' / 'framework' / 'sessions').resolve(),
|
1454
|
-
cache: str | Path = (Path.cwd() / 'storage' / 'framework' / 'cache').resolve(),
|
1455
|
-
testing: str | Path = (Path.cwd() / 'storage' / 'framework' / 'testing').resolve(),
|
1456
|
-
storage: str | Path = (Path.cwd() / 'storage').resolve(),
|
1457
|
-
tests: str | Path = (Path.cwd() / 'tests').resolve()
|
1458
|
-
) -> 'Application':
|
1459
|
-
"""
|
1460
|
-
Set and resolve application directory paths using keyword arguments.
|
1461
|
-
|
1462
|
-
This method allows customization of all major application directory paths, such as
|
1463
|
-
console components, HTTP components, application layers, resources, routes,
|
1464
|
-
database files, and storage locations. All provided paths are resolved to absolute
|
1465
|
-
paths and stored as strings in the configuration dictionary.
|
1466
|
-
|
1467
|
-
Parameters
|
1468
|
-
----------
|
1469
|
-
console : str or Path, optional
|
1470
|
-
Directory for console command classes. Defaults to 'app/console'.
|
1471
|
-
controllers : str or Path, optional
|
1472
|
-
Directory for HTTP controller classes. Defaults to 'app/http/controllers'.
|
1473
|
-
middleware : str or Path, optional
|
1474
|
-
Directory for HTTP middleware classes. Defaults to 'app/http/middleware'.
|
1475
|
-
requests : str or Path, optional
|
1476
|
-
Directory for HTTP request classes. Defaults to 'app/http/requests'.
|
1477
|
-
models : str or Path, optional
|
1478
|
-
Directory for data model classes. Defaults to 'app/models'.
|
1479
|
-
providers : str or Path, optional
|
1480
|
-
Directory for service provider classes. Defaults to 'app/providers'.
|
1481
|
-
events : str or Path, optional
|
1482
|
-
Directory for event classes. Defaults to 'app/events'.
|
1483
|
-
listeners : str or Path, optional
|
1484
|
-
Directory for event listener classes. Defaults to 'app/listeners'.
|
1485
|
-
notifications : str or Path, optional
|
1486
|
-
Directory for notification classes. Defaults to 'app/notifications'.
|
1487
|
-
jobs : str or Path, optional
|
1488
|
-
Directory for queue job classes. Defaults to 'app/jobs'.
|
1489
|
-
policies : str or Path, optional
|
1490
|
-
Directory for authorization policy classes. Defaults to 'app/policies'.
|
1491
|
-
exceptions : str or Path, optional
|
1492
|
-
Directory for custom exception classes. Defaults to 'app/exceptions'.
|
1493
|
-
services : str or Path, optional
|
1494
|
-
Directory for application service classes. Defaults to 'app/services'.
|
1495
|
-
views : str or Path, optional
|
1496
|
-
Directory for view templates. Defaults to 'resources/views'.
|
1497
|
-
lang : str or Path, optional
|
1498
|
-
Directory for language files. Defaults to 'resources/lang'.
|
1499
|
-
assets : str or Path, optional
|
1500
|
-
Directory for asset files. Defaults to 'resources/assets'.
|
1501
|
-
routes : str or Path, optional
|
1502
|
-
Directory for route definitions. Defaults to 'routes'.
|
1503
|
-
config : str or Path, optional
|
1504
|
-
Directory for configuration files. Defaults to 'config'.
|
1505
|
-
migrations : str or Path, optional
|
1506
|
-
Directory for database migration files. Defaults to 'database/migrations'.
|
1507
|
-
seeders : str or Path, optional
|
1508
|
-
Directory for database seeder files. Defaults to 'database/seeders'.
|
1509
|
-
factories : str or Path, optional
|
1510
|
-
Directory for model factory files. Defaults to 'database/factories'.
|
1511
|
-
logs : str or Path, optional
|
1512
|
-
Directory for log file storage. Defaults to 'storage/logs'.
|
1513
|
-
sessions : str or Path, optional
|
1514
|
-
Directory for session file storage. Defaults to 'storage/framework/sessions'.
|
1515
|
-
cache : str or Path, optional
|
1516
|
-
Directory for cache file storage. Defaults to 'storage/framework/cache'.
|
1517
|
-
testing : str or Path, optional
|
1518
|
-
Directory for testing file storage. Defaults to 'storage/framework/testing'.
|
1519
|
-
|
1520
|
-
Returns
|
1521
|
-
-------
|
1522
|
-
Application
|
1523
|
-
Returns the current Application instance to enable method chaining.
|
1524
|
-
|
1525
|
-
Notes
|
1526
|
-
-----
|
1527
|
-
All path parameters accept either string or Path objects and are automatically
|
1528
|
-
resolved to absolute paths relative to the current working directory. The
|
1529
|
-
resolved paths are stored as strings in the internal configuration dictionary.
|
1530
|
-
"""
|
1531
|
-
|
1532
|
-
# Prepare and store all resolved paths as strings in the configurators dictionary
|
1533
|
-
# Ensure 'paths' exists in configurators
|
1534
|
-
self.__configurators['path'] = {
|
1535
|
-
'root' : self.__bootstrap_base_path or str(Path.cwd().resolve()),
|
1536
|
-
'console' : str(console),
|
1537
|
-
'controllers' : str(controllers),
|
1538
|
-
'middleware' : str(middleware),
|
1539
|
-
'requests' : str(requests),
|
1540
|
-
'models' : str(models),
|
1541
|
-
'providers' : str(providers),
|
1542
|
-
'events' : str(events),
|
1543
|
-
'listeners' : str(listeners),
|
1544
|
-
'notifications' : str(notifications),
|
1545
|
-
'jobs' : str(jobs),
|
1546
|
-
'policies' : str(policies),
|
1547
|
-
'exceptions' : str(exceptions),
|
1548
|
-
'services' : str(services),
|
1549
|
-
'views' : str(views),
|
1550
|
-
'lang' : str(lang),
|
1551
|
-
'assets' : str(assets),
|
1552
|
-
'routes' : str(routes),
|
1553
|
-
'config' : str(config),
|
1554
|
-
'migrations' : str(migrations),
|
1555
|
-
'seeders' : str(seeders),
|
1556
|
-
'factories' : str(factories),
|
1557
|
-
'logs' : str(logs),
|
1558
|
-
'sessions' : str(sessions),
|
1559
|
-
'cache' : str(cache),
|
1560
|
-
'testing' : str(testing),
|
1561
|
-
'storage' : str(storage),
|
1562
|
-
'tests' : str(tests)
|
1563
|
-
}
|
1564
|
-
|
1565
|
-
# Return self instance for method chaining
|
1566
|
-
return self
|
1567
|
-
|
1568
|
-
def loadPaths(
|
1569
|
-
self,
|
1570
|
-
paths: Paths | dict
|
1571
|
-
) -> 'Application':
|
1572
|
-
"""
|
1573
|
-
Load and store path configuration from a Paths instance or dictionary.
|
1574
|
-
|
1575
|
-
This method validates and stores the application path configuration in the
|
1576
|
-
internal configurators storage. If a dictionary is provided, it will be
|
1577
|
-
converted to a Paths instance before storage.
|
1578
|
-
|
1579
|
-
Parameters
|
1580
|
-
----------
|
1581
|
-
paths : Paths or dict
|
1582
|
-
The path configuration as either a Paths instance or a dictionary
|
1583
|
-
containing path parameters that can be used to construct a Paths instance.
|
1584
|
-
|
1585
|
-
Returns
|
1586
|
-
-------
|
1587
|
-
Application
|
1588
|
-
The current application instance to enable method chaining.
|
1589
|
-
|
1590
|
-
Raises
|
1591
|
-
------
|
1592
|
-
OrionisTypeError
|
1593
|
-
If the paths parameter is not an instance of Paths or a dictionary.
|
1594
|
-
|
1595
|
-
Notes
|
1596
|
-
-----
|
1597
|
-
Dictionary inputs are automatically converted to Paths instances using
|
1598
|
-
the dictionary unpacking operator (**paths). This method is used internally
|
1599
|
-
by withConfigurators() and can be called directly for path configuration.
|
1600
|
-
"""
|
1601
|
-
|
1602
|
-
# Validate paths type
|
1603
|
-
if not isinstance(paths, (Paths, dict)):
|
1604
|
-
raise OrionisTypeError(f"Expected Paths instance or dict, got {type(paths).__name__}")
|
1605
|
-
|
1606
|
-
# Always ensure 'root' path is set
|
1607
|
-
base_path = {'root': self.__bootstrap_base_path or str(Path.cwd().resolve())}
|
1608
|
-
|
1609
|
-
# If paths is a dict, convert it to Paths instance
|
1610
|
-
if isinstance(paths, dict):
|
1611
|
-
paths.update(base_path)
|
1612
|
-
paths = Paths(**paths).toDict()
|
1613
|
-
elif isinstance(paths, Paths):
|
1614
|
-
paths = paths.toDict()
|
1615
|
-
paths.update(base_path)
|
1616
|
-
|
1617
|
-
# Store the configuration
|
1618
|
-
self.__configurators['path'] = paths
|
1619
|
-
|
1620
|
-
# Return the application instance for method chaining
|
1621
|
-
return self
|
1622
|
-
|
1623
|
-
def setBasePath(
|
1624
|
-
self,
|
1625
|
-
basePath: Path
|
1626
|
-
) -> 'Application':
|
1627
|
-
"""
|
1628
|
-
Set the base path for the application.
|
1629
|
-
|
1630
|
-
This method allows setting the base path of the application, which is
|
1631
|
-
used as the root directory for all relative paths in the application.
|
1632
|
-
The provided basePath must be a Path object.
|
1633
|
-
|
1634
|
-
Parameters
|
1635
|
-
----------
|
1636
|
-
basePath : Path
|
1637
|
-
The base path to set for the application. It must be a Path object.
|
1638
|
-
|
1639
|
-
Returns
|
1640
|
-
-------
|
1641
|
-
Application
|
1642
|
-
The current application instance to enable method chaining.
|
1643
|
-
|
1644
|
-
Raises
|
1645
|
-
------
|
1646
|
-
OrionisTypeError
|
1647
|
-
If basePath is not a Path instance.
|
1648
|
-
"""
|
1649
|
-
|
1650
|
-
# If basePath is a string, convert to Path
|
1651
|
-
if isinstance(basePath, str):
|
1652
|
-
basePath = Path(basePath)
|
1653
|
-
|
1654
|
-
if not isinstance(basePath, Path):
|
1655
|
-
raise OrionisTypeError("basePath must be a Path object or a string convertible to Path.")
|
1656
|
-
|
1657
|
-
# Resolve and store the base path as a string
|
1658
|
-
self.__bootstrap_base_path = str(basePath.resolve())
|
1659
|
-
|
1660
|
-
# Return self instance for method chaining
|
1661
|
-
return self
|
1662
|
-
|
1663
|
-
def getBasePath(
|
1664
|
-
self
|
1665
|
-
) -> Path:
|
1666
|
-
"""
|
1667
|
-
Get the base path of the application.
|
1668
|
-
|
1669
|
-
This method returns the base path that was previously set using setBasePath().
|
1670
|
-
If no base path has been set, it returns the current working directory as a Path object.
|
1671
|
-
|
1672
|
-
Returns
|
1673
|
-
-------
|
1674
|
-
Path
|
1675
|
-
The base path of the application as a Path object.
|
1676
|
-
"""
|
1677
|
-
|
1678
|
-
# Always return a Path object
|
1679
|
-
if self.__bootstrap_base_path:
|
1680
|
-
return Path(self.__bootstrap_base_path)
|
1681
|
-
return Path.cwd().resolve()
|
1682
|
-
|
1683
1429
|
def setConfigQueue(
|
1684
1430
|
self,
|
1685
1431
|
**queue_config
|
@@ -1944,6 +1690,129 @@ class Application(Container, IApplication):
|
|
1944
1690
|
# Return the application instance for method chaining
|
1945
1691
|
return self
|
1946
1692
|
|
1693
|
+
def setConfigPaths(
|
1694
|
+
self,
|
1695
|
+
*,
|
1696
|
+
root: str | Path = str(Path.cwd().resolve()),
|
1697
|
+
app: str | Path = str((Path.cwd() / 'app').resolve()),
|
1698
|
+
console: str | Path = str((Path.cwd() / 'app' / 'console').resolve()),
|
1699
|
+
exceptions: str | Path = str((Path.cwd() / 'app' / 'exceptions').resolve()),
|
1700
|
+
http: str | Path = str((Path.cwd() / 'app' / 'http').resolve()),
|
1701
|
+
models: str | Path = str((Path.cwd() / 'app' / 'models').resolve()),
|
1702
|
+
providers: str | Path = str((Path.cwd() / 'app' / 'providers').resolve()),
|
1703
|
+
notifications: str | Path = str((Path.cwd() / 'app' / 'notifications').resolve()),
|
1704
|
+
services: str | Path = str((Path.cwd() / 'app' / 'services').resolve()),
|
1705
|
+
jobs: str | Path = str((Path.cwd() / 'app' / 'jobs').resolve()),
|
1706
|
+
bootstrap: str | Path = str((Path.cwd() / 'app' / 'bootstrap').resolve()),
|
1707
|
+
config: str | Path = str((Path.cwd() / 'config').resolve()),
|
1708
|
+
database: str | Path = str((Path.cwd() / 'database' / 'database').resolve()),
|
1709
|
+
resources: str | Path = str((Path.cwd() / 'resources').resolve()),
|
1710
|
+
routes: str | Path = str((Path.cwd() / 'routes').resolve()),
|
1711
|
+
storage: str | Path = str((Path.cwd() / 'storage').resolve()),
|
1712
|
+
tests: str | Path = str((Path.cwd() / 'tests').resolve())
|
1713
|
+
) -> 'Application':
|
1714
|
+
"""
|
1715
|
+
Set and resolve application directory paths using keyword arguments.
|
1716
|
+
|
1717
|
+
Only the following options are available:
|
1718
|
+
- root
|
1719
|
+
- app
|
1720
|
+
- console
|
1721
|
+
- exceptions
|
1722
|
+
- http
|
1723
|
+
- models
|
1724
|
+
- providers
|
1725
|
+
- notifications
|
1726
|
+
- services
|
1727
|
+
- jobs
|
1728
|
+
- bootstrap
|
1729
|
+
- config
|
1730
|
+
- database
|
1731
|
+
- resources
|
1732
|
+
- routes
|
1733
|
+
- storage
|
1734
|
+
- tests
|
1735
|
+
|
1736
|
+
All provided paths are resolved to absolute paths and stored as strings in the configuration dictionary.
|
1737
|
+
|
1738
|
+
Returns
|
1739
|
+
-------
|
1740
|
+
Application
|
1741
|
+
Returns the current Application instance to enable method chaining.
|
1742
|
+
"""
|
1743
|
+
|
1744
|
+
self.__configurators['path'] = {
|
1745
|
+
'root': str(root),
|
1746
|
+
'app': str(app),
|
1747
|
+
'console': str(console),
|
1748
|
+
'exceptions': str(exceptions),
|
1749
|
+
'http': str(http),
|
1750
|
+
'models': str(models),
|
1751
|
+
'providers': str(providers),
|
1752
|
+
'notifications': str(notifications),
|
1753
|
+
'services': str(services),
|
1754
|
+
'jobs': str(jobs),
|
1755
|
+
'bootstrap': str(bootstrap),
|
1756
|
+
'config': str(config),
|
1757
|
+
'database': str(database),
|
1758
|
+
'resources': str(resources),
|
1759
|
+
'routes': str(routes),
|
1760
|
+
'storage': str(storage),
|
1761
|
+
'tests': str(tests)
|
1762
|
+
}
|
1763
|
+
|
1764
|
+
return self
|
1765
|
+
|
1766
|
+
def loadConfigPaths(
|
1767
|
+
self,
|
1768
|
+
paths: Paths | dict
|
1769
|
+
) -> 'Application':
|
1770
|
+
"""
|
1771
|
+
Load and store path configuration from a Paths instance or dictionary.
|
1772
|
+
|
1773
|
+
This method validates and stores the application path configuration in the
|
1774
|
+
internal configurators storage. If a dictionary is provided, it will be
|
1775
|
+
converted to a Paths instance before storage.
|
1776
|
+
|
1777
|
+
Parameters
|
1778
|
+
----------
|
1779
|
+
paths : Paths or dict
|
1780
|
+
The path configuration as either a Paths instance or a dictionary
|
1781
|
+
containing path parameters that can be used to construct a Paths instance.
|
1782
|
+
|
1783
|
+
Returns
|
1784
|
+
-------
|
1785
|
+
Application
|
1786
|
+
The current application instance to enable method chaining.
|
1787
|
+
|
1788
|
+
Raises
|
1789
|
+
------
|
1790
|
+
OrionisTypeError
|
1791
|
+
If the paths parameter is not an instance of Paths or a dictionary.
|
1792
|
+
|
1793
|
+
Notes
|
1794
|
+
-----
|
1795
|
+
Dictionary inputs are automatically converted to Paths instances using
|
1796
|
+
the dictionary unpacking operator (**paths). This method is used internally
|
1797
|
+
by withConfigurators() and can be called directly for path configuration.
|
1798
|
+
"""
|
1799
|
+
|
1800
|
+
# Validate paths type
|
1801
|
+
if not isinstance(paths, (Paths, dict)):
|
1802
|
+
raise OrionisTypeError(f"Expected Paths instance or dict, got {type(paths).__name__}")
|
1803
|
+
|
1804
|
+
# If paths is a dict, convert it to Paths instance
|
1805
|
+
if isinstance(paths, dict):
|
1806
|
+
paths = Paths(**paths).toDict()
|
1807
|
+
elif isinstance(paths, Paths):
|
1808
|
+
paths = paths.toDict()
|
1809
|
+
|
1810
|
+
# Store the configuration
|
1811
|
+
self.__configurators['path'] = paths
|
1812
|
+
|
1813
|
+
# Return the application instance for method chaining
|
1814
|
+
return self
|
1815
|
+
|
1947
1816
|
def __loadConfig(
|
1948
1817
|
self,
|
1949
1818
|
) -> None:
|
@@ -2000,86 +1869,85 @@ class Application(Container, IApplication):
|
|
2000
1869
|
|
2001
1870
|
def config(
|
2002
1871
|
self,
|
2003
|
-
key: str = None
|
2004
|
-
default: Any = None
|
1872
|
+
key: str = None
|
2005
1873
|
) -> Any:
|
2006
1874
|
"""
|
2007
1875
|
Retrieve application configuration values using dot notation.
|
2008
1876
|
|
2009
|
-
This method provides access to the application's configuration settings
|
2010
|
-
|
2011
|
-
|
1877
|
+
This method provides access to the application's configuration settings,
|
1878
|
+
supporting retrieval of nested values using dot notation (e.g., "database.default").
|
1879
|
+
If a key is provided, the method returns the corresponding configuration value.
|
1880
|
+
If no key is provided, it returns the entire configuration dictionary, excluding
|
1881
|
+
path-related configuration (which should be accessed via the `path()` method).
|
2012
1882
|
|
2013
1883
|
Parameters
|
2014
1884
|
----------
|
2015
1885
|
key : str, optional
|
2016
1886
|
The configuration key to retrieve, supporting dot notation for nested
|
2017
|
-
values (e.g., "database.default", "app.name"). If None, returns
|
2018
|
-
entire configuration dictionary
|
2019
|
-
default : Any, optional
|
2020
|
-
The value to return if the specified key is not found in the configuration.
|
1887
|
+
values (e.g., "database.default", "app.name"). If None, the method returns
|
1888
|
+
the entire configuration dictionary except for the 'path' configuration.
|
2021
1889
|
Default is None.
|
2022
1890
|
|
2023
1891
|
Returns
|
2024
1892
|
-------
|
2025
1893
|
Any
|
2026
|
-
|
2027
|
-
|
2028
|
-
|
1894
|
+
If `key` is provided and found, returns the corresponding configuration value.
|
1895
|
+
If `key` is None, returns the entire configuration dictionary (excluding 'path').
|
1896
|
+
If the key is not found, returns None.
|
2029
1897
|
|
2030
1898
|
Raises
|
2031
1899
|
------
|
2032
1900
|
OrionisRuntimeError
|
2033
|
-
If the application configuration has not been initialized.
|
2034
|
-
|
1901
|
+
If the application configuration has not been initialized (i.e., if `create()`
|
1902
|
+
has not been called before accessing configuration).
|
2035
1903
|
OrionisValueError
|
2036
|
-
If the provided key parameter is not a string type.
|
1904
|
+
If the provided `key` parameter is not a string type.
|
2037
1905
|
|
2038
1906
|
Notes
|
2039
1907
|
-----
|
2040
1908
|
The method traverses nested configuration structures by splitting the key
|
2041
1909
|
on dots and navigating through dictionary levels. Path configurations are
|
2042
1910
|
excluded from full configuration returns and should be accessed via the
|
2043
|
-
path() method instead.
|
1911
|
+
`path()` method instead.
|
2044
1912
|
"""
|
2045
1913
|
|
2046
|
-
# Create a local copy of the configuration to avoid
|
1914
|
+
# Create a local copy of the configuration to avoid mutating the original
|
2047
1915
|
local_config = self.__config.copy()
|
2048
1916
|
|
2049
|
-
# Remove 'path' from local copy to
|
1917
|
+
# Remove 'path' from the local copy to ensure path config is not returned here
|
2050
1918
|
if 'path' in local_config:
|
2051
1919
|
del local_config['path']
|
2052
1920
|
|
2053
1921
|
# Ensure the application is booted before accessing configuration
|
2054
1922
|
if not local_config:
|
2055
|
-
raise OrionisRuntimeError(
|
1923
|
+
raise OrionisRuntimeError(
|
1924
|
+
"Application configuration is not initialized. Please call create() before accessing configuration."
|
1925
|
+
)
|
2056
1926
|
|
2057
|
-
#
|
1927
|
+
# If no key is provided, return the entire configuration (excluding 'path')
|
2058
1928
|
if key is None:
|
2059
1929
|
return local_config
|
2060
1930
|
|
2061
|
-
#
|
1931
|
+
# Ensure the key is a string
|
2062
1932
|
if not isinstance(key, str):
|
2063
|
-
raise OrionisValueError(
|
1933
|
+
raise OrionisValueError(
|
1934
|
+
"Key must be a string. Use config() without arguments to retrieve the entire configuration."
|
1935
|
+
)
|
2064
1936
|
|
2065
|
-
# Split the key by dot notation
|
1937
|
+
# Split the key by dot notation to support nested access
|
2066
1938
|
parts = key.split('.')
|
2067
1939
|
|
2068
|
-
# Start with the full config
|
1940
|
+
# Start with the full config and traverse according to the key parts
|
2069
1941
|
config_value = local_config
|
2070
|
-
|
2071
|
-
# Traverse the config dictionary based on the key parts
|
2072
1942
|
for part in parts:
|
2073
|
-
|
2074
|
-
# If part is not in config_value, return default
|
1943
|
+
# If the part exists in the current config_value, go deeper
|
2075
1944
|
if isinstance(config_value, dict) and part in config_value:
|
2076
1945
|
config_value = config_value[part]
|
2077
|
-
|
2078
|
-
# If part is not found, return default value
|
2079
1946
|
else:
|
2080
|
-
return
|
1947
|
+
# If any part is missing, return None
|
1948
|
+
return None
|
2081
1949
|
|
2082
|
-
# Return the final configuration value
|
1950
|
+
# Return the final configuration value found
|
2083
1951
|
return config_value
|
2084
1952
|
|
2085
1953
|
# === Path Configuration Access Method ===
|
@@ -2089,49 +1957,38 @@ class Application(Container, IApplication):
|
|
2089
1957
|
|
2090
1958
|
def path(
|
2091
1959
|
self,
|
2092
|
-
key: str = None
|
2093
|
-
default: Any = None
|
1960
|
+
key: str = None
|
2094
1961
|
) -> Path | dict:
|
2095
1962
|
"""
|
2096
1963
|
Retrieve application path configuration values using dot notation.
|
2097
1964
|
|
2098
|
-
|
2099
|
-
supporting retrieval of either a specific path value or the entire paths
|
2100
|
-
configuration dictionary. If a key is provided, it returns the corresponding
|
2101
|
-
path as a `Path` object. If no key is provided, it returns a dictionary
|
2102
|
-
mapping all path configuration keys to their resolved `Path` objects.
|
1965
|
+
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.
|
2103
1966
|
|
2104
1967
|
Parameters
|
2105
1968
|
----------
|
2106
1969
|
key : str, optional
|
2107
|
-
Dot-notated key specifying the path configuration to retrieve (e.g.,
|
2108
|
-
|
2109
|
-
configuration dictionary. Default is None.
|
2110
|
-
default : Any, optional
|
2111
|
-
Value to return if the specified key is not found in the path
|
2112
|
-
configuration. Default is None.
|
1970
|
+
Dot-notated key specifying the path configuration to retrieve (e.g., "console", "storage.logs").
|
1971
|
+
If None, returns the entire paths configuration dictionary. Default is None.
|
2113
1972
|
|
2114
1973
|
Returns
|
2115
1974
|
-------
|
2116
1975
|
Path or dict
|
2117
1976
|
If `key` is provided and found, returns the resolved `Path` object for that key.
|
2118
1977
|
If `key` is None, returns a dictionary mapping all path keys to their `Path` objects.
|
2119
|
-
If `key` is not found, returns
|
1978
|
+
If `key` is not found, returns None.
|
2120
1979
|
|
2121
1980
|
Raises
|
2122
1981
|
------
|
2123
1982
|
OrionisRuntimeError
|
2124
|
-
If the application configuration has not been initialized.
|
2125
|
-
when `path()` is called before `create()`.
|
1983
|
+
If the application configuration has not been initialized (i.e., if `create()` has not been called).
|
2126
1984
|
OrionisValueError
|
2127
|
-
If the provided `key` parameter is not a string
|
1985
|
+
If the provided `key` parameter is not a string.
|
2128
1986
|
|
2129
1987
|
Notes
|
2130
1988
|
-----
|
2131
|
-
The method traverses the paths configuration structure by splitting the key
|
2132
|
-
|
2133
|
-
|
2134
|
-
application configuration.
|
1989
|
+
- The method traverses the paths configuration structure by splitting the key on dots and navigating through dictionary levels.
|
1990
|
+
- This method is specifically designed for path-related configuration access, separate from general application configuration.
|
1991
|
+
- All returned paths are resolved as `Path` objects for consistency and ease of use.
|
2135
1992
|
"""
|
2136
1993
|
|
2137
1994
|
# Create a local copy of the path configuration to avoid mutation
|
@@ -2161,8 +2018,8 @@ class Application(Container, IApplication):
|
|
2161
2018
|
if key in local_path_config:
|
2162
2019
|
return Path(local_path_config[key])
|
2163
2020
|
|
2164
|
-
# If the key is not found, return
|
2165
|
-
return
|
2021
|
+
# If the key is not found, return None
|
2022
|
+
return None
|
2166
2023
|
|
2167
2024
|
# === Application Creation Method ===
|
2168
2025
|
# The create() method is responsible for bootstrapping the application.
|
@@ -2203,7 +2060,12 @@ class Application(Container, IApplication):
|
|
2203
2060
|
if not self.__booted:
|
2204
2061
|
|
2205
2062
|
# Register the application instance in the container
|
2206
|
-
self.instance(
|
2063
|
+
self.instance(
|
2064
|
+
IApplication,
|
2065
|
+
self,
|
2066
|
+
alias=f"x-{IApplication.__module__}.{IApplication.__name__}",
|
2067
|
+
enforce_decoupling=None
|
2068
|
+
)
|
2207
2069
|
|
2208
2070
|
# Load configuration if not already set
|
2209
2071
|
self.__loadConfig()
|
@@ -2213,6 +2075,9 @@ class Application(Container, IApplication):
|
|
2213
2075
|
self.__registerProviders()
|
2214
2076
|
self.__bootProviders()
|
2215
2077
|
|
2078
|
+
# Mark as booted
|
2079
|
+
self.__booted = True
|
2080
|
+
|
2216
2081
|
# Load core framework kernels
|
2217
2082
|
self.__loadFrameworksKernel()
|
2218
2083
|
|
@@ -2228,8 +2093,5 @@ class Application(Container, IApplication):
|
|
2228
2093
|
# Log message to the logger
|
2229
2094
|
logger.info(boot_message)
|
2230
2095
|
|
2231
|
-
# Mark as booted
|
2232
|
-
self.__booted = True
|
2233
|
-
|
2234
2096
|
# Return the application instance for method chaining
|
2235
2097
|
return self
|