[kupfer: 38/51] Change Source to have empty repr_key



commit 265429cd82a3c57df2af094fda9a59e4e7617fea
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Sat Jan 9 21:43:00 2010 +0100

    Change Source to have empty repr_key
    
    By default, all instances of a source are the same. Sources must
    override repr_key to differentiate instances.

 kupfer/obj/base.py          |    6 +++---
 kupfer/plugin/core/debug.py |    3 +++
 2 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/kupfer/obj/base.py b/kupfer/obj/base.py
index cd51621..8fc8a84 100644
--- a/kupfer/obj/base.py
+++ b/kupfer/obj/base.py
@@ -276,7 +276,8 @@ class Source (KupferObject, pretty.OutputMixin):
 		return self._version
 
 	def __eq__(self, other):
-		return type(self) == type(other) and repr(self) == repr(other)
+		return (type(self) == type(other) and repr(self) == repr(other) and
+		        self.version == other.version)
 
 	def __hash__(self ):
 		return hash(repr(self))
@@ -295,8 +296,7 @@ class Source (KupferObject, pretty.OutputMixin):
 		pass
 
 	def repr_key(self):
-		# use the source's name so that it is reloaded on locale change
-		return (str(self), self.version)
+		return ""
 
 	def get_items(self):
 		"""
diff --git a/kupfer/plugin/core/debug.py b/kupfer/plugin/core/debug.py
index e09f00b..b5c1c92 100644
--- a/kupfer/plugin/core/debug.py
+++ b/kupfer/plugin/core/debug.py
@@ -217,6 +217,9 @@ class ComposedSource (Source):
 		if self.leaf.object[2] is not None:
 			yield self.leaf.object[2]
 
+	def repr_key(self):
+		return self.leaf.repr_key()
+
 	@classmethod
 	def decorates_type(cls):
 		return ComposedLeaf



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