[kupfer] plugin.shorten_links: Use has_result



commit 34c4fa24b48866e248b82ca5ee3cc40f5fd62c43
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Tue Dec 22 00:51:05 2009 +0100

    plugin.shorten_links: Use has_result
    
    Actions with result (has_result) return a single Leaf, while factory
    actions (is_factory) return a whole collection as a Source. We can use
    the result form for the shorten link action

 kupfer/plugin/shorten_links.py |   16 ++++------------
 1 files changed, 4 insertions(+), 12 deletions(-)
---
diff --git a/kupfer/plugin/shorten_links.py b/kupfer/plugin/shorten_links.py
index 06fe890..201d107 100644
--- a/kupfer/plugin/shorten_links.py
+++ b/kupfer/plugin/shorten_links.py
@@ -50,9 +50,12 @@ class ShortenLinks(Action):
 	def __init__(self):
 		Action.__init__(self, _('Shorten Link...'))
 
+	def has_result(self):
+		return True
+
 	def activate(self, leaf, iobj):
 		result = iobj.process(leaf.object)
-		return ShortenLinksSource(UrlLeaf(result, result))
+		return UrlLeaf(result, result)
 
 	def item_types(self):
 		yield UrlLeaf
@@ -66,9 +69,6 @@ class ShortenLinks(Action):
 	def object_source(self, for_item=None):
 		return ServicesSource()
 
-	def is_factory(self):
-		return True
-
 
 class ServicesSource(Source):
 	def __init__(self):
@@ -77,11 +77,3 @@ class ServicesSource(Source):
 	def get_items(self):
 		yield TinyUrl()
 
-
-class ShortenLinksSource(Source):
-	def __init__(self, item):
-		Source.__init__(self, name=_('Shorten links'))
-		self._item = item
-
-	def get_items(self):
-		yield self._item



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