Skip to content

Commit b81e4b6

Browse files
committed
ProxylessGateway: Dynamic object initial implementation
Fixed: #40
1 parent b5c3124 commit b81e4b6

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

isc/py/gw/DynamicObject.cls

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/// Dynamic Python object
2+
Class isc.py.gw.DynamicObject Extends %RegisteredObject
3+
{
4+
5+
Property %Name As %String(MAXLEN = 1000);
6+
7+
Property %Type As %String(MAXLEN = 1000);
8+
9+
Property %Serialization As %Integer;
10+
11+
/// do ##class(isc.py.init.Test).Initialize(,1)
12+
/// set obj = ##class(isc.py.gw.DynamicObject).%New("Person", "p1", , "'Ed'", "25", "'Test'")
13+
/// w obj.name
14+
/// s obj.name="Bob"
15+
/// w obj.name
16+
/// w obj.age
17+
/// w obj.getAge()
18+
/// w obj.getAgePlus(10)
19+
Method %OnNew(type, variable, serialization As %Integer = {##class(isc.py.Callout).#SerializationStr}, args...) As %Status [ Private, ServerOnly = 1 ]
20+
{
21+
set ..%Name = variable
22+
set ..%Type = type
23+
set ..%Serialization = serialization
24+
quit ##class(isc.py.Main).ExecuteFunctionArgs(type, variable,,, args...)
25+
}
26+
27+
/// Get serialized property value
28+
Method %DispatchGetProperty(property As %String) [ ServerOnly = 1 ]
29+
{
30+
$$$TOE(sc, ##class(isc.py.Main).GetVariableInfo(..%Name _ "." _ property, ..%Serialization, .defined, .type, .length))
31+
throw:'defined ##class(%Exception.General).%New("<PROPERTY>", property)
32+
33+
$$$TOE(sc, ##class(isc.py.Main).SimpleString("zzzproperty=" _ ..%Name _ "." _ property, "zzzproperty", ..%Serialization, .zzzproperty))
34+
$$$TOE(sc, ##class(isc.py.Main).SimpleString("del zzzproperty"))
35+
36+
quit zzzproperty
37+
}
38+
39+
/// Set python object property
40+
Method %DispatchSetProperty(property As %String, val) [ ServerOnly = 1 ]
41+
{
42+
$$$TOE(sc, ##class(isc.py.Main).GetVariableInfo(..%Name _ "." _ property, ..%Serialization, .defined, .type, .length))
43+
throw:'defined ##class(%Exception.General).%New("<PROPERTY>", property)
44+
45+
set arguments = $lb(..%Name, ##class(isc.py.util.Converter).EscapeString(property), ##class(isc.py.util.Converter).EscapeString(val))
46+
47+
$$$TOE(sc, ##class(isc.py.Main).ExecuteFunction("setattr", arguments))
48+
}
49+
50+
/// Call python function
51+
Method %DispatchMethod(method As %String, args...) [ ServerOnly = 1 ]
52+
{
53+
$$$TOE(sc, ##class(isc.py.Main).ExecuteFunctionArgs(..%Name _ "." _ method, ,..%Serialization, .result, args...))
54+
quit result
55+
}
56+
57+
}
58+

0 commit comments

Comments
 (0)