withlist locks with -l and -a switches

Bug #266276 reported by Adrianwi
2
Affects Status Importance Assigned to Milestone
GNU Mailman
New
Medium
Unassigned

Bug Description

The following is from
<http://www.mail-archive.com/mailman-users%40python.org/msg34340.html>

Thanks to Mark for the reply and explaniation. This
probably belongs in both the command line scripts and
documentation category.

>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

[http://sourceforge.net/tracker/index.php?func=detail&aid=1298841&group_id=103&atid=100103]

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.