From 424d7e267b009cc19b8503eadab782736d9597d0 Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Tue, 30 Mar 2010 20:06:07 -0700 Subject: Consolidate the exec/eval bits, switch anonfunc to better_exec, etc The methodpool, ${@} expansions, anonymous python functions, event handlers now all run with the same global context, ensuring a consistent environment for them. Added a bb.utils.better_eval function which does an eval() with the same globals as better_exec. Signed-off-by: Chris Larson --- lib/bb/event.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/bb/event.py') diff --git a/lib/bb/event.py b/lib/bb/event.py index afd5bf57c..8559858f0 100644 --- a/lib/bb/event.py +++ b/lib/bb/event.py @@ -48,13 +48,18 @@ _handlers = {} _ui_handlers = {} _ui_handler_seq = 0 +# For compatibility +bb.utils._context["NotHandled"] = NotHandled +bb.utils._context["Handled"] = Handled + def fire_class_handlers(event, d): for handler in _handlers: h = _handlers[handler] event.data = d if type(h).__name__ == "code": - exec(h) - tmpHandler(event) + locals = {"e": event} + exec h in bb.utils._context, locals + bb.utils.better_eval("tmpHandler(e)", locals) else: h(event) del event.data -- cgit 1.2.3-korg