Package biblio :: Package webquery :: Module querythrottle :: Class AbsoluteNumberThrottle
[hide private]
[frames] | no frames]

Class AbsoluteNumberThrottle

source code

   object --+        
            |        
 impl.ReprObj --+    
                |    
BaseQueryThrottle --+
                    |
                   AbsoluteNumberThrottle

Limit a query to a maximum number.

Many web-services have a per-day query limit (e.g. 500 per day for ISBNdb). It is difficult to implement this across multiple invocations of the query objects and Python interpreter, but this can serve as a crude implementation. By default, it raises an exception if the limit is reached.

Instance Methods [hide private]
 
__init__(self, max, fail_action='RAISE')
C'tor, allowing the maximum queries and failure behaviour to be set.
source code
 
within_limit(self, wquery)
Have fewer queries been posted than the limit?
source code
 
log_success(self, wquery)
Sucessful queries will probably effect the success of future ones, so here is a place to log them.
source code

Inherited from BaseQueryThrottle: check_limit

Inherited from impl.ReprObj: __repr__, __str__, __unicode__

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__

Class Variables [hide private]

Inherited from BaseQueryThrottle (private): _repr_fields

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, max, fail_action='RAISE')
(Constructor)

source code 
C'tor, allowing the maximum queries and failure behaviour to be set.
Parameters:
  • max (int) - The total number of queries allowed.
  • fail_action - See BaseQueryThrottle.
Overrides: object.__init__

within_limit(self, wquery)

source code 

Have fewer queries been posted than the limit?

Note that if multiple queries simulatanoeusly test via this function, exceeding the limit is possible.

Parameters:
Overrides: BaseQueryThrottle.within_limit

log_success(self, wquery)

source code 
Sucessful queries will probably effect the success of future ones, so here is a place to log them.
Overrides: BaseQueryThrottle.log_success
(inherited documentation)