PersistentObjects 0.1.4__tar.gz → 0.1.5__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.
- {persistentobjects-0.1.4 → persistentobjects-0.1.5}/PKG-INFO +1 -1
- {persistentobjects-0.1.4 → persistentobjects-0.1.5}/PersistentObjects/core.py +29 -0
- {persistentobjects-0.1.4 → persistentobjects-0.1.5}/PersistentObjects.egg-info/PKG-INFO +1 -1
- {persistentobjects-0.1.4 → persistentobjects-0.1.5}/pyproject.toml +1 -1
- {persistentobjects-0.1.4 → persistentobjects-0.1.5}/LICENSE +0 -0
- {persistentobjects-0.1.4 → persistentobjects-0.1.5}/PersistentObjects/__init__.py +0 -0
- {persistentobjects-0.1.4 → persistentobjects-0.1.5}/PersistentObjects.egg-info/SOURCES.txt +0 -0
- {persistentobjects-0.1.4 → persistentobjects-0.1.5}/PersistentObjects.egg-info/dependency_links.txt +0 -0
- {persistentobjects-0.1.4 → persistentobjects-0.1.5}/PersistentObjects.egg-info/top_level.txt +0 -0
- {persistentobjects-0.1.4 → persistentobjects-0.1.5}/README.md +0 -0
- {persistentobjects-0.1.4 → persistentobjects-0.1.5}/setup.cfg +0 -0
|
@@ -66,11 +66,36 @@ class _PersistentState:
|
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
class _Namespace:
|
|
69
|
+
_instances = {}
|
|
70
|
+
|
|
71
|
+
def __new__(cls, root, key):
|
|
72
|
+
# Create unique identifier for this namespace
|
|
73
|
+
instance_key = (id(root), key)
|
|
74
|
+
|
|
75
|
+
if instance_key in cls._instances:
|
|
76
|
+
return cls._instances[instance_key]
|
|
77
|
+
|
|
78
|
+
instance = super().__new__(cls)
|
|
79
|
+
cls._instances[instance_key] = instance
|
|
80
|
+
return instance
|
|
81
|
+
|
|
69
82
|
def __init__(self, root, key):
|
|
83
|
+
# Prevent re-initialization
|
|
84
|
+
if hasattr(self, "_initialized"):
|
|
85
|
+
return
|
|
86
|
+
|
|
87
|
+
self._initialized = True
|
|
70
88
|
self._root = root
|
|
71
89
|
self._key = key
|
|
72
90
|
|
|
73
91
|
def __getattr__(self, name):
|
|
92
|
+
if name.startswith("_"):
|
|
93
|
+
raise AttributeError(name)
|
|
94
|
+
if name.endswith("_"):
|
|
95
|
+
try:
|
|
96
|
+
return super().__getattribute__(name[:-1])
|
|
97
|
+
except AttributeError:
|
|
98
|
+
raise AttributeError(f"'{self.__class__.__name__}' object has no attribute '{name}'.\n Notice: Attribute '{name}' is not persistent!")
|
|
74
99
|
try:
|
|
75
100
|
return self._root._data[self._key][name]
|
|
76
101
|
except KeyError:
|
|
@@ -81,6 +106,10 @@ class _Namespace:
|
|
|
81
106
|
super().__setattr__(name, value)
|
|
82
107
|
return
|
|
83
108
|
|
|
109
|
+
if name.endswith("_"):
|
|
110
|
+
super().__setattr__(name[:-1], value)
|
|
111
|
+
return
|
|
112
|
+
|
|
84
113
|
with self._root._lock:
|
|
85
114
|
bucket = self._root._data.setdefault(self._key, {})
|
|
86
115
|
bucket[name] = value
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{persistentobjects-0.1.4 → persistentobjects-0.1.5}/PersistentObjects.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{persistentobjects-0.1.4 → persistentobjects-0.1.5}/PersistentObjects.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|