[kupfer: 15/53] higherorder: Port to wants_context partially



commit 7d615003959a20082c790b682fa319a92d2bf6c1
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Thu Mar 24 17:22:34 2011 +0100

    higherorder: Port to wants_context partially
    
    A full port is not possible at this point. We cannot use (Take Result)
    on actions that want context. At the moment, it's hardly relevant
    anyway.

 kupfer/plugin/higherorder.py |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/kupfer/plugin/higherorder.py b/kupfer/plugin/higherorder.py
index 9d25616..bc22c25 100644
--- a/kupfer/plugin/higherorder.py
+++ b/kupfer/plugin/higherorder.py
@@ -29,7 +29,7 @@ class Select (Action):
 def _exec_no_show_result(composedleaf):
 	pretty.print_debug(__name__, "Evaluating command", composedleaf)
 	obj, action, iobj = composedleaf.object
-	ret = commandexec.activate_action(*composedleaf.object)
+	ret = commandexec.activate_action(None, *composedleaf.object)
 	result_type = commandexec.parse_action_result(action, ret)
 	if result_type == commandexec.RESULT_OBJECT:
 		return ret
@@ -83,7 +83,9 @@ class TakeResult (Action):
 		yield ComposedLeaf
 	def valid_for_item(self, leaf):
 		action = leaf.object[1]
-		return action.has_result() or action.is_factory()
+		return ((action.has_result() or
+		         action.is_factory()) and
+		         not action.wants_context())
 	def get_description(self):
 		return _("Take the command result as a proxy object")
 
@@ -92,8 +94,11 @@ class DiscardResult (Action):
 	def __init__(self):
 		Action.__init__(self, _("Run (Discard Result)"))
 
-	def activate(self, leaf):
-		commandexec.activate_action(*leaf.object)
+	def wants_context(self):
+		return True
+
+	def activate(self, leaf, ctx):
+		commandexec.activate_action(ctx, *leaf.object)
 	def item_types(self):
 		yield ComposedLeaf
 	def valid_for_item(self, leaf):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]