|
Lines 275-281
def get_default_values(self, property_name):
Link Here
|
| 275 |
if key == property_name: |
275 |
if key == property_name: |
| 276 |
value = default_value(prop.syntax) |
276 |
value = default_value(prop.syntax) |
| 277 |
if isinstance(value, (list, tuple)): |
277 |
if isinstance(value, (list, tuple)): |
| 278 |
value = read_syntax_choices(prop.syntax.name) |
278 |
value = read_syntax_choices(prop.syntax) |
| 279 |
return value |
279 |
return value |
| 280 |
|
280 |
|
| 281 |
def _map_properties(self, obj, properties): |
281 |
def _map_properties(self, obj, properties): |
|
Lines 1126-1141
def _get_syntax(syntax_name):
Link Here
|
| 1126 |
return udm_syntax.__dict__[syntax_name]() |
1126 |
return udm_syntax.__dict__[syntax_name]() |
| 1127 |
|
1127 |
|
| 1128 |
|
1128 |
|
| 1129 |
def search_syntax_choices_by_key(syntax_name, key): |
1129 |
def search_syntax_choices_by_key(syn, key): |
| 1130 |
syn = _get_syntax(syntax_name) |
|
|
| 1131 |
if syn is None: |
| 1132 |
return None |
| 1133 |
|
| 1134 |
if issubclass(syn.__class__, udm_syntax.UDM_Objects): |
1130 |
if issubclass(syn.__class__, udm_syntax.UDM_Objects): |
| 1135 |
if syn.key == 'dn': |
1131 |
if syn.key == 'dn': |
| 1136 |
module_search_options = {'scope': 'base', 'container': key} |
1132 |
module_search_options = {'scope': 'base', 'container': key} |
| 1137 |
try: |
1133 |
try: |
| 1138 |
return read_syntax_choices(syntax_name, {}, module_search_options) |
1134 |
return read_syntax_choices(syn, {}, module_search_options) |
| 1139 |
except udm_errors.base: # TODO: which exception is raised here exactly? |
1135 |
except udm_errors.base: # TODO: which exception is raised here exactly? |
| 1140 |
# invalid DN |
1136 |
# invalid DN |
| 1141 |
return [] |
1137 |
return [] |
|
Lines 1144-1162
def search_syntax_choices_by_key(syntax_name, key):
Link Here
|
| 1144 |
if match: |
1140 |
if match: |
| 1145 |
attr = match.groups()[0] |
1141 |
attr = match.groups()[0] |
| 1146 |
options = {'objectProperty': attr, 'objectPropertyValue': key} |
1142 |
options = {'objectProperty': attr, 'objectPropertyValue': key} |
| 1147 |
return read_syntax_choices(syntax_name, options) |
1143 |
return read_syntax_choices(syn, options) |
| 1148 |
|
1144 |
|
| 1149 |
MODULE.warn('Syntax "%s": No fast search function' % syntax_name) |
1145 |
MODULE.warn('Syntax %r: No fast search function' % syn.name) |
| 1150 |
# return them all, as there is no reason to filter after everything has loaded |
1146 |
# return them all, as there is no reason to filter after everything has loaded |
| 1151 |
# frontend will cache it. |
1147 |
# frontend will cache it. |
| 1152 |
return read_syntax_choices(syntax_name) |
1148 |
return read_syntax_choices(syn) |
| 1153 |
|
|
|
| 1154 |
|
1149 |
|
| 1155 |
def info_syntax_choices(syntax_name, options={}): |
|
|
| 1156 |
syn = _get_syntax(syntax_name) |
| 1157 |
if syn is None: |
| 1158 |
return None |
| 1159 |
|
1150 |
|
|
|
1151 |
def info_syntax_choices(syn, options={}): |
| 1160 |
if issubclass(syn.__class__, udm_syntax.UDM_Objects): |
1152 |
if issubclass(syn.__class__, udm_syntax.UDM_Objects): |
| 1161 |
size = 0 |
1153 |
size = 0 |
| 1162 |
if syn.static_values is not None: |
1154 |
if syn.static_values is not None: |
|
Lines 1176-1185
def info_syntax_choices(syntax_name, options={}):
Link Here
|
| 1176 |
|
1168 |
|
| 1177 |
|
1169 |
|
| 1178 |
@LDAP_Connection |
1170 |
@LDAP_Connection |
| 1179 |
def read_syntax_choices(syntax_name, options={}, module_search_options={}, ldap_connection=None, ldap_position=None): |
1171 |
def read_syntax_choices(syn, options={}, module_search_options={}, ldap_connection=None, ldap_position=None): |
| 1180 |
syn = _get_syntax(syntax_name) |
1172 |
syntax_name = syn.name |
| 1181 |
if syn is None: |
|
|
| 1182 |
return None |
| 1183 |
|
1173 |
|
| 1184 |
if issubclass(syn.__class__, udm_syntax.UDM_Objects): |
1174 |
if issubclass(syn.__class__, udm_syntax.UDM_Objects): |
| 1185 |
syn.choices = [] |
1175 |
syn.choices = [] |
|
Lines 1350-1356
def map_choice(obj):
Link Here
|
| 1350 |
syn.choices.append((dn, dn_list[0].split('=', 1)[1])) |
1340 |
syn.choices.append((dn, dn_list[0].split('=', 1)[1])) |
| 1351 |
elif issubclass(syn.__class__, udm_syntax.LDAP_Search): |
1341 |
elif issubclass(syn.__class__, udm_syntax.LDAP_Search): |
| 1352 |
options = options.get('options', {}) |
1342 |
options = options.get('options', {}) |
| 1353 |
syntax = udm_syntax.LDAP_Search(options['syntax'], options['filter'], options['attributes'], options['base'], options['value'], options['viewonly'], options['empty'], options['empty_end']) |
1343 |
try: |
|
|
1344 |
syntax = udm_syntax.LDAP_Search(options['syntax'], options['filter'], options['attributes'], options['base'], options['value'], options['viewonly'], options['empty'], options['empty_end']) |
| 1345 |
except KeyError: |
| 1346 |
syntax = syn |
| 1354 |
|
1347 |
|
| 1355 |
if '$dn$' in options: |
1348 |
if '$dn$' in options: |
| 1356 |
filter_mod = get_module(None, options['$dn$']) |
1349 |
filter_mod = get_module(None, options['$dn$']) |
|
Lines 1391-1397
def map_choice(obj):
Link Here
|
| 1391 |
id = obj.oldattr[store][0] |
1384 |
id = obj.oldattr[store][0] |
| 1392 |
else: |
1385 |
else: |
| 1393 |
# no valid store object, ignore |
1386 |
# no valid store object, ignore |
| 1394 |
MODULE.warn('LDAP_Search syntax "%s": "%s" is no valid property for object "%s" - ignoring entry.' % (options['syntax'], store, dn)) |
1387 |
MODULE.warn('LDAP_Search syntax %r: %r is no valid property for object %r - ignoring entry.' % (syntax.name, store, dn)) |
| 1395 |
continue |
1388 |
continue |
| 1396 |
|
1389 |
|
| 1397 |
# find the value to display |
1390 |
# find the value to display |