…f request context.
With flask-debugtoolbar 0.6.x (and perhaps earlier), a DebugPanel instance is created on each request. The flask-mongoengine MongoDebugPanel was patching the jinja environment's loader every time an instance was created. Given enough times, this will cause a RuntimeError with maximum recursion depth being reached. Fix this by only patching the loader once, the first time it's needed.