[kupfer: 3/31] Add Source.initialize



commit ed7157b5b57d78418805f97eb5cb4a184a78d2f2
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Wed Dec 30 03:14:26 2009 +0100

    Add Source.initialize

 kupfer/data.py    |    2 ++
 kupfer/objects.py |   10 ++++++++++
 2 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/data.py b/kupfer/data.py
index 73e61b3..d20db77 100644
--- a/kupfer/data.py
+++ b/kupfer/data.py
@@ -467,6 +467,8 @@ class SourceController (pretty.OutputMixin):
 
 	def cache_toplevel_sources(self):
 		"""Ensure that all toplevel sources are cached"""
+		for src in set(self.sources):
+			src.initialize()
 		for src in set(self.toplevel_sources):
 			self._checked_rescan_source(src, force=False)
 
diff --git a/kupfer/objects.py b/kupfer/objects.py
index d4f19ca..d03c80f 100644
--- a/kupfer/objects.py
+++ b/kupfer/objects.py
@@ -728,6 +728,16 @@ class Source (KupferObject, pretty.OutputMixin):
 	def __hash__(self ):
 		return hash(repr(self))
 
+	def initialize(self):
+		"""
+		Called when a Source enters Kupfer's system for real
+
+		This method is called at least once for any "real" Source. A Source
+		must be able to return an icon name for get_icon_name as well as a
+		description for get_description, even if this method was never called.
+		"""
+		pass
+
 	def repr_key(self):
 		# use the source's name so that it is reloaded on locale change
 		return (str(self), self.version)



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