Python API
Information
- This topic describes the public Python API f PLANTA
- These functions are guaranteed to be supported in future versions
Technical details
Information
- Within the PLANTA Server, a CPython interpreter is running (versions can be selected in PLANTA Installer during installation / update).
- Since all sessions of a server share the same interpreter, all global objects are shared between all sessions as well.
- If you add, e.g., a new attribute to a Python module, this attribute will be retrievable in other sessions as well. If a status is to be saved in the active session only, you should use
ppms.get_session_dict()
.
- If you add, e.g., a new attribute to a Python module, this attribute will be retrievable in other sessions as well. If a status is to be saved in the active session only, you should use
PPMS Module
Information
- The part of the PLANTA Server written in C makes particular functions available in a function library.
- This function library is located in the server directory under
/dlls/
by default and named_ppms.so
or_ppms.dll
depending on the operating system.
- This function library is located in the server directory under
- In the
ppms
directory you will find:- the
ppms_.py
file. This file is automatically generated with the help of SWIG and makes the C function available. - the
ppms.py
file which combines the two modules and contains the actual interface to PLANTA. The PLANTA objects are still extended by additional functions which are purely written in Python.
- the
Injections
Information
- You can store a Python code at several positions in the system which will then be executed by the program.
- Upon execution, a Python module object is created from the source text. As a result, further attributes may be inserted automatically.
- At every position in the system, the
ppms
module is made available automatically. If there is a code in the Value range field, theinspect
module is imported additionally.
Python Path
Information
- By default, the PYTHONPATH environment variable is set for the server by the respective start scripts.
- After the server has started the Python interpreter, the
startup.py
, which further adjusts the path, will be imported. - The standard order configured by PLANTA is the following:
py/distribution
dlls
dlls/python34.zip
lib
py
py/pysrc
py/distribution/site-packages
py/api/ppms/wrapper/system
py/api/ppms/wrapper
py/api/ppms/customizing/venus
py/api/ppms/server
Python IDs
- DI/DF Python IDs can be used in the following data items:
Individual Python files
- Individual files should be placed in their own directories under /py/<customer>
Logging
You can use logging calls to debug your Python code.
- The logging is written to both the wrapper and session log file
- To work with custom python packages they must reside in your /py/api/ folder
import logging
logger = logging.getLogger(__name__)
def my_func(arg):
logger.info('Custom func was called!')
# ...
Customizing API
Namespace | Topic |
---|---|
ppms.assignment_module | General assignment API |
ppms.create_project | Creating projects |
ppms.create_report | Creating reports |
ppms.cu_access | Customizer access |
ppms.customizer.mail | API for sending emails |
ppms.debugging | Debugging Python code |
ppms.dimmer | Client-side dimmer |
ppms.file_utils | Utilities for working with files |
ppms.global_setting | Reading global settings |
ppms.period | Creating period records |
ppms.project_rights | Project rights |
ppms.psp_elements | PSP elements |
ppms.rights | General rights API |
ppms.sql | Uilities for working with the database |
ppms.user_interface
The ppms.user_interface
package provides various helper functions that affect how the user interacts with the client.
ppms.interface
The ppms.interface
package contains the PLANTA link API.
Server API
Namespace | Content |
---|---|
ppms.text_constant | Using text constants |
planta_logging.logging | PLANTA Server Logging |
ppms.migration
The ppms.migration
package implements the migration framework and provides the base classes for writing new migration packets.
Related Topics
The API style guide can be found (in German) in the topic PythonApiStyleGuide