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 <[EMAIL PROTECTED]>       The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan

------------------------------------------------------
Mailman-Users mailing list
Mailman-Users@python.org
http://mail.python.org/mailman/listinfo/mailman-users
Mailman FAQ: http://www.python.org/cgi-bin/faqw-mm.py
Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/
Unsubscribe: 
http://mail.python.org/mailman/options/mailman-users/archive%40jab.org

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

Reply via email to