Discussion (7)1
Log in or sign up to continue

just do it in a classMethod in Objectscript
don't forget to return to your original namespace to find where you came from

For now, it's not possible in pure python, because the select namespace is specified by the environment variable IRISNAMESPACE, and environment variable can't be change in the parent process, I have tried by reloading iris module with no success.

To achieve that, for now, as Robert says, you have to create an helper method in objectscript ... :(

Class Embedded.Utils
{

ClassMethod GetNameSpace() As %Status
{

    Return $namespace
}

ClassMethod SetNameSpace(pNameSpace) As %Status
{
    zn pNameSpace
    Return $namespace
}

}

Python :

import iris

print(iris.cls("Embedded.Utils").GetNameSpace())
try:
    print(iris.cls("Security.Users").Exists("SuperUser"))
except RuntimeError:
    print("Wrong NameSpace")

print(iris.cls("Embedded.Utils").SetNameSpace("%SYS"))
try:
    print(iris.cls("Security.Users").Exists("SuperUser"))
except RuntimeError:
    print("Wrong NameSpace")

But be aware to have the method SetNamespace available also the new target namespace to be able to return !
So you either map the class to Namespace %All,
or name the class %ZEmbedded.Utils or similar,  to make it available across all namespaces.

Sorry. it just turned out that sharing across namespaces doesn't (yet?) work with embedded Python