Revision: 8186
          http://svn.sourceforge.net/mailman/?rev=8186&view=rev
Author:   bwarsaw
Date:     2007-04-02 19:03:18 -0700 (Mon, 02 Apr 2007)

Log Message:
-----------
Moved the session.expire() to the MailList.Load() method, via
DBContext.api_load().  This is where it really ought to be based on the
internal semantics of .Load()/.Lock().

MailListMapperExtension.populate_instance(): Checking the state of the isnew
flag is not sufficient to know whether the MailList object we're getting is
brand spankin' new or not.  It turns out that when we session.expire() the
MailList object, the next time SA loads this from the db, the
populate_instance() will get called with isnew=True, even though the object
really isn't new.  Instead, check to make sure InitTempVars() isn't
incorrectly called twice.  Note that I might move this test, but I wanted to
check in something that works, and then see if this is what we expect from the
SA guys (this flag appears underdocumented).

LockFile.py: Add some additional debugging.

Modified Paths:
--------------
    trunk/mailman/Mailman/LockFile.py
    trunk/mailman/Mailman/MailList.py
    trunk/mailman/Mailman/database/dbcontext.py
    trunk/mailman/Mailman/database/listdata.py

Modified: trunk/mailman/Mailman/LockFile.py
===================================================================
--- trunk/mailman/Mailman/LockFile.py   2007-03-31 23:56:58 UTC (rev 8185)
+++ trunk/mailman/Mailman/LockFile.py   2007-04-03 02:03:18 UTC (rev 8186)
@@ -313,10 +313,12 @@
         return self._read() == self._tmpfname
 
     def finalize(self):
+        log.debug('finalize')
         self.unlock(unconditionally=True)
 
     # XXX Can we just get rid of __del__()?
     def __del__(self):
+        log.debug('__del__')
         if self._owned:
             self.finalize()
 

Modified: trunk/mailman/Mailman/MailList.py
===================================================================
--- trunk/mailman/Mailman/MailList.py   2007-03-31 23:56:58 UTC (rev 8185)
+++ trunk/mailman/Mailman/MailList.py   2007-04-03 02:03:18 UTC (rev 8186)
@@ -586,6 +586,7 @@
             fqdn_listname = self.fqdn_listname
         if not Utils.list_exists(fqdn_listname):
             raise Errors.MMUnknownListError(fqdn_listname)
+        database.load(self)
         self._memberadaptor.load()
         if check_version:
             # XXX for now disable version checks.  We'll fold this into schema

Modified: trunk/mailman/Mailman/database/dbcontext.py
===================================================================
--- trunk/mailman/Mailman/database/dbcontext.py 2007-03-31 23:56:58 UTC (rev 
8185)
+++ trunk/mailman/Mailman/database/dbcontext.py 2007-04-03 02:03:18 UTC (rev 
8186)
@@ -129,7 +129,6 @@
 
     # Higher level interface
     def api_lock(self, mlist):
-        self.session.expire(mlist)
         # Don't try to re-lock a list
         if mlist.fqdn_listname in self._mlist_txns:
             return
@@ -152,6 +151,11 @@
             txn.rollback()
         del mlist._txnkey
 
+    def api_load(self, mlist):
+        # Mark the MailList object such that future attribute accesses will
+        # refresh from the database.
+        self.session.expire(mlist)
+
     def api_save(self, mlist):
         # When dealing with MailLists, .Save() will always be followed by
         # .Unlock().  However lists can also be unlocked without saving.  But

Modified: trunk/mailman/Mailman/database/listdata.py
===================================================================
--- trunk/mailman/Mailman/database/listdata.py  2007-03-31 23:56:58 UTC (rev 
8185)
+++ trunk/mailman/Mailman/database/listdata.py  2007-04-03 02:03:18 UTC (rev 
8186)
@@ -173,7 +173,13 @@
 
 class MailListMapperExtension(MapperExtension):
     def populate_instance(self, mapper, context, row, mlist, ikey, isnew):
-        if isnew:
+        # isnew doesn't really seem to give us what we want.  Specifically, if
+        # we expire the MailList object from the session, we'll get called
+        # with populate_instance(..., isnew=True) when the object is reloaded
+        # from the database.  We'll still check isnew, but we'll also check to
+        # make sure there's no _memberadaptor attribute, since that is set in
+        # the InitTempVars() method.
+        if isnew and not hasattr(mlist, '_memberadaptor'):
             # Get the list name and host name -- which are required by
             # InitTempVars() from the row data.
             list_name = row['listdata_list_name']


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to