Skip to content

Commit 1cea8c9

Browse files
committed
embedded python methods in objectscript
1 parent 3962774 commit 1cea8c9

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Document name="iris-python-template.ZPM">
44
<Module>
55
<Name>iris-python-template</Name>
6-
<Version>1.0.4</Version>
6+
<Version>2.0.1</Version>
77
<Description>The simplest template to run embedded python</Description>
88
<Packaging>module</Packaging>
99
<SourcesRoot>src</SourcesRoot>

src/dc/python/PersistentClass.cls

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,42 @@ Class dc.python.PersistentClass Extends %Persistent
44
/// Description
55
Property Test As %VarString;
66

7-
ClassMethod CreateRecord(ByRef id As %Integer) As %Status
7+
ClassMethod CreateRecord(propValue As %VarString = "TestString", ByRef id As %Integer) As %Status
88
{
99
set sc=$$$OK
10-
set objPC=..%New()
11-
set objPC.Test="Test string"
12-
set sc=objPC.%Save()
13-
set id=objPC.%Id()
10+
set obj=..%New()
11+
set obj.Test=propValue
12+
set sc=obj.%Save()
13+
set id=obj.%Id()
14+
return sc
15+
}
16+
17+
ClassMethod CreateRecordPython(propValue As %VarString, ByRef id As %Integer) [ Language = python ]
18+
{
19+
import iris
20+
obj=iris.cls(__name__)._New()
21+
obj.Test=propValue
22+
sc=obj._Save()
23+
id=obj._Id()
1424
return sc
1525
}
1626

1727
/// opens the record by id and reads its property
18-
ClassMethod ReadProperty(id As %Integer) As %Status
28+
ClassMethod PrintProperty(id As %Integer) As %Status
1929
{
2030
Set sc = $$$OK
2131
set obj=..%OpenId(id,,.sc)
2232
if $ISOBJECT(obj) write obj.Test
2333
Return sc
2434
}
2535

36+
ClassMethod PrintPropertyPython(id As %Integer) [ Language = python ]
37+
{
38+
import iris
39+
obj=iris.cls(__name__)._OpenId(id)
40+
print(obj.Test)
41+
}
42+
2643
Storage Default
2744
{
2845
<Data name="PersistentClassDefaultData">

0 commit comments

Comments
 (0)