Filter entities
        Runs filters on entity properties changing them in place.
        :param model:  object or dict
        :param context: object, dict or None
        :return: None
167495
def filter_entities(self, model, context=None):
        
        if model is None:
            return

        for property_name in self.entities:
            prop = self.entities[property_name]
            value = self.get(model, property_name)

            filtered_value = prop.filter(
                value=value,
                model=model,
                context=context
            )
            if value != filtered_value:  # unless changed!
                self.set(model, property_name, filtered_value)

            prop.filter_with_schema(
                model=value,
                context=context
            )
122923
def filter(self, record):
        """"""
        fmt = LogManager.spec.context_format
        if fmt:
            data = self.context.to_dict()
            if data:
                record.context = fmt % ",".join("%s=%s" % (key, val) for key, val in sorted(data.items()) if key and val)
            else:
                record.context = ""
        return True
592616
def _filter_queryset(self, queryset):
        
        entities = self.request.query_params.getlist('entity')
        labels = self.request.query_params.getlist('label')
        positions = self.request.query_params.getlist('position')

        if labels and len(labels) != len(entities):
            raise exceptions.ParseError(
                'If `labels` query parameter is given, also `entities` '
                'must be given and they must be of the same length.'
            )

        if positions and len(positions) != len(entities):
            raise exceptions.ParseError(
                'If `positions` query parameter is given, also `entities` '
                'must be given and they must be of the same length.'
            )

        if entities:
            for entity, label, position in zip_longest(entities, labels, positions):
                filter_params = {'entities__pk': entity}
                if label:
                    filter_params['relationpartition__label'] = label
                if position:
                    filter_params['relationpartition__position'] = position

                queryset = queryset.filter(**filter_params)

        return queryset
76552
def remove_model(self, model, **kwargs):
        
        kwargs['model'] = model
        kwargs['context'] = 'model'
        self.remove_parameters_all(**kwargs)
1179045
def init_with_context(self, context):
        
        # Apply the include/exclude patterns:
        listitems = self._visible_models(context['request'])

        # Convert to a similar data structure like the dashboard icons have.
        # This allows sorting the items identically.
        models = [
            {'name': model._meta.model_name,
             'app_name': model._meta.app_label,
             'title': capfirst(model._meta.verbose_name_plural),
             'url': self._get_admin_change_url(model, context)
             }
            for model, perms in listitems if self.is_item_visible(model, perms)
        ]

        # Sort models.
        sort_cms_models(models)

        # Convert to items
        for model in models:
            self.children.append(items.MenuItem(title=model['title'], url=model['url']))
1353971
public void addFilterModel(final FilterModel model) {
		if (model.getUrlPatterns() != null) {
			try {
				filterLock.writeLock().lock();
				associateBundle(model.getContextModel().getVirtualHosts(), model.getContextModel().getBundle());
				for (String virtualHost : resolveVirtualHosts(model)) {
					for (String urlPattern : model.getUrlPatterns()) {
							final UrlPattern newUrlPattern = new UrlPattern(getFullPath(model.getContextModel(), urlPattern),
											model);
							String fullPath = getFullPath(model.getContextModel(), urlPattern);
							if (filterUrlPatterns.get(virtualHost) == null) {
								filterUrlPatterns.put(virtualHost, new ConcurrentHashMap<>());
							}
							Set<UrlPattern> urlSet = filterUrlPatterns.get(virtualHost).get(fullPath);
							if (urlSet == null) {
									//initialize first
									urlSet = new HashSet<>();
							}
							urlSet.add(newUrlPattern);
							filterUrlPatterns.get(virtualHost).put(fullPath, urlSet);
    //					final UrlPattern existingPattern = filterUrlPatterns.putIfAbsent(
    //							getFullPath(model.getContextModel(), urlPattern), newUrlPattern);
    //					if (existingPattern != null) {
    //						// this should never happen but is a good assertion
    //						LOG.error("Internal error (please report): Cannot associate url mapping "
    //								+ getFullPath(model.getContextModel(), urlPattern) + " to " + newUrlPattern
    //								+ " because is already associated to " + existingPattern);
    //					}
                                    }
                                }
			} finally {
				filterLock.writeLock().unlock();
			}
		}
	}
