Package s3 :: Module s3resource :: Class S3ResourceFilter
[frames] | no frames]

Class S3ResourceFilter

source code

object --+
         |
        S3ResourceFilter

Class representing a resource filter

Instance Methods
 
__init__(self, resource, id=None, uid=None, filter=None, vars=None, extra_filters=None, filter_component=None)
Constructor
source code
 
extra_filter_methods(self)
Getter for extra filter methods, lazy property so methods are only imported/initialized when needed
source code
 
add_filter(self, query, component=None, master=True)
Extend this filter
source code
 
add_extra_filter(self, method, expression)
Add an extra filter
source code
 
set_extra_filters(self, filters)
Replace the current extra filters
source code
 
get_query(self)
Get the effective DAL query
source code
 
get_filter(self)
Get the effective virtual filter
source code
 
get_extra_filters(self)
Get the list of extra filters
source code
 
get_joins(self, left=False, as_list=True)
Get the joins required for this filter
source code
 
get_fields(self)
Get all field selectors in this filter
source code
 
__call__(self, rows, start=None, limit=None)
Filter a set of rows by the effective virtual filter
source code
 
apply_extra_filters(self, ids, start=None, limit=None)
Apply all extra filters on a list of record ids
source code
 
count(self, left=None, distinct=False)
Get the total number of matching records
source code
 
__repr__(self)
String representation of the instance
source code
 
serialize_url(self)
Serialize this filter as URL query
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__, __subclasshook__

Static Methods
 
parse_bbox_query(resource, get_vars)
Generate a Query from a URL boundary box query; supports multiple bboxes, but optimised for the usual case of just 1
source code
Properties

Inherited from object: __class__

Method Details

__init__(self, resource, id=None, uid=None, filter=None, vars=None, extra_filters=None, filter_component=None)
(Constructor)

source code 

Constructor

Parameters:
  • resource - the S3Resource
  • id - the record ID (or list of record IDs)
  • uid - the record UID (or list of record UIDs)
  • filter - a filter query (S3ResourceQuery or Query)
  • vars - the dict of GET vars (URL filters)
  • extra_filters - extra filters (to be applied on pre-filtered subsets), as list of tuples (method, expression)
  • filter_component - the alias of the component the URL filters apply for (filters for this component must be handled separately)
Overrides: object.__init__

extra_filter_methods(self)

source code 

Getter for extra filter methods, lazy property so methods are only imported/initialized when needed

Returns:
dict {name: callable} of known named filter methods
Decorators:
  • @property

To Do: document the expected signature of filter methods

add_filter(self, query, component=None, master=True)

source code 

Extend this filter

Parameters:
  • query - a Query or S3ResourceQuery object
  • component - alias of the component the filter shall be added to (None for master)
  • master - False to filter only component

add_extra_filter(self, method, expression)

source code 

Add an extra filter

Parameters:
  • method - a name of a known filter method, or a callable filter method
  • expression - the filter expression (string)

set_extra_filters(self, filters)

source code 

Replace the current extra filters

Parameters:
  • filters - list of tuples (method, expression), or None to remove all extra filters

get_query(self)

source code 

Get the effective DAL query

get_filter(self)

source code 

Get the effective virtual filter

get_extra_filters(self)

source code 

Get the list of extra filters

Returns:
list of tuples (method, expression)

get_joins(self, left=False, as_list=True)

source code 

Get the joins required for this filter

Parameters:
  • left - get the left joins
  • as_list - return a flat list rather than a nested dict

get_fields(self)

source code 

Get all field selectors in this filter

__call__(self, rows, start=None, limit=None)
(Call operator)

source code 

Filter a set of rows by the effective virtual filter

Parameters:
  • rows - a Rows object
  • start - index of the first matching record to select
  • limit - maximum number of records to select

apply_extra_filters(self, ids, start=None, limit=None)

source code 

Apply all extra filters on a list of record ids

Parameters:
  • ids - the pre-filtered set of record IDs
  • limit - the maximum number of matching IDs to establish, None to find all matching IDs
Returns:
a sequence of matching IDs

count(self, left=None, distinct=False)

source code 

Get the total number of matching records

Parameters:
  • left - left outer joins
  • distinct - count only distinct rows

__repr__(self)
(Representation operator)

source code 

String representation of the instance

Overrides: object.__repr__

parse_bbox_query(resource, get_vars)
Static Method

source code 

Generate a Query from a URL boundary box query; supports multiple bboxes, but optimised for the usual case of just 1

Parameters:
  • resource - the resource
  • get_vars - the URL GET vars

serialize_url(self)

source code 

Serialize this filter as URL query

Returns:
a Storage of URL GET variables