Beispiel #1
0
		def map_choices( obj_list ):
			result = []
			for obj in obj_list:
				obj.open()

				if syn.key == 'dn':
					key = obj.dn
				else:
					try:
						key = syn.key % obj.info
					except KeyError:
						# ignore the entry as the key is important for a selection, there
						# is no sensible fallback for the key (Bug #26994)
						continue
				if syn.label is None:
					label = udm_objects.description( obj )
				elif syn.label == 'dn':
					label = obj.dn
				else:
					try:
						label = syn.label % obj.info
					except KeyError:
						# fallback to the default description as this is just what displayed
						# to the user (Bug #26994)
						label = udm_objects.description( obj )

				result.append( (key, label) )
			return result
	def obj_description(self, obj):
		description = None
		description_property_name = ucr.get('directory/manager/web/modules/%s/display' % self.name)
		if description_property_name:
			description = self.property_description(obj, description_property_name)
		if not description:
			description = udm_objects.description(obj)
		if description and description.isdigit():
			description = int(description)
		return description
Beispiel #3
0
		def _thread( container ):
			entries = []
			for module, obj in list_objects( container, object_type = object_type ):
				if obj is None:
					continue
				if object_type != '$containers$' and module.childs:
					continue
				if object_type == '$containers$' and not module.childs:
					continue
				entries.append( { '$dn$' : obj.dn,
								  '$childs$' : module.childs,
								  'objectType' : module.name,
								  'labelObjectType' : module.subtitle,
								  'name' : udm_objects.description(obj),
								  'path' : ldap_dn2path( obj.dn, include_rdn = False ) } )

			return entries
			def map_choices(obj_list):
				result = []
				for obj in obj_list:
					# first try it without obj.open() (expensive)
					key, label = extract_key_label(syn, obj.dn, obj.info)
					if key is None or label is None:
						obj.open()
						key, label = extract_key_label(syn, obj.dn, obj.info)
						if key is None:
							# ignore the entry as the key is important for a selection, there
							# is no sensible fallback for the key (Bug #26994)
							continue
						if label is None:
							# fallback to the default description as this is just what displayed
							# to the user (Bug #26994)
							label = udm_objects.description(obj)
					result.append((key, label))
				return result
Beispiel #5
0
		def _thread(container):
			entries = []
			for module, obj in list_objects(container, object_type=object_type):
				if obj is None:
					continue
				if object_type != '$containers$' and module.childs:
					continue
				if object_type == '$containers$' and not module.childs:
					continue
				entries.append({
					'$dn$': obj.dn,
					'$childs$': module.childs,
					'objectType': module.name,
					'labelObjectType': module.subtitle,
					'name': udm_objects.description(obj),
					'path': ldap_dn2path(obj.dn, include_rdn=False),
					'$flags$': obj.oldattr.get('univentionObjectFlag', []),
					'$operations$': module.operations,
				})

			return entries
Beispiel #6
0
		def _thread( request ):
			module = self._get_module_by_request( request )

			superordinate = request.options.get( 'superordinate' )
			if superordinate == 'None':
				superordinate = None
			elif superordinate is not None:
				MODULE.info( 'Query defines a superordinate %s' % superordinate )
				mod = get_module( request.flavor, superordinate )
				if mod is not None:
					MODULE.info( 'Found UDM module for superordinate' )
					superordinate = mod.get( superordinate )
					request.options[ 'container' ] = superordinate.dn
				else:
					raise UMC_OptionTypeError( _( 'Could not find an UDM module for the superordinate object %s' ) % superordinate )

			result = module.search( request.options.get( 'container' ), request.options[ 'objectProperty' ], request.options[ 'objectPropertyValue' ], superordinate, scope = request.options.get( 'scope', 'sub' ) )

			entries = []
			object_type = request.options.get( 'objectType', request.flavor )
			for obj in result:
				if obj is None:
					continue
				module = get_module( object_type, obj.dn )
				if module.module is None:
					MODULE.warn( 'Could not identify LDAP object %s (flavor: %s). The object is ignored.' % ( obj.dn, request.flavor ) )
					continue
				entry = {
					'$dn$' : obj.dn,
					'$childs$' : module.childs,
					'objectType' : module.name,
					'labelObjectType' : module.subtitle,
					'name' : udm_objects.description( obj ),
					'path' : ldap_dn2path( obj.dn, include_rdn = False )
					}
				if request.options[ 'objectProperty' ] not in ( 'name', 'None' ):
					entry[ request.options[ 'objectProperty' ] ] = obj[ request.options[ 'objectProperty' ] ]
				entries.append( entry )
			return entries