← Back to team overview

zeitgeist team mailing list archive

[Merge] lp:~seif/zeitgeist/fix-691660 into lp:zeitgeist

 

Seif Lotfy has proposed merging lp:~seif/zeitgeist/fix-691660 into lp:zeitgeist.

Requested reviews:
  Zeitgeist Framework Team (zeitgeist)
Related bugs:
  #691660 Allow Extensions without PUBLIC_METHODS
  https://bugs.launchpad.net/bugs/691660


This allows Extensions to be built without having to have a public method
-- 
https://code.launchpad.net/~seif/zeitgeist/fix-691660/+merge/44116
Your team Zeitgeist Framework Team is requested to review the proposed merge of lp:~seif/zeitgeist/fix-691660 into lp:zeitgeist.
=== modified file '_zeitgeist/engine/extension.py'
--- _zeitgeist/engine/extension.py	2010-10-19 13:54:12 +0000
+++ _zeitgeist/engine/extension.py	2010-12-18 00:11:55 +0000
@@ -44,7 +44,7 @@
 	inserted and retrieved from the log. These hooks can either block the
 	event completely, modify it, or add additional metadata to it.
 	"""
-	PUBLIC_METHODS = None
+	PUBLIC_METHODS = []
 	
 	def __init__(self, engine):
 		self.engine = weakref.proxy(engine)
@@ -238,9 +238,6 @@
 		if not issubclass(extension, Extension):
 			raise TypeError("Unable to load %r, all extensions must be "
 				"subclasses of %r" % (extension, Extension))
-		if getattr(extension, "PUBLIC_METHODS", None) is None:
-			raise ValueError("Unable to load %r, this extension has not "
-				"defined any methods" % extension)
 		try:
 			obj = extension(self.__engine)
 		except Exception:

=== modified file 'test/test-engine-extension.rst'
--- test/test-engine-extension.rst	2010-09-25 13:19:51 +0000
+++ test/test-engine-extension.rst	2010-12-18 00:11:55 +0000
@@ -93,18 +93,6 @@
       ...
     TypeError: Unable to load <type 'set'>, all extensions must be subclasses of <class '...Extension'>
 
-Also, if an extension does not define any public method a ValueErro is raised
-
-    >>> class FailExtension(Extension):
-    ...
-    ...     def get_boo(self):
-    ...         return "boo"
-    ...
-    >>> engine.extensions.load(FailExtension) # doctest:+ELLIPSIS
-    Traceback (most recent call last):
-      ...
-    ValueError: Unable to load <...FailExtension'>, this extension has not defined any methods
-
 At a last step, let's unload all extensions
 
     >>> engine.extensions.unload()