Bug 42787 - UDM: has_key() and __contains__ differ
UDM: has_key() and __contains__ differ
Status: NEW
Product: UCS
Classification: Unclassified
Component: UDM (Generic)
UCS 5.0
Other Linux
: P5 normal (vote)
: ---
Assigned To: UMC maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-10-28 13:36 CEST by Florian Best
Modified: 2021-04-14 10:37 CEST (History)
2 users (show)

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): API change
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Best univentionstaff 2016-10-28 13:36:00 CEST
The methods hay_key() and __contains__ in UDM's base class simpleLDAP differ.

__contains__() checks if the key exists in the modules property_descriptions.
hay_key() does the same plus also checks if the option this property requires is activated at the current object.

The use of has_key() is deprecated and python3 removed this. We should unify the behavior. IMO __contains__ should do what hay_key() currently does.

If we change this we can replace every occurence of "object.hay_key(key)" with "key in object". Some tools like autopep8 are doing this automatically. Some automatic style checkers like pep8 are blaming the use of has_key().
Comment 1 Florian Best univentionstaff 2017-06-22 12:18:14 CEST
We could add a method has_property() which replaces the current behavior of has_key().