Python API
Information
- Below you will find the description of the PLANTA Python API.
Technical Details
Information
- A CPython interpreter is running within the PLANTA Server (versions cannot be selected in / during iInstallation / update in the PLANTA Installer).
- Since all sessions of a server share a common interpreter, all global objects are likewise shared by all sessions.
- If you, e.g., add a new attribute to a Python module, this attribute can also be retrieved in other sessions. If a status is only to be saved in the active session,
ppms.get_session_dict()
should be used.
- If you, e.g., add a new attribute to a Python module, this attribute can also be retrieved in other sessions. If a status is only to be saved in the active session,
ppms Module
Information
- The part of the PLANTA Server which is written in C provides particular functions in a function library.
- This function library is located in the Server directory under
/dlls/
by default and is named_ppms.so
or_ppms.dll, depending on the respective operating system
.
- This function library is located in the Server directory under
- Tthe
ppms
directory contains:- the
ppms_.py
. file: this file is automatically generated by SWIG and renders the C function callable. - the
ppms.py file which combines both modules an
d contains the actual interface to PLANTA. Here, additional functions which are exclusively written in Python are added to the PLANTA objects.
- the
Injections
Information
- Python code can be stored at several positions in the system and is then executed by the program.
- During execution, a Python module object is generated from the source text. In the course of this, additional attributes may be inserted automatically.
- At each position in the system, the
ppms
module is automatically made available. For Code in the Value range field, theinspect
module is imported in addition.
Python Path
Information
- The PYTHONPATH environment variable is set for the server by the respective start scripts by default.
- After the server has started the Python interpreter, the
startup.py
which further adjusts the path is imported. - The standard order, as it is configured by PLANTA, reads as follows:
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 best be located in a separate directory 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.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 | Utilities 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