Hi Barry,

[EMAIL PROTECTED] 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, [EMAIL PROTECTED]
http://weather.is.kochi-u.ac.jp/
_______________________________________________
Mailman-Developers mailing list
[email protected]
http://mail.python.org/mailman/listinfo/mailman-developers
Mailman FAQ: http://www.python.org/cgi-bin/faqw-mm.py
Searchable Archives: 
http://www.mail-archive.com/mailman-developers%40python.org/
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-developers/archive%40jab.org

Security Policy: 
http://www.python.org/cgi-bin/faqw-mm.py?req=show&file=faq01.027.htp

Reply via email to