commit-gnue
[Top][All Lists]
Advanced

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

r5578 - trunk/gnue-common/src/apps


From: reinhard
Subject: r5578 - trunk/gnue-common/src/apps
Date: Tue, 30 Mar 2004 13:35:55 -0600 (CST)

Author: reinhard
Date: 2004-03-30 13:35:54 -0600 (Tue, 30 Mar 2004)
New Revision: 5578

Modified:
   trunk/gnue-common/src/apps/plugin.py
Log:
Added support for __initplugin__.


Modified: trunk/gnue-common/src/apps/plugin.py
===================================================================
--- trunk/gnue-common/src/apps/plugin.py        2004-03-30 19:25:36 UTC (rev 
5577)
+++ trunk/gnue-common/src/apps/plugin.py        2004-03-30 19:35:54 UTC (rev 
5578)
@@ -38,7 +38,9 @@
 
 Any plugin must immediately check whether it is functional (especially whether
 all dependencies are installed), and import must fail with a meaningful
-exception otherwise.
+exception otherwise.  Optionally, a module can also define a function with the
+name __initplugin__ that initializes the module and raises an exception if the
+plugin cannot be initialized.
 
 Plugins can be organized in a tree structure.  To load a plugin, any point in
 the tree may be specified.  For example, consider there are three plugins named
@@ -201,6 +203,11 @@
 
   if hasattr (m, identifier):
     # This is already a plugin, no need to go deeper
+    if hasattr (m, '__initplugin__'):
+      try:
+        m.__initplugin__ ()
+      except:
+        return {base: sys.exc_info ()}
     return {base: m}
 
   # List all submodules
@@ -227,6 +234,11 @@
 
   if hasattr (m, identifier):
     # This is already a plugin, no need to go deeper
+    if hasattr (m, '__initplugin__'):
+      try:
+        m.__initplugin__ ()
+      except:
+        return {base: sys.exc_info ()}
     return m
 
   # Search all submodules
@@ -289,7 +301,7 @@
         print "ok"
       else:
         list = traceback.format_exception_only (result [0], result [1])
-        print string.join (list, '')
+        print string.join (list, ''),
 
   elif sys.argv [1] == 'test':
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]