MCPcopy
hub / github.com/pallets/werkzeug / DebuggedApplication

Class DebuggedApplication

src/werkzeug/debug/__init__.py:229–574  ·  view source on GitHub ↗

Enables debugging support for a given application:: from werkzeug.debug import DebuggedApplication from myapp import app app = DebuggedApplication(app, evalex=True) The ``evalex`` argument allows evaluating expressions in any frame of a traceback. This works by pres

Source from the content-addressed store, hash-verified

227
228
229class DebuggedApplication:
230 """Enables debugging support for a given application::
231
232 from werkzeug.debug import DebuggedApplication
233 from myapp import app
234 app = DebuggedApplication(app, evalex=True)
235
236 The ``evalex`` argument allows evaluating expressions in any frame
237 of a traceback. This works by preserving each frame with its local
238 state. Some state, such as context globals, cannot be restored with
239 the frame by default. When ``evalex`` is enabled,
240 ``environ["werkzeug.debug.preserve_context"]`` will be a callable
241 that takes a context manager, and can be called multiple times.
242 Each context manager will be entered before evaluating code in the
243 frame, then exited again, so they can perform setup and cleanup for
244 each call.
245
246 :param app: the WSGI application to run debugged.
247 :param evalex: enable exception evaluation feature (interactive
248 debugging). This requires a non-forking server.
249 :param request_key: The key that points to the request object in this
250 environment. This parameter is ignored in current
251 versions.
252 :param console_path: the URL for a general purpose console.
253 :param console_init_func: the function that is executed before starting
254 the general purpose console. The return value
255 is used as initial namespace.
256 :param show_hidden_frames: by default hidden traceback frames are skipped.
257 You can show them by setting this parameter
258 to `True`.
259 :param pin_security: can be used to disable the pin based security system.
260 :param pin_logging: enables the logging of the pin system.
261
262 .. versionchanged:: 2.2
263 Added the ``werkzeug.debug.preserve_context`` environ key.
264 """
265
266 _pin: str | None
267 _pin_cookie: str
268
269 def __init__(
270 self,
271 app: WSGIApplication,
272 evalex: bool = False,
273 request_key: str = "werkzeug.request",
274 console_path: str = "/console",
275 console_init_func: t.Callable[[], dict[str, t.Any]] | None = None,
276 show_hidden_frames: bool = False,
277 pin_security: bool = True,
278 pin_logging: bool = True,
279 ) -> None:
280 if not console_init_func:
281 console_init_func = None
282 self.app = app
283 self.evalex = evalex
284 self.frames: dict[int, DebugFrameSummary | _ConsoleFrame] = {}
285 self.frame_contexts: dict[int, list[t.ContextManager[None]]] = {}
286 self.request_key = request_key

Calls

no outgoing calls