@@ -11,6 +11,8 @@ Property %Type As %String(MAXLEN = 1000);
11
11
/// Default serialization for methods
12
12
Property %Serialization As %Integer ;
13
13
14
+ Property %EscapeOnSet As %Boolean [ InitialExpression = {$$$YES} ];
15
+
14
16
/// do ##class(isc.py.init.Test).Initialize(,1)
15
17
/// set obj = ##class(isc.py.gw.DynamicObject).%New("Person", "p1", , "'Ed'", "25", "'Test'")
16
18
/// w obj.name
@@ -53,10 +55,17 @@ Method %DispatchGetProperty(property As %String) [ ServerOnly = 1 ]
53
55
/// Set python object property
54
56
Method %DispatchSetProperty (property As %String , val ) [ ServerOnly = 1 ]
55
57
{
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)
58
60
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 )
60
69
61
70
$$$TOE(sc , ##class (isc.py.Main ).ExecuteFunction (" setattr" , arguments ))
62
71
}
0 commit comments