[Mailman-Users] Lock files and withlist?

Mark Sapiro msapiro at value.net
Fri Sep 16 20:59:01 CEST 2005


Adrian Wells wrote
>
>customchange.py is located at the root installation directory of Mailman. 
>It contains:
>
># Python function to make custom changes
>def customchange(m):
>    curlist = m.real_name
>    curlist = curlist.lower()
>    print 'Current list is: ' + curlist
>    if curlist.startswith('apples'):
>         print 'Starts with apples!  Current host_name is: ' + m.host_name
>         print 'Changing hostname now...'
>         m.host_name = 'lists.newlistname.org'
>         m.Save()
>
>
>This script is then run with withlist:
>
>./withlist -a -l -r customchange
>
>
>After preforming this, I noticed that the web interface for lists are not
>accessible and that the locks directory contains at least two lock files
>for every list.

This probably should be considered a bug in withlist or at least a
documentation deficiency. The problem is when running withlist with -l
and -a switches, only the last list is unlocked by withlist. Thus you
need to unlock the lists in your script. In your example you could do
this two ways

1) make sure you unlock every list, processed or not.

# Python function to make custom changes
def customchange(m):
    curlist = m.real_name
    curlist = curlist.lower()
    print 'Current list is: ' + curlist
    if curlist.startswith('apples'):
         print 'Starts with apples!  Current host_name is: ' +
m.host_name
         print 'Changing hostname now...'
         m.host_name = 'lists.newlistname.org'
         m.Save()
    m.Unlock()


2) run withlist with -a but without -l and only lock the lists you're
changing.

# Python function to make custom changes
def customchange(m):
    curlist = m.real_name
    curlist = curlist.lower()
    print 'Current list is: ' + curlist
    if curlist.startswith('apples'):
         m.Lock()
         print 'Starts with apples!  Current host_name is: ' +
m.host_name
         print 'Changing hostname now...'
         m.host_name = 'lists.newlistname.org'
         m.Save()
         m.Unlock()

3) Safer still is like 2) with the addition of try: finally:

# Python function to make custom changes
def customchange(m):
    curlist = m.real_name
    curlist = curlist.lower()
    print 'Current list is: ' + curlist
    if curlist.startswith('apples'):
       try:
          m.Lock()
          print 'Starts with apples!  Current host_name is: ' +
m.host_name
          print 'Changing hostname now...'
          m.host_name = 'lists.newlistname.org'
          m.Save()
       finally:
          m.Unlock()

--
Mark Sapiro <msapiro at value.net>       The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan




More information about the Mailman-Users mailing list