Skip to content

Commit 122c537

Browse files
authored
Update Gateway.md
1 parent 8b7dc8c commit 122c537

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

Gateway.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class Person(object):
135135
return self.age + add
136136
```
137137

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'")`
139139
In this call we create Python variable `p1` of `Person` class and pass three methods to constructor `'Ed'`, `25` and `'Test'`.
140140

141141
3. Now we can interact with the object, let's get and set some properties:
@@ -163,7 +163,7 @@ write obj.getAgePlus(10)
163163
set sc = obj.%ToJSON(.json)
164164
set sc = obj.%ToDynObj(.dynObj)
165165
set sc = obj.%ToPickle(.pickle)
166-
set sc = obj.%ToStream(,.stream)
166+
set sc = obj.%ToStream(.stream)
167167
```
168168

169169
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
185185

186186
```
187187
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]]")
190190
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))
192192
```
193193

194194
And here's an example of setting property to proxy object:
195195

196196
```
197197
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()
205201
202+
set obj.relative = obj2
203+
set obj3 = obj.relative
204+
write obj3.%GetJSON()
206205
```
207206

208207
You can use `%EscapeOnSet` and `%EscapeOnCall` properties and `%IsPrimitive` method to affect default serialization behaviour.

0 commit comments

Comments
 (0)