Anonymous committed 699b067

Provide a more generic and tweak'able filter function.

Comments (0)

Files changed (1)


                        asynchronous, each ajax request waits for the previous to
                        end, which is a bit easier for the browser. Pass it
                        True or False. (Default: False)
-    :param count_self: When set to `True` it will also count objects from the
-                       flickzeug package. (Default: False).
+    :param filter: A callable which takes a single argument, a type name.
     def __init__(self, app, app_path='/_leakfinder', period=5, maxhistory=300,
-                 async_ajax=False, count_self=False):
+                 async_ajax=False, filter=None):
         WebMiddleware.__init__(self, app, app_path)
         self.period = period
         self.maxhistory = maxhistory
         self.async_ajax = async_ajax
-        self.count_self = count_self
+        self.filter = filter
         self.running = False
         self.history = {}
         self.samples = 0
         for objtype, count in typecounts.iteritems():
             typename = objtype.__module__ + "." + objtype.__name__
             if typename not in self.history:
-                if not self.count_self and typename.startswith('flickzeug'):
+                if self.filter and self.filter(typename):
                 self.history[typename] = [0] * self.samples