@@ -135,7 +135,7 @@ class Person(object):
135
135
return self.age + add
136
136
```
137
137
138
- 2 . Create Proxy variable: ` set obj = ##class(isc.py.gw.DynamicObject).%New("Person", "p1", , "'Ed'", "25", "'Test'") `
138
+ 2 . Create Proxy variable: ` set obj = ##class(isc.py.gw.DynamicObject).%New("Person", "p1", "'Ed'", "25", "'Test'") `
139
139
In this call we create Python variable ` p1 ` of ` Person ` class and pass three methods to constructor ` 'Ed' ` , ` 25 ` and ` 'Test' ` .
140
140
141
141
3 . Now we can interact with the object, let's get and set some properties:
@@ -163,7 +163,7 @@ write obj.getAgePlus(10)
163
163
set sc = obj.%ToJSON(.json)
164
164
set sc = obj.%ToDynObj(.dynObj)
165
165
set sc = obj.%ToPickle(.pickle)
166
- set sc = obj.%ToStream(, .stream)
166
+ set sc = obj.%ToStream(.stream)
167
167
```
168
168
169
169
To create proxy object from existing proxy object just skip type argument:
@@ -185,24 +185,23 @@ Now for a more complex example. In case of primitives (int, bool, str, float) pr
185
185
186
186
```
187
187
set sc = ##class(isc.py.Main).ImportModule("numpy",,"np")
188
- set np =##class(isc.py.gw.DynamicObject).%New(,"np")
189
- set arr =##class(isc.py.gw.DynamicObject).%New("np.array", "arr", ,"[[1.5,2],[4,5]]")
188
+ set np = ##class(isc.py.gw.DynamicObject).%New(,"np")
189
+ set arr = ##class(isc.py.gw.DynamicObject).%New("np.array", "arr","[[1.5,2],[4,5]]")
190
190
set exp = np.exp(arr)
191
- w $replace(exp.%GetString(),$c(10), $c(13,10))
191
+ write $replace(exp.%GetString(),$c(10), $c(13,10))
192
192
```
193
193
194
194
And here's an example of setting property to proxy object:
195
195
196
196
```
197
197
do ##class(isc.py.init.Test).Initialize(,1)
198
- set obj = ##class(isc.py.gw.DynamicObject).%New("Person", "p1", , "'Ed'", "25", "'Test'")
199
- set obj2 = ##class(isc.py.gw.DynamicObject).%New("Person", "p2", , "'Bob'", "22", "'Test2'")
200
- w obj.%GetJSON()
201
-
202
- s obj.relative = obj2
203
- s obj3 = obj.relative
204
- w obj3.%GetJSON()
198
+ set obj = ##class(isc.py.gw.DynamicObject).%New("Person", "p1", "'Ed'", "25", "'Test'")
199
+ set obj2 = ##class(isc.py.gw.DynamicObject).%New("Person", "p2", "'Bob'", "22", "'Test2'")
200
+ write obj.%GetJSON()
205
201
202
+ set obj.relative = obj2
203
+ set obj3 = obj.relative
204
+ write obj3.%GetJSON()
206
205
```
207
206
208
207
You can use ` %EscapeOnSet ` and ` %EscapeOnCall ` properties and ` %IsPrimitive ` method to affect default serialization behaviour.
0 commit comments