Bug 52683 - Select syntax type from dropdown list
Select syntax type from dropdown list
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UDM - Extended Attributes
UCS 4.4
Other Linux
: P5 normal (vote)
: UCS 4.4-8-errata
Assigned To: Philipp Hahn
Florian Best
:
Depends on:
Blocks: 53840 53870
  Show dependency treegraph
 
Reported: 2021-01-25 07:02 CET by Philipp Hahn
Modified: 2021-10-04 13:36 CEST (History)
2 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 2: Improvement: Would be a product improvement
Who will be affected by this bug?: 2: Will only affect a few installed domains
How will those affected feel about the bug?: 2: A Pain – users won’t like this once they notice it
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:
hahn: Patch_Available+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipp Hahn univentionstaff 2021-01-25 07:02:13 CET
Similar to Bug #31857 and Bug #25054 provide a list of available syntax classes selection.

univention/admin/syntax.py:
class Syntax(select):
        """
        Syntax class for Extended Attributes.
        """
        choices = []
        @classmethod
        def update_choices(cls):
                mod = sys.modules[__name__]
                cls.choices = sorted(
                        (sym, sym)
                        for sym, obj in ((sym, getattr(mod, sym)) for sym in dir(mod))
                        if isinstance(obj, type) and issubclass(obj, ISyntax)
                )
__register_choice_update_function(Syntax.update_choices)


univention/admin/handlers/settings/extended_attribute.py
        'syntax': univention.admin.property(
...
                syntax=univention.admin.syntax.Syntax,

UCS Technical training 2021-01-21/22
Comment 2 Philipp Hahn univentionstaff 2021-09-25 17:57:12 CEST
[4.4-8] ba81e362dc Bug #52683 UDM: Convert Language syntax to select
 .../univention-directory-manager-modules/modules/univention/admin/syntax.py     | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

[4.4-8] ed951f3c13 Bug #52683 UDM: Add syntax to select for EA
 management/univention-directory-manager-modules/debian/changelog          |  6 ++++++
 .../modules/univention/admin/handlers/settings/extended_attribute.py      |  2 +-
 .../modules/univention/admin/syntax.py                                    | 19 +++++++++++++++++++
 3 files changed, 26 insertions(+), 1 deletion(-)

[4.4-8] 916dda4415 Bug #52683 UDM syntax: sort import statements
 .../modules/univention/admin/syntax.py                          | 33 +++++++++++++++--------------
 1 file changed, 17 insertions(+), 16 deletions(-)

Package: univention-directory-manager-modules
Version: 14.0.20-19A~4.4.0.202109251745
Branch: ucs_4.4-0
Scope: errata4.4-8

[4.4-8] f06bb46853 Bug #52683: univention-directory-manager-modules 14.0.20-19A~4.4.0.202109251745
 doc/errata/staging/univention-directory-manager-modules.yaml | 12 ++++++++++++
 1 file changed, 12 insertions(+)
Comment 3 Florian Best univentionstaff 2021-09-27 10:30:33 CEST
RFC: the same for settings/extended_attribute:hook ?

REOPEN: We should not by default pick the first one in UMC:

diff --git management/univention-directory-manager-modules/modules/univention/admin/syntax.py management/univention-directory-manager-modules/modules/univention/admin/syntax.py
index 5af5038086..6e32d25898 100644
--- management/univention-directory-manager-modules/modules/univention/admin/syntax.py
+++ management/univention-directory-manager-modules/modules/univention/admin/syntax.py
@@ -5295,6 +5300,8 @@ class UDM_Syntax(combobox):
        """
        choices = []  # type: List[Tuple[str, str]]
 
+       empty_value = True
+
        @classmethod
        def update_choices(cls):
                mod = sys.modules[__name__]
Comment 4 Philipp Hahn univentionstaff 2021-09-28 18:51:53 CEST
(In reply to Florian Best from comment #3)
> RFC: the same for settings/extended_attribute:hook ?

1. We could do this, but "hook"s are used even less.
2. The API for hooks is also very open and getting all valid hooks from univention.admin.hook.__dict__ is tricky: "hooks" are loaded dynamically by univention.admin.modules.update() only *after* the syntax classes are updated:
95 »···univention.admin.syntax.import_syntax_files()
96 »···univention.admin.hook.iunivention/admin/modules.pymport_hook_files()
Changing the order might either break some hooks or some syntax classes.

Because of these 2 reasons I don't want to do this now.

> REOPEN: We should not by default pick the first one in UMC:
...
> management/univention-directory-manager-modules/modules/univention/admin/
> syntax.py
> +       empty_value = True

Already fixed by 5f892f35b71

Package: univention-directory-manager-modules
Version: 14.0.20-21A~4.4.0.202109271552
Branch: ucs_4.4-0
Scope: errata4.4-8
Comment 5 Philipp Hahn univentionstaff 2021-09-29 11:40:17 CEST
[phahn/31857-udm-ea2] 2a1fe4eddf fix[udm] Dynamic module loading
 management/univention-directory-manager-modules/debian/changelog                    | 6 ++++++
 management/univention-directory-manager-modules/modules/univention/admin/modules.py | 7 ++-----
 2 files changed, 8 insertions(+), 5 deletions(-)

[phahn/31857-udm-ea2] 7f5ddbd4d3 Bug #50648 UDM modules: replace os.path.walk()
 .../modules/univention/admin/modules.py                         | 33 +++++++++++++++--------------
 1 file changed, 17 insertions(+), 16 deletions(-)

[phahn/31857-udm-ea2] a46cbdb708 squash! style[udm/syntax] Make choices a list of tuple
 .../univention-directory-manager-modules/modules/univention/admin/syntax.py | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

[phahn/31857-udm-ea2] 7526263bcf squash! Bug #52683 UDM: Convert Language syntax to select
 management/univention-directory-manager-modules/modules/univention/admin/syntax.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Package: univention-directory-manager-modules
Version: 14.0.20-22A~4.4.0.202109291137
Branch: ucs_4.4-0
Scope: errata4.4-8

[phahn/31857-udm-ea2] e39bb7d0ef Bug #52683: univention-directory-manager-modules 14.0.20-22A~4.4.0.202109291137
 doc/errata/staging/univention-directory-manager-modules.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 6 Florian Best univentionstaff 2021-09-29 13:21:13 CEST
OK: languageCode
OK: UDM_Syntax
OK: modules.update()
~OK: YAML (does not mention languageCode, missing dots, no sentences)