ic-python-db 0.7.6__tar.gz → 0.7.7__tar.gz
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.
- {ic_python_db-0.7.6/ic_python_db.egg-info → ic_python_db-0.7.7}/PKG-INFO +1 -1
- {ic_python_db-0.7.6 → ic_python_db-0.7.7}/ic_python_db/__init__.py +1 -1
- {ic_python_db-0.7.6 → ic_python_db-0.7.7}/ic_python_db/db_engine.py +6 -0
- {ic_python_db-0.7.6 → ic_python_db-0.7.7}/ic_python_db/entity.py +27 -0
- {ic_python_db-0.7.6 → ic_python_db-0.7.7/ic_python_db.egg-info}/PKG-INFO +1 -1
- {ic_python_db-0.7.6 → ic_python_db-0.7.7}/pyproject.toml +1 -1
- {ic_python_db-0.7.6 → ic_python_db-0.7.7}/setup.py +1 -1
- {ic_python_db-0.7.6 → ic_python_db-0.7.7}/LICENSE +0 -0
- {ic_python_db-0.7.6 → ic_python_db-0.7.7}/MANIFEST.in +0 -0
- {ic_python_db-0.7.6 → ic_python_db-0.7.7}/README.md +0 -0
- {ic_python_db-0.7.6 → ic_python_db-0.7.7}/ic_python_db/_cdk.py +0 -0
- {ic_python_db-0.7.6 → ic_python_db-0.7.7}/ic_python_db/constants.py +0 -0
- {ic_python_db-0.7.6 → ic_python_db-0.7.7}/ic_python_db/context.py +0 -0
- {ic_python_db-0.7.6 → ic_python_db-0.7.7}/ic_python_db/hooks.py +0 -0
- {ic_python_db-0.7.6 → ic_python_db-0.7.7}/ic_python_db/mixins.py +0 -0
- {ic_python_db-0.7.6 → ic_python_db-0.7.7}/ic_python_db/properties.py +0 -0
- {ic_python_db-0.7.6 → ic_python_db-0.7.7}/ic_python_db/py.typed +0 -0
- {ic_python_db-0.7.6 → ic_python_db-0.7.7}/ic_python_db/storage.py +0 -0
- {ic_python_db-0.7.6 → ic_python_db-0.7.7}/ic_python_db/system_time.py +0 -0
- {ic_python_db-0.7.6 → ic_python_db-0.7.7}/ic_python_db.egg-info/SOURCES.txt +0 -0
- {ic_python_db-0.7.6 → ic_python_db-0.7.7}/ic_python_db.egg-info/dependency_links.txt +0 -0
- {ic_python_db-0.7.6 → ic_python_db-0.7.7}/ic_python_db.egg-info/top_level.txt +0 -0
- {ic_python_db-0.7.6 → ic_python_db-0.7.7}/requirements-dev.txt +0 -0
- {ic_python_db-0.7.6 → ic_python_db-0.7.7}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ic_python_db
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.7
|
|
4
4
|
Summary: A lightweight key-value database written in Python, intended for use on the Internet Computer (IC)
|
|
5
5
|
Home-page: https://github.com/smart-social-contracts/ic-python-db
|
|
6
6
|
Author: Smart Social Contracts
|
|
@@ -36,6 +36,12 @@ class Database:
|
|
|
36
36
|
if cls._instance:
|
|
37
37
|
raise RuntimeError("Database instance already exists")
|
|
38
38
|
cls._instance = cls(audit_enabled, db_storage, db_audit)
|
|
39
|
+
|
|
40
|
+
# Flush any Entity subclasses that were defined before Database existed
|
|
41
|
+
from .entity import Entity
|
|
42
|
+
|
|
43
|
+
Entity._flush_deferred_types()
|
|
44
|
+
|
|
39
45
|
return cls._instance
|
|
40
46
|
|
|
41
47
|
def __init__(
|
|
@@ -91,10 +91,37 @@ class Entity:
|
|
|
91
91
|
|
|
92
92
|
_entity_type = None # To be defined in subclasses
|
|
93
93
|
_context: Set["Entity"] = set() # Set of entities in current context
|
|
94
|
+
_deferred_types: List[Type["Entity"]] = [] # Types defined before DB exists
|
|
94
95
|
_do_not_save = False
|
|
95
96
|
__version__ = 1 # Default schema version
|
|
96
97
|
__namespace__: Optional[str] = None # Optional namespace for entity type
|
|
97
98
|
|
|
99
|
+
def __init_subclass__(cls, **kwargs):
|
|
100
|
+
"""Auto-register Entity subclasses with the Database at class definition time."""
|
|
101
|
+
super().__init_subclass__(**kwargs)
|
|
102
|
+
db = Database._instance
|
|
103
|
+
if db is not None:
|
|
104
|
+
db.register_entity_type(cls, cls.get_full_type_name())
|
|
105
|
+
else:
|
|
106
|
+
# Database not initialized yet — defer registration
|
|
107
|
+
Entity._deferred_types.append(cls)
|
|
108
|
+
|
|
109
|
+
@classmethod
|
|
110
|
+
def _flush_deferred_types(cls):
|
|
111
|
+
"""Register any Entity subclasses that were defined before Database existed."""
|
|
112
|
+
if not cls._deferred_types:
|
|
113
|
+
return
|
|
114
|
+
try:
|
|
115
|
+
db = Database.get_instance()
|
|
116
|
+
except Exception:
|
|
117
|
+
return
|
|
118
|
+
for deferred_cls in cls._deferred_types:
|
|
119
|
+
try:
|
|
120
|
+
db.register_entity_type(deferred_cls, deferred_cls.get_full_type_name())
|
|
121
|
+
except Exception:
|
|
122
|
+
pass
|
|
123
|
+
cls._deferred_types.clear()
|
|
124
|
+
|
|
98
125
|
def __init__(self, **kwargs):
|
|
99
126
|
"""Initialize a new entity.
|
|
100
127
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ic_python_db
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.7
|
|
4
4
|
Summary: A lightweight key-value database written in Python, intended for use on the Internet Computer (IC)
|
|
5
5
|
Home-page: https://github.com/smart-social-contracts/ic-python-db
|
|
6
6
|
Author: Smart Social Contracts
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "ic_python_db"
|
|
7
|
-
version = "0.7.
|
|
7
|
+
version = "0.7.7"
|
|
8
8
|
description = "A lightweight key-value database written in Python, intended for use on the Internet Computer (IC)"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [
|
|
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
|
|
|
5
5
|
|
|
6
6
|
setup(
|
|
7
7
|
name="ic_python_db",
|
|
8
|
-
version="0.7.
|
|
8
|
+
version="0.7.7",
|
|
9
9
|
author="Smart Social Contracts",
|
|
10
10
|
author_email="smartsocialcontracts@gmail.com",
|
|
11
11
|
description="A lightweight key-value database with entity relationships and audit logging",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|