def _filter(self, environ, params):
<EOL>if self.queries:<EOL><INDENT>if '<STR_LIT>' not in environ:<EOL><INDENT>return False<EOL><DEDENT>available = set(qstr.partition('<STR_LIT:=>')[<NUM_LIT:0>] for qstr in<EOL>environ['<STR_LIT>'].split('<STR_LIT:&>'))<EOL>required = set(self.queries)<EOL>if not required.issubset(available):<EOL><INDENT>return False<EOL><DEDENT><DEDENT>unused = {}<EOL>for key, value in params.items():<EOL><INDENT>if key not in self.use:<EOL><INDENT>unused[key] = value<EOL><DEDENT><DEDENT>for key in unused:<EOL><INDENT>del params[key]<EOL><DEDENT>try:<EOL><INDENT>additional = self.filter(environ, params, unused) or {}<EOL><DEDENT>except DeferLimit:<EOL><INDENT>return False<EOL><DEDENT>key = self.key(params)<EOL>params.update(unused)<EOL>params.update(additional)<EOL>now = time.time()<EOL>self.db.expire(key, <NUM_LIT>)<EOL>update_uuid = str(uuid.uuid4())<EOL>update = {<EOL>'<STR_LIT>': update_uuid,<EOL>'<STR_LIT>': {<EOL>'<STR_LIT>': params,<EOL>'<STR_LIT:time>': now,<EOL>},<EOL>}<EOL>self.db.rpush(key, msgpack.dumps(update))<EOL>records = self.db.lrange(key, <NUM_LIT:0>, -<NUM_LIT:1>)<EOL>loader = BucketLoader(self.bucket_class, self.db, self, key, records)<EOL>if '<STR_LIT>' in environ:<EOL><INDENT>config = environ['<STR_LIT>']['<STR_LIT>']<EOL>try:<EOL><INDENT>max_updates = int(config['<STR_LIT>'])<EOL><DEDENT>except (KeyError, ValueError):<EOL><INDENT>max_updates = None<EOL><DEDENT>try:<EOL><INDENT>max_age = int(config['<STR_LIT>'])<EOL><DEDENT>except (KeyError, ValueError):<EOL><INDENT>max_age = <NUM_LIT><EOL><DEDENT>if max_updates and loader.need_summary(now, max_updates, max_age):<EOL><INDENT>summarize = dict(summarize=now, uuid=str(uuid.uuid4()))<EOL>self.db.rpush(key, msgpack.dumps(summarize))<EOL>compactor_key = config.get('<STR_LIT>', '<STR_LIT>')<EOL>self.db.zadd(compactor_key, int(math.ceil(now)), key)<EOL><DEDENT><DEDENT>self.db.expireat(key, loader.bucket.expire)<EOL>if loader.delay is not None:<EOL><INDENT>environ.setdefault('<STR_LIT>', [])<EOL>environ['<STR_LIT>'].append((loader.delay, self,<EOL>loader.bucket))<EOL><DEDENT>set_name = environ.get('<STR_LIT>')<EOL>if set_name:<EOL><INDENT>self.db.zadd(set_name, loader.bucket.expire, key)<EOL><DEDENT>return not self.continue_scan<EOL>
Performs final filtering of the request to determine if this
limit applies.  Returns False if the limit does not apply or
if the call should not be limited, or True to apply the limit.