Commit 88339454 authored by Ivan Tyagov's avatar Ivan Tyagov

Convert to proper Python type based on node_id.

parent a745cfa2
...@@ -6,6 +6,21 @@ from erp5.component.module.Log import log ...@@ -6,6 +6,21 @@ from erp5.component.module.Log import log
# XXX: get rid of Proxy roles on this script when proper authentication is used!!! # XXX: get rid of Proxy roles on this script when proper authentication is used!!!
def convertNodeValue(node_id, node_value):
"""
Based on node_id convert to proper Python type. Based on this format:
ns=<namespaceindex>;<type>=<value>
XXX: handle rest of datatypes!
"""
node_type = node_id.split(";")[1]
if node_type.startswith("s"):
node_value = str(node_value)
if node_type.startswith("i"):
node_value = int(node_value)
return node_value
# XXX: what should be the OPCUA container? # XXX: what should be the OPCUA container?
default_opcua_document = context.opcua_document_module["1"] default_opcua_document = context.opcua_document_module["1"]
...@@ -24,6 +39,6 @@ else: ...@@ -24,6 +39,6 @@ else:
# set to "ERP5 OPCUA Document" # set to "ERP5 OPCUA Document"
node_dict = default_opcua_document.getNodeDict() node_dict = default_opcua_document.getNodeDict()
log("Original = %s" %node_dict) log("Original = %s" %node_dict)
node_dict[node_id] = node_value node_dict[node_id] = convertNodeValue(node_id, node_value)
default_opcua_document.setNodeDict(node_dict) default_opcua_document.setNodeDict(node_dict)
log("Changed = %s" %default_opcua_document.getNodeDict()) log("Changed = %s" %default_opcua_document.getNodeDict())
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<value> <value>
<list> <list>
<string>editable</string> <string>editable</string>
<string>title</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -75,6 +76,10 @@ ...@@ -75,6 +76,10 @@
<key> <string>form_id</string> </key> <key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value> <value> <string>Base_viewFieldLibrary</string> </value>
</item> </item>
<item>
<key> <string>title</string> </key>
<value> <string>Node Dictionary</string> </value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment