Skip to content

Commit 10f7a03

Browse files
committed
cleanup
1 parent 048c169 commit 10f7a03

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

opcua/server/address_space_sqlite.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def __contains__(self, nodeid):
6767
def __setitem__(self, key, value):
6868
# TODO the item in the database it is not updated
6969
super(AddressSpaceSQLite, self).__setitem__(key, value)
70-
7170

7271
def keys(self):
7372
raise Exception("dict.keys() is not supported for performance. Use iterator.")
@@ -98,16 +97,17 @@ def dump(self, namespaceidx=AddressSpace.DEFAULT_USER_NAMESPACE_INDEX):
9897
with self._lock:
9998
# 2. Populate.
10099
for nodeid, ndata in self._cache.items():
101-
if nodeid.NamespaceIndex != namespaceidx:
102-
for ref in ndata.references:
103-
if ref.NodeId.NamespaceIndex == namespaceidx:
104-
keyNodeId = AddressSpaceSQLite._nodeid_to_key(ndata.nodeid)
105-
AddressSpaceSQLite._insert_reference(self._conn, keyNodeId, ref)
106-
print('INTER_NAMESPACE REF {:s}/{:d}->{:d}'.format(str(nodeid.Identifier), nodeid.NamespaceIndex, ref.NodeId.NamespaceIndex))
107-
continue
108100
assert(nodeid == ndata.nodeid)
109101
assert(isinstance(ndata, NodeData))
110-
AddressSpaceSQLite._write_nodedata(self._conn, ndata)
102+
if nodeid.NamespaceIndex == namespaceidx:
103+
AddressSpaceSQLite._write_nodedata(self._conn, ndata)
104+
continue
105+
# inter-namespace references.
106+
for ref in ndata.references:
107+
if ref.NodeId.NamespaceIndex != namespaceidx:
108+
continue
109+
keyNodeId = AddressSpaceSQLite._nodeid_to_key(ndata.nodeid)
110+
AddressSpaceSQLite._insert_reference(self._conn, keyNodeId, ref)
111111

112112
# 3. Integrity checks.
113113
for nodeid, ndata in self._cache.items():
@@ -162,11 +162,6 @@ def _read_nodedata(conn, nodeid, nodeData, attrTable=ATTR_TABLE_NAME, refsTable=
162162
referred_nodeids = [r.NodeId for r in nodeData.references]
163163
for row in _c_read.execute(cmd2):
164164
ref = AddressSpaceSQLite._read_reference_row(row)
165-
#try:
166-
# idx = referred_nodeids.index(ref.NodeId)
167-
# print('DUPLICATE {:s}'.format(str(ref.NodeId)))
168-
# nodeData.references[idx] = ref
169-
#except ValueError:
170165
nodeData.references.append(ref)
171166

172167
# Read and write from attribute table
Binary file not shown.

0 commit comments

Comments
 (0)