Author: dmeyer
Date: Thu Mar 20 11:46:27 2008
New Revision: 3208

Log:
Revert kaa.execute back into kaa.InProgress().execute


Modified:
   trunk/base/src/notifier/__init__.py
   trunk/base/src/notifier/async.py
   trunk/beacon/src/db.py
   trunk/popcorn/src/generic.py

Modified: trunk/base/src/notifier/__init__.py
==============================================================================
--- trunk/base/src/notifier/__init__.py (original)
+++ trunk/base/src/notifier/__init__.py Thu Mar 20 11:46:27 2008
@@ -39,8 +39,7 @@
 from signals import Signal, Signals
 
 # InProgress class
-from async import TimeoutException, InProgress, InProgressCallback, 
InProgressSignals, \
-     execute
+from async import TimeoutException, InProgress, InProgressCallback, 
InProgressSignals
 
 # Thread callbacks, helper functions and decorators
 from thread import MainThreadCallback, NamedThreadCallback, ThreadCallback, \

Modified: trunk/base/src/notifier/async.py
==============================================================================
--- trunk/base/src/notifier/async.py    (original)
+++ trunk/base/src/notifier/async.py    Thu Mar 20 11:46:27 2008
@@ -30,7 +30,7 @@
 # -----------------------------------------------------------------------------
 
 __all__ = [ 'TimeoutException', 'InProgress', 'InProgressCallback', 
'InProgressSignals',
-            'execute', 'AsyncException', 'AsyncExceptionBase', 
'make_exception_class' ]
+            'AsyncException', 'AsyncExceptionBase', 'make_exception_class' ]
 
 # python imports
 import sys
@@ -353,6 +353,20 @@
         return async
 
 
+    def execute(self, func, *args, **kwargs):
+        """
+        Execute the given function and return the result or exception in the
+        InProgress object. Returns self as result of the execution.
+        """
+        try:
+            result = func(*args, **kwargs)
+        except:
+            self.throw(*sys.exc_info())
+        else:
+            self.finish(result)
+        return self
+
+    
     def wait(self, timeout = None):
         """
         Waits for the result (or exception) of the InProgress object.  The
@@ -447,21 +461,6 @@
         return self.finish(None)
 
 
-def execute(func, *args, **kwargs):
-    """
-    Execute the given function and return the result or exception in an
-    InProgress object.
-    """
-    async = InProgress()
-    try:
-        result = func(*args, **kwargs)
-    except:
-        async.throw(*sys.exc_info())
-    else:
-        async.finish(result)
-    return async
-
-    
 class InProgressSignals(InProgress):
     """
     InProgress object that will be finished if one of the provided

Modified: trunk/beacon/src/db.py
==============================================================================
--- trunk/beacon/src/db.py      (original)
+++ trunk/beacon/src/db.py      Thu Mar 20 11:46:27 2008
@@ -173,9 +173,9 @@
         # do query based on type
         if 'filename' in query and qlen == 1:
             fname = os.path.realpath(query['filename'])
-            return kaa.execute(self.query_filename, fname)
+            return kaa.InProgress().execute(self.query_filename, fname)
         if 'id' in query and qlen == 1:
-            return kaa.execute(self._db_query_id, query['id'])
+            return kaa.InProgress().execute(self._db_query_id, query['id'])
         if 'parent' in query and 'recursive' in query and qlen == 2:
             if not query['parent']._beacon_isdir:
                 raise AttributeError('parent is no directory')
@@ -186,9 +186,9 @@
                     return self._db_query_dir(query['parent'])
             query['parent'] = query['parent']._beacon_id
         if 'attr' in query:
-            return kaa.execute(self._db_query_attr, query)
+            return kaa.InProgress().execute(self._db_query_attr, query)
         if 'type' in query and query['type'] == 'media':
-            return kaa.execute(self._db.query, **query)
+            return kaa.InProgress().execute(self._db.query, **query)
         return self._db_query_raw(query)
 
 

Modified: trunk/popcorn/src/generic.py
==============================================================================
--- trunk/popcorn/src/generic.py        (original)
+++ trunk/popcorn/src/generic.py        Thu Mar 20 11:46:27 2008
@@ -62,7 +62,7 @@
             # always return an InProgress object
             if self._get_state() in states and not self._pending:
                 # already finished
-                return kaa.execute(func, self, *args, **kwargs)
+                return kaa.InProgress().execute(func, self, *args, **kwargs)
             # add callback to list of pending calls
             async = kaa.InProgress()
             callback = kaa.Callback(func, self, *args, **kwargs)

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to