Upgrades
This document lists all current deprecations, with upgrade steps and planned removal. When the deprecation is removed with a major update, it will be moved under its corresponding header.
This version
U64 - Replace PrivilegedAPI by explicit privileged
flag
- deprecated since: v12.6.0
- planned removal: v13
- automated code fix available: no
Current behaviour + reason for change
Privileged API calls are done by using the PrivilegedAPI
class. A danger of this approach is that the object may be
instantiated well in advance of the actual API call, such that it is no longer transparent whether that call is
privileged or not. Furthermore, PrivilegedAPI
and the default API
could be mixed within a method which can also
result in unwanted privileged calls.
New behaviour
The PrivilegedAPI
class will be removed and privileged API calls should be done by adding an explicit privileged
flag in the corresponding method (e.g. entity.children(privileged=True)
). The following methods are affected:
API.get_entity()
API.get_entity_file()
API.get_root_entities()
Entity.parent()
Entity.children()
Entity.siblings()
caution
If not used properly, (confidential) information which SHOULD NOT be accessible by a user may
leak (for instance by including data in a view). Please consider the following when using the privileged
flag:
- Make sure the app's admin is aware that the code circumvents certain permissions at specific places.
- Make sure to test the implementation thoroughly, to ensure no confidential data is leaked.
Conversion
- api = PrivilegedAPI()
- privileged_root_entities = api.get_root_entities()
+ api = API()
+ privileged_root_entities = api.get_root_entities(privileged=True)
U63 - Remove prefix
and suffix
on DateField
- deprecated since: v12.5.0
- planned removal: v13
- automated code fix available: no
Current behaviour + reason for change
A prefix
and / or suffix
can be defined on a DateField, which is not relevant for this type of field. The
attributes will therefore be removed.
New behaviour
It will not be possible to use prefix
and suffix
on a DateField.
Conversion
- DateField('Some date', suffix='XYZ')
+ DateField('Some date (XYZ)')
U62 - Renamed threejs_visualisation()
to visualize_geometry()
- deprecated since: v12.5.0
- planned removal: v13
- automated code fix available: yes
Current behaviour + reason for change
A SoilLayout2D
or SoilLayer2D
can be visualized by calling threejs_visualisation()
on the
corresponding object. The "threejs" part in this name is no longer relevant and might be unclear to the developer.
New behaviour
Both methods return the geometric representation of the object, which can be used in a GeometryView. Therefore the
methods are renamed to visualize_geometry()
:
SoilLayout2D.threejs_visualisation()
->SoilLayout2D.visualize_geometry()
SoilLayer2D.threejs_visualisation()
->SoilLayer2D.visualize_geometry()
Conversion
The following conversion has to be performed, which can be done automatically by using the CLI command
viktor-cli fix -u 62
:
layout = SoilLayout2D(...)
- geometry, labels = layout.threejs_visualisation(...)
+ geometry, labels = layout.visualize_geometry(...)
U61 - Move entity-type information from manifest to Controller
- deprecated since: v12.3.0
- planned removal: v13
- automated code fix available: yes
Current behaviour + reason for change
The entity-type information is currently partly described in the corresponding Controller (parametrization / views / summary),
but some data is defined in the manifest.yml
(label, children, show_children_as). This manifest is a concept which is
often hard to grasp for a starting developer. In order to improve the onboarding of new developers, as well as
consistency of where to define entity-type information, we would like to get rid of the manifest completely.
The first step is to move the definition of the following keys to the corresponding controller:
label
(required)children
(if present)show_children_as
(if present)
New behaviour
The keys will become simple class attributes, similar as parametrization
and summary
:
class EntityTypeController(ViktorController):
label = 'Label of the entity-type'
children = ['SomeType', 'AnotherType']
show_children_as = 'Cards' # or 'Table'
If they are still present in the manifest, you may expect the following warning:
Entity.label is present in manifest.yml but is overwritten by the app logic. Remove entry from manifest.
Note, when you are defining label
on the Controller, the SDK will also try to get children
+ show_children_as
or use the default of "no children" if not found. Therefore you cannot define label
on the Controller, while
keeping children
and show_children_as
in the manifest!
Conversion
The following conversion has to be performed, which can be done automatically by using the CLI command
viktor-cli fix -u 61
:
# manifest.yml
version: '1'
entity_types:
EntityTypeA:
- label: This is A
- show_children_as: Cards
- children:
- - EntityTypeB
...
EntityTypeB:
- label: This is B
...
# entity_type_a/controller.py
class EntityTypeAController(ViktorController):
+ label = 'This is A'
+ children = ['EntityTypeB']
+ show_children_as = 'Cards'
...
# entity_type_b/controller.py
class EntityTypeBController(ViktorController):
+ label = 'This is B'
...