def ucr_overwrite_properties(module, lo): # type: (Any, univention.admin.uldap.access) -> None """ Overwrite properties in property_descriptions by UCR variables """ ucr_prefix = ucr_property_prefix % module.module if not module: return for var in configRegistry.keys(): if not var.startswith(ucr_prefix): continue try: prop_name, attr = var[len(ucr_prefix):].split('/', 1) # ignore internal attributes ud.debug(ud.ADMIN, ud.INFO, 'ucr_overwrite_properties: found variable: %s' % var) if attr.startswith('__'): continue if attr == 'default': # a property object is instantiated with default=... # but internally uses "base_default" as member variable # "default" is an instance_method... attr = 'base_default' if prop_name in module.property_descriptions: prop = module.property_descriptions[prop_name] ud.debug(ud.ADMIN, ud.INFO, 'ucr_overwrite_properties: found property') if hasattr(prop, attr): new_prop_val = configRegistry[var] old_prop_val = getattr(prop, attr) if old_prop_val is None: # if the attribute was None the type cast # will fail. best bet is str as type old_prop_val = '' prop_val_type = type(old_prop_val) ud.debug(ud.ADMIN, ud.INFO, 'ucr_overwrite_properties: set property attribute %s to %s' % (attr, new_prop_val)) if attr in ('syntax', ): if hasattr(univention.admin.syntax, new_prop_val): syntax = getattr(univention.admin.syntax, new_prop_val) setattr(prop, attr, syntax()) else: if lo.search(filter=filter_format(univention.admin.syntax.LDAP_Search.FILTER_PATTERN, [new_prop_val])): syntax = univention.admin.syntax.LDAP_Search(new_prop_val) syntax._load(lo) setattr(prop, attr, syntax) else: syntax = univention.admin.syntax.string() setattr(prop, attr, syntax()) elif prop_val_type is bool: setattr(prop, attr, configRegistry.is_true(None, None, new_prop_val)) else: setattr(prop, attr, prop_val_type(new_prop_val)) ud.debug(ud.ADMIN, ud.INFO, 'ucr_overwrite_properties: get property attribute: %s (type %s)' % (old_prop_val, prop_val_type)) except Exception as exc: ud.debug(ud.ADMIN, ud.ERROR, 'ucr_overwrite_properties: failed to set property attribute: %s' % (exc,)) continue
def __init__(self, short_description='', long_description='', syntax=None, module_search=None, multivalue=False, one_only=False, parent=None, options=[], license=[], required=False, may_change=True, identifies=False, unique=False, default=None, prevent_umc_default_popup=False, dontsearch=False, show_in_lists=False, editable=True, configObjectPosition=None, configAttributeName=None, include_in_default_search=False, nonempty_is_default=False, readonly_when_synced=False, size=None, copyable=False): self.short_description = short_description self.long_description = long_description if isinstance(syntax, types.ClassType): self.syntax = syntax() else: self.syntax = syntax self.module_search = module_search self.multivalue = multivalue self.one_only = one_only self.parent = parent self.options = options self.license = license self.required = required self.may_change = may_change self.identifies = identifies self.unique = unique self.base_default = default self.prevent_umc_default_popup = prevent_umc_default_popup self.dontsearch = dontsearch self.show_in_lists = show_in_lists self.editable = editable self.configObjectPosition = configObjectPosition self.configAttributeName = configAttributeName self.templates = [] self.include_in_default_search = include_in_default_search self.threshold = int( configRegistry.get('directory/manager/web/sizelimit', '2000') or 2000) self.nonempty_is_default = nonempty_is_default self.readonly_when_synced = readonly_when_synced self.size = size self.copyable = copyable
def __init__( self, short_description='', # type: str long_description='', # type: str syntax=None, # type: Union[Type, Any] module_search=None, # type: None multivalue=False, # type: bool one_only=False, # type: bool parent=None, # type: str options=[], # type: List[str] license=[], # type: List[str] required=False, # type: bool may_change=True, # type: bool identifies=False, # type: bool unique=False, # type: bool default=None, # type: Any prevent_umc_default_popup=False, # type: bool dontsearch=False, # type: bool show_in_lists=False, # type: bool editable=True, # type: bool configObjectPosition=None, # type: None configAttributeName=None, # type: None include_in_default_search=False, # type: bool nonempty_is_default=False, # type: bool readonly_when_synced=False, # type: bool size=None, # type: str copyable=False # type: bool ): # type: (...) -> None """ |UDM| property. :param short_description: a short descriptive text - shown below the input filed in |UMC| by default. :param long_description: a long descriptive text - shown only on demand in |UMC|. :param syntax: a syntax class or instance to validate the value. :param module_search: UNUSED? :param multivalue: allow only a single value (`False`) or multiple values (`True`) . :param one_only: UNUSED? :param parent: UNUSED? :param options: List of options, which enable this property. :param license: List of license strings, which are required to use this property. :param required: `True` for a required property, `False` for an optional property. :param may_change: `True` if the property can be changed after the object has been created, `False` when the property can only be specified when the object is created. :param identifies: `True` if the property is part of the set of properties, which are required to uniquely identify the object. The properties are used by default to build |RDN| for a new object. :param unique: `True` if the property must be unique for all object instances. :param default: The default value for the property when a new object is created. :param prevent_umc_default_popup: `True` to prevent a pop-up dialog in |UMC| when the default value is not set. :param dontsearch: `True` to prevent searches using the property. :param show_in_lists: UNUSED? :param editable: `False` prevents the property from being modified by the user; it still can be modified by code. :param configObjectPosition: UNUSED? :param configAttributeName: UNUSED? :param include_in_default_search: The default search searches this property when set to `True`. :param nonempty_is_default: `True` selects the first non-empty value as the default. `False` always selects the first default value, even if it is empty. :param readonly_when_synced: `True` only shows the value as read-only when synchronized from some upstream database. :param size: The |UMC| widget size; one of :py:data:`univention.admin.syntax.SIZES`. :param copyable: With `True` the property is copied when the object is cloned; with `False` the new object will use the default value. """ self.short_description = short_description self.long_description = long_description if isinstance(syntax, types.ClassType): self.syntax = syntax() else: self.syntax = syntax self.module_search = module_search self.multivalue = multivalue self.one_only = one_only self.parent = parent self.options = options or [] self.license = license or [] self.required = required self.may_change = may_change self.identifies = identifies self.unique = unique self.base_default = default self.prevent_umc_default_popup = prevent_umc_default_popup self.dontsearch = dontsearch self.show_in_lists = show_in_lists self.editable = editable self.configObjectPosition = configObjectPosition self.configAttributeName = configAttributeName self.templates = [ ] # type: List # univention.admin.handlers.simpleLdap self.include_in_default_search = include_in_default_search self.threshold = int( configRegistry.get('directory/manager/web/sizelimit', '2000') or 2000) self.nonempty_is_default = nonempty_is_default self.readonly_when_synced = readonly_when_synced self.size = size self.copyable = copyable