Here you'll find a simple program that uses Python in an IRIS environment and another simple program that uses ObjectScript in a Python environment. Also, I'd like to share a few of the troubles I went trough while learning to implement this.
Python in IRIS environment
Let's say, for example, you're in an IRIS environment and you want to solve a problem that you find easy, or more efficient with Python.
You can simply change the environment: create your method as any other, and in the end of it's name and specifications, you add [ Language = python ]:
This method provides an output such as:
will provide the following output:
On the next step, we create a connection to the desired namespace, using a path with host, port and namespace (host:port/namespace), and providing user and password:
You can access methods with the irispy.classMethodValue() by providing the class' name, the method's name and arguments, manipulate objects with .set() (for properties) and many other possibilites, while treating everything on python the way you prefer.
For more information on functions provided by iris and how to use them, check )
But also, if you want to access your local files, there are several ways to do that, and it's easy to find tutorials for that, since Python is so popular.
To me, the easiest to work with is the following:
Here I imported everything from the file testesql.py located in C:/python, and printed the results of the select() function
Extras - troubles I ran into
SHELLS: When using Shells, remember that the Windows PowerShell works as an UNIX-based system (since it is based on .NET) and the Command Prompt is the one that will work with the Windows' examples in the official documentation. This can sound basic for some more experienced programmers, but if you're not paying enough attention you can lose quite some time on this so I found important to write a bit about it.
USER AND PRIVILEGES: The current user for coding with ObjectScript from a Python environment needs to have privileges for the Namespace's resources. Remember that if you don't select any user, the current is UnknownUser, and if you don't select any namespaces, the current is USER. So, in the most simple access, you might want to follow: Management Portal > System Management > Security > Users > UnknownUser > Roles and select %DB_USER and save.
I DON'T KNOW WHAT'S GOING ON: To check more information on errors you're having, you might want to follow Management Portal > System Explorer > SQL and type "SELECT * FROM %SYS.Audit ORDER BY UTCTimeStamp Desc" to get the most recent audit. There you'll find causes for errors such as IRIS_ACCESSDENIED() and much more you might be getting even outside IRIS environment.
PYTHON COMPILING ERROR: You will want to avoid Methods names such as try() or functions that are already built in python. The compiler won't understand the difference from the Method to the function.
Thank you for reading, and please feel free to share suggestions, comments, doubts or just whatever you're developing!

SOCIAL SHARE CARD GENERATOR