Skip to content

Commit 4814ee9

Browse files
committed
Refactor initialization methods and enhance Python attribute processing in IOP.Common and IOP.Utils classes; update tests for production settings to assert None values correctly.
1 parent cab2bb0 commit 4814ee9

File tree

3 files changed

+37
-18
lines changed

3 files changed

+37
-18
lines changed

src/iop/cls/IOP/Common.cls

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,12 @@ Method GetModule() As %String
3737
Return ..%module
3838
}
3939

40-
Method %OnNew(pConfigName As %String) As %Status
41-
{
42-
$$$ThrowOnError(..Connect())
43-
$$$ThrowOnError($method($this,"initConfig",.pConfigName)) ; call subclass
44-
do ..%class."_debugpy"($this)
45-
Quit $$$OK
46-
}
47-
4840
Method OnInit() As %Status
4941
{
5042
set tSC = $$$OK
5143
try {
52-
44+
$$$ThrowOnError(..Connect())
45+
do ..%class."_debugpy"($this)
5346
do ..%class."_dispatch_on_init"($this)
5447
} catch ex {
5548
set tSC = ex.AsStatus()
@@ -149,6 +142,40 @@ Method SetPropertyValues()
149142
$$$LOGWARNING(ex.DisplayString())
150143
}
151144
}
145+
// Now process the Python Attributes Settings
146+
// First list all the properties of the current class
147+
set class = $CLASSNAME()
148+
set tSQL = "SELECT * FROM %Dictionary.PropertyDefinition WHERE parent = ?"
149+
set tSQL = tSQL _ " AND name <> 'timeout'"
150+
set tSQL = tSQL _ " and name <> 'enable'"
151+
set tSQL = tSQL _ " and name <> '%classpaths'"
152+
set tSQL = tSQL _ " and name <> '%classname'"
153+
set tSQL = tSQL _ " and name <> '%module'"
154+
set tSQL = tSQL _ " and name <> 'port'"
155+
set tSQL = tSQL _ " and name <> 'PythonInterpreterPath'"
156+
157+
set tStmt = ##class(%SQL.Statement).%New()
158+
159+
set tSC = tStmt.%Prepare(tSQL)
160+
if $$$ISERR(tSC) {
161+
$$$LOGERROR("Error preparing SQL statement: "_tSC)
162+
quit
163+
}
164+
set tRs = tStmt.%Execute(class)
165+
166+
while tRs.%Next() {
167+
set property = tRs.%Get("Name")
168+
set value = $property($this,property)
169+
170+
if value'="" {
171+
try {
172+
set $property(..%class,property) = value
173+
} catch ex {
174+
$$$LOGWARNING(ex.DisplayString())
175+
}
176+
}
177+
}
178+
152179
quit
153180
}
154181

src/iop/cls/IOP/Utils.cls

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -309,14 +309,6 @@ ClassMethod GenerateProxyClass(
309309

310310
Set tSC = tCOSClass.Properties.Insert(tCustomProp)
311311
Quit:$$$ISERR(tSC)
312-
313-
#dim tMethod As %Dictionary.MethodDefinition = ##class(%Dictionary.MethodDefinition).%New()
314-
Set tMethod.Name = tPropName_"Set"
315-
Set tMethod.ReturnType = "%Status"
316-
Set tMethod.FormalSpec = "value:"_tDataType
317-
Do tMethod.Implementation.WriteLine(" Set ..%class."""_tPropName_""" = value")
318-
Do tMethod.Implementation.WriteLine(" Quit $$$OK")
319-
Set tSC = tCOSClass.Methods.Insert(tMethod)
320312

321313
Set tPropCat = "Python Attributes"
322314
Set tSETTINGSParamValue = tSETTINGSParamValue_","_tPropName_":"_tPropCat

src/tests/test_bproduction_settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def setup_class(cls):
1616

1717
def test_my_none_var(self):
1818
rsp = _Director.test_component('UnitTest.MySettingOperation',None,'iris.Ens.StringRequest',"my_none_var")
19-
assert rsp.value == ''
19+
assert rsp.value == None
2020

2121
def test_my_str_var(self):
2222
rsp = _Director.test_component('UnitTest.MySettingOperation',None,'iris.Ens.StringRequest',"my_str_var")

0 commit comments

Comments
 (0)