Register scripts as modules
Product line
Standard
|Expert
Operating mode
CLOUD ABO
|ON-PREMISES
Modules
Services & CRM
Budget & Phases
Purchases
Resource Planning
Business Intelligence
In Python it is possible to call features and classes from other scripts. Features and classes that are used more often or in several scripts can be outlays into a separate script (module).
Scripts are also used as modules for Custom Renderer and List Controller , as well as for customer-specific adjustments of Resource Planning and of Interfaces (Extensions) .
A module is created like a normal script via settings > Reports & Scripts > Scripts: Right-click New > Script entry.
The following fields are relevant for modules:
designation |
Module names must not have spaces in their names. Umlauts are also not recommended. The module will be imported or called later with this name. It is best to choose a designation that gives an indication of the content, so that you can easily identify which module it is in the list. Note that Python is case-sensitive, so the module must be called in the same case as the designation defined here. |
Platform |
For modules, Python must be selected here. In Vertec versions before 6.6, this field does not exist yet. In this case, the script text must start with a #. |
Extended user rights |
If registered scripts should later be able to be executed by users with restricted user rights, an extended permission can be accepted for the corresponding code points. See the article Extended user rights in scripts . Note that accepting extended user rights during the execution of the extended code takes effect system-wide, even if you call something from another module in a script. |
Script text |
This is where the Python code is inserted. See the section Code in scripts as modules below. |
Script Editor... |
Opens the script in the. Script Editor . The Script Editor is then directly linked to the script entry. This means that if code is modified in the Script Editor, the script text in the script entry also changes. |
Classes and features can be defined in modules.
def funktionsname(): ...
Parameters can be passed to the feature in parentheses. Features without parameters are created with blank parentheses.
To call a feature from another script (module), it must first be imported:
import modulname
The module name corresponds to the designation of the script (see above). The function is called via
modulname.funktionsname
import modulname modulname.funktionsname
class classname: ...
If the class inherits from another class, it can be passed in parentheses:
class baseclassname: ... class classname(baseclassname): ...
Features can also be defined within the class.
Custom Renderers , List Controllers and Resource Planning enhancements specify which features you can and must define. Access is via modulname.classname.
For custom collections, you can define the features yourself. To use a class from another module, it must first be imported:
import modulname
If features are to be used by this class, both the module and the class must be imported:
from modulname import classname
If a module is modified, it is reloaded the next time it is called within the same session (from Vertec 6.4).
Other sessions detect the changed script code via Notif Server, but do not reload the module. In this case either Vertec must be restarted or the module must be reloaded with the command reload(modulname)
reloaded. Either once in the Script Editor
or directly in the script:
import modulname reload(modulname)