Skip to content

Commit 23508d6

Browse files
committed
Improve global_options function in options.py with better error handling and code clarity
1 parent 1480bca commit 23508d6

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

Mailman/Cgi/options.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,12 +1202,14 @@ def sigterm_handler(signum, frame, mlist=mlist):
12021202

12031203
def global_options(mlist, user, globalopts):
12041204
# Is there anything to do?
1205+
has_changes = False
12051206
for attr in dir(globalopts):
12061207
if attr.startswith('_'):
12071208
continue
12081209
if getattr(globalopts, attr) is not None:
1210+
has_changes = True
12091211
break
1210-
else:
1212+
if not has_changes:
12111213
return
12121214

12131215
def sigterm_handler(signum, frame, mlist=mlist):
@@ -1226,18 +1228,15 @@ def sigterm_handler(signum, frame, mlist=mlist):
12261228

12271229
if globalopts.enable is not None:
12281230
mlist.setDeliveryStatus(user, globalopts.enable)
1229-
12301231
if globalopts.remind is not None:
12311232
mlist.setMemberOption(user, mm_cfg.SuppressPasswordReminder,
1232-
globalopts.remind)
1233-
1233+
globalopts.remind)
12341234
if globalopts.nodupes is not None:
12351235
mlist.setMemberOption(user, mm_cfg.DontReceiveDuplicates,
1236-
globalopts.nodupes)
1237-
1236+
globalopts.nodupes)
12381237
if globalopts.mime is not None:
1239-
mlist.setMemberOption(user, mm_cfg.DisableMime, globalopts.mime)
1240-
1238+
mlist.setMemberOption(user, mm_cfg.DisableMime,
1239+
globalopts.mime)
12411240
mlist.Save()
12421241
finally:
12431242
mlist.Unlock()

0 commit comments

Comments
 (0)