[Twisted-Python] Reflector init patch (repost)

Jonathan Lange jml at mumak.net
Mon Nov 4 04:20:44 EST 2002


On Thu, Oct 31, 2002 at 11:33:01AM +1100, Jonathan M. Lange wrote:

With reference to twisted.enterprise.reflector not making a Deferred available 
on construction, despite it being an asynchronous operation...

> Suggestions include having a populatedDeferred as a member (rather than
> populatedCallback)

I've been having troubles with my mail recently. In case this did not come 
through, here is the patch again.

Comments appreciated. Commits even more so.

Index: twisted/enterprise/reflector.py
===================================================================
RCS file: /cvs/Twisted/twisted/enterprise/reflector.py,v
retrieving revision 1.9
diff -u -r1.9 reflector.py
--- twisted/enterprise/reflector.py     16 Oct 2002 04:27:29 -0000      1.9
+++ twisted/enterprise/reflector.py     31 Oct 2002 00:57:59 -0000
@@ -20,6 +20,7 @@
 from twisted.enterprise import adbapi
 from twisted.enterprise.util import DBError, getKeyColumn, quote, _TableInfo, 
_TableRelationship
 from twisted.enterprise.row import RowObject
+from twisted.internet import defer
 
 class Reflector:
     """Base class for enterprise reflectors. This implements rowCacheing.
@@ -61,6 +62,7 @@
         
         from twisted.internet import reactor
         reactor.callLater(0, self._really_populate)
+        self.populatedDeferred = defer.Deferred()
 
     def _really_populate(self):
         """Implement me to populate schema information for the reflector.
Index: twisted/enterprise/sqlreflector.py
===================================================================
RCS file: /cvs/Twisted/twisted/enterprise/sqlreflector.py,v
retrieving revision 1.10
diff -u -r1.10 sqlreflector.py
--- twisted/enterprise/sqlreflector.py  14 Oct 2002 22:34:21 -0000      1.10
+++ twisted/enterprise/sqlreflector.py  31 Oct 2002 00:58:00 -0000
@@ -49,6 +49,7 @@
         defe = self.runInteraction(self._transPopulateSchema)
         if self.populatedCallback:
             defe.addCallbacks(self.populatedCallback)
+        defe.chainDeferred(self.populatedDeferred)
 
     def _transPopulateSchema(self, transaction):
         """Used to construct the row classes in a single interaction.





More information about the Twisted-Python mailing list