141048
public void removeFilterModel(final FilterModel model) {
		if (model.getUrlPatterns() != null) {
			try {
				deassociateBundle(model.getContextModel().getVirtualHosts(), model.getContextModel().getBundle());
				filterLock.writeLock().lock();
				for (String virtualHost:resolveVirtualHosts(model)) {
					for (String urlPattern : model.getUrlPatterns()) {
							String fullPath = getFullPath(model.getContextModel(), urlPattern);
							Set<UrlPattern> urlSet = filterUrlPatterns.get(virtualHost).get(fullPath);
							UrlPattern toDelete = null;
							for (UrlPattern pattern : urlSet) {
									FilterModel filterModel = (FilterModel) pattern.getModel();
									Class<?> filter = filterModel.getFilterClass();
									Class<?> matchFilter = model.getFilterClass();
									if (filter != null && filter.equals(matchFilter)) {
											toDelete = pattern;
											break;
									}
							}
							urlSet.remove(toDelete);
					}
				}
			} finally {
				filterLock.writeLock().unlock();
			}
		}
	}
1162384
def filter(self, value, table=None):
        '''
        
        '''
        if table is not None:
            filterable = self.filterable_func(value, table)
        else:
            filterable = self.filterable_func(value)
        return filterable
247343
def filter(self, **kwargs):
        
        keys = self.filter_keys(**kwargs)
        return self.keys_to_values(keys)
887966
def queryset_from_filter_dict(filter_dict=None, model=None, app=None):
    """"""
    model = model or DEFAULT_MODEL
    app = app or DEFAULT_APP
    model = get_model(model, app)
    
    if filter_dict:
        return model.objects.filter(**filter_dict)
    return model.objects
103697
def filter(self):
        
        argmap = {
            filter.label or label: filter.field
            for label, filter in self.filters.items()
        }
        args = self.opts.parser.parse(argmap)
        query = self.query if self.query is not None else self.opts.query
        for label, filter in self.filters.items():
            value = args.get(filter.label or label)
            if value is not None:
                query = filter.filter(query, self.opts.model, label, value)
        return query
323741
def _handle_filter_sets(self, app):
        
        if 'IMAGINE_FILTER_SETS' in app.config and isinstance(app.config['IMAGINE_FILTER_SETS'], dict):
            for filter_name, filters_settings in app.config['IMAGINE_FILTER_SETS'].items():
                filter_set = []
                if isinstance(filters_settings, dict) and 'filters' in filters_settings:
                    for filter_type, filter_settings in filters_settings['filters'].items():
                        if filter_type in self._filters:
                            filter_item = self._filters[filter_type](**filter_settings)
                            if isinstance(filter_item, ImagineFilterInterface):
                                filter_set.append(filter_item)
                            else:
                                raise ValueError('Filter must be implement ImagineFilterInterface')
                        else:
                            raise ValueError('Unknown filter type: %s' % filter_type)

                    filter_config = {'filters': filter_set}
                    if 'cached' in filters_settings:
                        filter_config['cached'] = filters_settings['cached']
                    else:
                        filter_config['cached'] = app.config['IMAGINE_CACHE_ENABLED']

                    self._filter_sets.update({filter_name: filter_config})
                else:
                    raise ValueError('Wrong settings for filter: %s' % filter_name)
        else:
            raise ValueError('Filters configuration does not present')
707057
@Override
    public boolean updateContext(IQueryContext context) {
        boolean result = false;
        
        for (IQueryFilter<T> filter : filters) {
            result |= filter.updateContext(context);
        }
        
        return result;
    }
1297739
def _apply_cell_filters(self, context):
        
        self.setattrs(_is_unpermitted_fields_set=True)
        for perm, fields in self.Meta.field_permissions.items():
            if not context.has_permission(perm):
                self._unpermitted_fields.extend(fields)
        return self._unpermitted_fields
755085
def filter_objects(self, objects, perm=None):
        
        if perm is None:
            perm = build_permission_name(self.model_class, 'view')
        return filter(lambda o: self.user.has_perm(perm, obj=o), objects)
144380
private void applyFilters(List<TreeModelFilter<SQLPPTriplesMap>> filters) {
		FilteredModel model = (FilteredModel) mappingList.getModel();
		model.removeAllFilters();
		model.addFilters(filters);
	}
1331178
def source_filter(method_name, *args, **kwargs):
    

    def source_filter(value, context, **_params):
        method = getattr(context["model"].source, method_name)
        return _filter(method, value, args, kwargs)

    return source_filter