[Mailman-Developers] [Mailman-checkins] SF.net SVN: mailman: [8184] trunk/mailman/Mailman

Tokio Kikuchi tkikuchi at is.kochi-u.ac.jp
Fri Mar 30 13:16:24 CEST 2007


Hi Barry,

bwarsaw at users.sourceforge.net wrote:
> Revision: 8184
>           http://svn.sourceforge.net/mailman/?rev=8184&view=rev
> Author:   bwarsaw
> Date:     2007-03-29 22:09:36 -0700 (Thu, 29 Mar 2007)
> 
> Log Message:
> -----------
> api_lock(): When locking the MailList object, tell the SQLAlchemy session to
> expire the object.  This way, when the MailList attributes are next accessed,
> the ORM will reload them from the database, getting any new values possibly
> set in other processes.
> 
> This works better than trying to use always_refresh=True on the mapper, or
> trying to do a reload() because both of those approaches blow away locks.  I'm
> not sure why this, but I suspect that it's because the identity map is handing
> us back a different object, rather than invalidating the object's attributes.
> 
> Modified Paths:
> --------------
>     trunk/mailman/Mailman/database/dbcontext.py
>     trunk/mailman/Mailman/testing/test_handlers.py
> 
> Modified: trunk/mailman/Mailman/database/dbcontext.py
> ===================================================================
> --- trunk/mailman/Mailman/database/dbcontext.py	2007-03-27 06:35:12 UTC (rev 8183)
> +++ trunk/mailman/Mailman/database/dbcontext.py	2007-03-30 05:09:36 UTC (rev 8184)
> @@ -129,6 +129,7 @@
>  
>      # 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
> 

Wow!  Fix is so simple.

I've done a test with this using two terminals:

terminal A                         terminal B

$ bin/withlist test                $ bin/withlist test
 >>> m.description
u''
 >>> m.Lock()
 >>> m.description = 'test'
 >>> m.Save()
                                    >>> m.Load()
                                    >>> m.description
                                    u''
 >>> m.Unlock()
                                    >>> m.Lock()
                                    >>> m.description
                                    u'test'

Mere Load() can't refresh the list attributes but needs Lock() to get 
them.  A few problem remains like decorating the message where 
OutgoingRunner is used.  This runner don't update the database so it 
doesn't use Lock() but only Load().  We should fix them to use Lock() 
(and Unlock()) to reload data.


-- 
Tokio Kikuchi, tkikuchi at is.kochi-u.ac.jp
http://weather.is.kochi-u.ac.jp/


More information about the Mailman-Developers mailing list