#!/usr/bin/env python
#***************************************************************************
-#* Copyright (C) 2004 polytechnique.org *
+#* Copyright (C) 2004-2009 polytechnique.org *
#* http://opensource.polytechnique.org/ *
#* *
#* This program is free software; you can redistribute it and/or modify *
return config.get(sec, val)[1:-1]
except ConfigParser.NoOptionError, e:
if default is None:
- print e
+ sys.stderr.write('%s\n' % str(e))
sys.exit(1)
else:
return default
PLATAL_DOMAIN = get_config('Mail', 'domain')
PLATAL_DOMAIN2 = get_config('Mail', 'domain2', '')
+sys.stderr.write('PLATAL_DOMAIN = %s\n' % PLATAL_DOMAIN )
VHOST_SEP = get_config('Lists', 'vhost_sep', '_')
ON_CREATE_CMD = get_config('Lists', 'on_create', '')
+SRV_HOST = get_config('Lists', 'rpchost', 'localhost')
+SRV_PORT = int(get_config('Lists', 'rpcport', '4949'))
+
################################################################################
#
# CLASSES
else:
return method(userdesc, perms, vhost, *arg)
except Exception, e:
+ sys.stderr.write('Exception in dispatcher %s\n' % str(e))
raise e
return 0
mlist.Save()
mlist.Unlock()
return ret
- except:
+ except Exception, e:
+ sys.stderr.write('Exception in locked call %s: %s\n' % (method.__name__, str(e)))
mlist.Unlock()
return 0
# TODO: use finally when switching to python 2.5
# helpers on lists
#
-def is_subscription_pending(userdesc, perms, mlist, edit):
+def is_subscription_pending(userdesc, perms, mlist):
for id in mlist.GetSubscriptionIds():
if userdesc.address == mlist.GetRecord(id)[1]:
return True
if mlist.advertised or is_member or is_owner or (not front_page and perms == 'admin'):
is_pending = False
if not is_member and (mlist.subscribe_policy > 1):
- is_pending = list_call_locked(userdesc, perms, mlist, is_subscription_pending, False)
+ is_pending = list_call_locked(is_subscription_pending, userdesc, perms, mlist, False)
if is_pending is 0:
return 0
details = get_list_info(userdesc, perms, mlist)[0]
return (details, options)
-def set_options(userdesc, perms, mlist, vals):
- """ Set the options of a list.
- @mlist
- @edit
- @admin
- """
+def set_options(userdesc, perms, mlist, opts, vals):
for (k, v) in vals.iteritems():
if k not in opts:
continue
try:
details = get_list_info(udesc, perms, mlist, (email is None and vhost == PLATAL_DOMAIN))[0]
result.append(details)
- except:
+ except Exception, e:
+ sys.stderr.write('Can\'t get list %s: %s\n' % (name, str(e)))
continue
return result
"""
members = mlist.getRegularMemberKeys()
added = []
- mlist.Lock()
for user in users:
email, name = to_forlife(user)
if ( email is None ) or ( email in members ):
filterlevel = 3
return (filterlevel << 1) + unsurelevel
-def set_bogo_level(userdesc, perms, vhost, listname, level):
+def set_bogo_level(userdesc, perms, mlist, level):
""" Set filter to the specified level.
@mlist
@edit
if mlist.real_name.lower() != listname:
options['real_name'] = listname, mlist.real_name
if correct: mlist.real_name = listname
- details = get_list_info(userdesc, perms, mlist)[0]
- return (details, options)
+ return 1
def check_options(userdesc, perms, vhost, listname, correct=False):
mlist.header_filter_rules = []
mlist.header_filter_rules.append(('X-Spam-Flag: Unsure, tests=bogofilter', mm_cfg.HOLD, False))
mlist.header_filter_rules.append(('X-Spam-Flag: Yes, tests=bogofilter', mm_cfg.HOLD, False))
- mlist.Save()
- mlist.Unlock()
if ON_CREATE_CMD != '':
try: os.system(ON_CREATE_CMD + ' ' + name)
except: pass
- check_options(userdesc, perms, mlist, True)
+ check_options_runner(userdesc, perms, mlist, listname.lower(), True)
mass_subscribe(userdesc, perms, mlist, members)
-
- # avoid the "-1 mail to moderate" bug
- mlist = MailList.MailList(name)
- mlist._UpdateRecords()
mlist.Save()
-
- return 1
finally:
mlist.Unlock()
- return 0
+
+ # avoid the "-1 mail to moderate" bug
+ mlist = MailList.MailList(name)
+ mlist._UpdateRecords()
+ mlist.Save()
+ return 1
def delete_list(userdesc, perms, mlist, del_archives=0):
""" Delete the list.
#-------------------------------------------------------------------------------
# server
#
-server = FastXMLRPCServer(("localhost", 4949), BasicAuthXMLRPCRequestHandler)
+server = FastXMLRPCServer((SRV_HOST, SRV_PORT), BasicAuthXMLRPCRequestHandler)
# index.php
server.register_function(get_lists)