Skip to content

Commit 026fddf

Browse files
committed
Proxyless gateway: support for unknown properties set. %EscapeOnSet property.
1 parent dfab5d2 commit 026fddf

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

isc/py/gw/DynamicObject.cls

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Property %Type As %String(MAXLEN = 1000);
1111
/// Default serialization for methods
1212
Property %Serialization As %Integer;
1313

14+
Property %EscapeOnSet As %Boolean [ InitialExpression = {$$$YES} ];
15+
1416
/// do ##class(isc.py.init.Test).Initialize(,1)
1517
/// set obj = ##class(isc.py.gw.DynamicObject).%New("Person", "p1", , "'Ed'", "25", "'Test'")
1618
/// w obj.name
@@ -53,10 +55,17 @@ Method %DispatchGetProperty(property As %String) [ ServerOnly = 1 ]
5355
/// Set python object property
5456
Method %DispatchSetProperty(property As %String, val) [ ServerOnly = 1 ]
5557
{
56-
$$$TOE(sc, ##class(isc.py.Main).GetVariableInfo(..%Variable _ "." _ property, ..%Serialization, .defined, .type, .length))
57-
throw:'defined ##class(%Exception.General).%New("<PROPERTY>", property)
58+
//$$$TOE(sc, ##class(isc.py.Main).GetVariableInfo(..%Variable _ "." _ property, ..%Serialization, .defined, .type, .length))
59+
//throw:'defined ##class(%Exception.General).%New("<PROPERTY>", property)
5860

59-
set arguments = $lb(..%Variable, ##class(isc.py.util.Converter).EscapeString(property), ##class(isc.py.util.Converter).EscapeString(val))
61+
if ($isObject(val) && val.%Extends("isc.py.gw.DynamicObject")) {
62+
set value = val.%Variable
63+
} elseif (..%EscapeOnSet) {
64+
set value = ##class(isc.py.util.Converter).EscapeString(val)
65+
} else {
66+
set value = val
67+
}
68+
set arguments = $lb(..%Variable,##class(isc.py.util.Converter).EscapeString(property), value)
6069

6170
$$$TOE(sc, ##class(isc.py.Main).ExecuteFunction("setattr", arguments))
6271
}

0 commit comments

Comments
 (0)