Skip to main content
Skip table of contents

Python API

Information

  • This topic describes the public Python API of PLANTA

  • These functions are guaranteed to be supported in future versions

Technische Details

Informationen

  • Innerhalb des PLANTA-Servers läuft ein CPython-Interpreter (Versionen sind in bei der Installation / dem Update im PLANTA-Installer auswählbar).

  • Da sich alle Sessions eines Servers den gleichen Interpreter teilen, werden auch alle globalen Objekte zwischen allen Sessions geteilt.

    • Fügt man also beispielsweise einem Python-Modul ein neues Attribut hinzu, ist dieses Attribut auch in anderen Session abfragbar. Soll ein Zustand nur in der aktiven Session gespeichert werden, sollte hierfür ppms.get_session_dict() verwendet werden.

ppms-Modul

Informationen

  • Der in C geschriebene Teil des PLANTA-Servers stellt bestimmte Funktionen in einer Funktionsbibliothek zur Verfügung.

    • Diese Funktionsbibliothek liegt standardmäßig im Server-Verzeichnis unter /dlls/ und heißt je nach Betriebssystem _ppms.so oder _ppms.dll.

  • Im Verzeichnis ppms befindet sich:

    • die Datei ppms_.py. Diese Datei wird mithilfe von SWIG automatisch generiert und macht die C-Funktionen aufrufbar.

    • die Datei ppms.py, die die beiden Module kombiniert und die eigentliche Schnittstelle zu PLANTA beinhaltet. Die PLANTA-Objekte werden hier noch um Funktionen erweitert, die in purem Python geschrieben sind.

Injections

Informationen

  • An mehreren Stellen im System kann Python-Code hinterlegt werden, der vom Programm ausgeführt wird.

  • Bei der Ausführung wird aus dem Quelltext ein Python-Modul-Objekt erzeugt. Dabei werden ggf. weitere Attribute automatisch eingefügt.

  • An jeder Stelle im System wird das ppms -Modul automatisch verfügbar gemacht. Bei Code im Feld Wertebereich wird noch zusätzlich das inspect -Modul importiert.

Python-Pfad

Informationen

  • Die Umgebungsvariable PYTHONPATH wird standardmäßig von den entsprechenden Start-Skripten für den Server gesetzt.

  • Nachdem der Server den Python-Interpreter gestartet hat, wird die startup.py importiert, die den Pfad weiter anpasst

  • Die Standard-Reihenfolge, die von PLANTA konfiguriert wird, lautet wie folgt:

    1. py/distribution

    2. dlls

    3. dlls/python34.zip

    4. lib

    5. py

    6. py/pysrc

    7. py/distribution/site-packages

    8. py/api/ppms/wrapper/system

    9. py/api/ppms/wrapper

    10. py/api/ppms/customizing/venus

    11. py/api/ppms/server

Python-IDs

Individuelle Python Dateien

  • Individuelle Dateien sollten am Besten in einem eigenen Verzeichnis unter /py/<kunde> liegen 

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

PY
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.customizet.module_reader

Package for consuming module data and converting that to JSON

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.llm

Prompt templating

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

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.