Author: robin.munn
Date: Mon Mar 21 17:39:05 2005
New Revision: 57
Modified:
trunk/mailman/src/mailman/database/schema.py
trunk/mailman/src/mailman/database/tests/test_attribute.py
Log:
Gracefully handle the situation where a mailing list's override group
is missing. This can happen, for instance, if someone has been poking
around in the database and deleted the wrong AttributeGroup.
Modified: trunk/mailman/src/mailman/database/schema.py
==============================================================================
--- trunk/mailman/src/mailman/database/schema.py (original)
+++ trunk/mailman/src/mailman/database/schema.py Mon Mar 21 17:39:05 2005
@@ -88,7 +88,10 @@
appropriate type.
"""
result = None
- overrides = AttributeGroup.byCollection_name(self.name)
+ try:
+ overrides = AttributeGroup.byCollection_name(self.name)
+ except SQLObjectNotFound:
+ overrides = None
if overrides is not None:
for value in overrides.values:
if attribute_name.lower() == value.name.lower():
@@ -107,7 +110,10 @@
"""
result = self.list_style.get_attributes()
# Then set overrides
- overrides = AttributeGroup.byCollection_name(self.name)
+ try:
+ overrides = AttributeGroup.byCollection_name(self.name)
+ except SQLObjectNotFound:
+ overrides = None
if overrides is not None:
for attr in overrides.values:
result[attr.name] = attr.value
Modified: trunk/mailman/src/mailman/database/tests/test_attribute.py
==============================================================================
--- trunk/mailman/src/mailman/database/tests/test_attribute.py (original)
+++ trunk/mailman/src/mailman/database/tests/test_attribute.py Mon Mar 21
17:39:05 2005
@@ -88,6 +88,46 @@
fetched_value = mlist.get_value('enable_archives')
eq(fetched_value, mlist_group_value.value)
+ def test_fetch_attribute_from_mailing_list_when_group_is_missing(self):
+ eq = self.assertEqual
+ attr = Attribute(name='enable_archives',
+ type='BOOL',
+ default_value='True')
+ group = AttributeGroup(collection_name='archive_options')
+ value = AttributeValue(name='enable_archives',
+ group=group,
+ value='False',
+ policy='BASIC')
+ style = ListStyle(name='no_archive')
+ style.addAttributeGroup(group)
+ # group.addStyle(style) # SQLObject automagically does this one
+ # Need to add a MailingList -- paste code from test_roster.py here
+ owners = Roster()
+ moderators = Roster()
+ members = Roster()
+ # Create a mailing list domain
+ domain_admins = Roster()
+ domain = Domain(mailhost='localhost', admins=domain_admins)
+ # Create the required message collections
+ archives = MessageCollection()
+ owner_archives = MessageCollection()
+ # mlist_group = AttributeGroup(collection_name='[EMAIL PROTECTED]')
+ # Finally! Create the mailing list.
+ mlist = MailingList(name='[EMAIL PROTECTED]',
+ owners=owners,
+ moderators=moderators,
+ members=members,
+ domain=domain,
+ archives=archives,
+ owner_archives=owner_archives,
+ list_style=style,
+ )
+ fetched_value = mlist.get_value('enable_archives')
+ eq(fetched_value, value.value)
+ value.set(value='True')
+ fetched_value = mlist.get_value('enable_archives')
+ eq(fetched_value, value.value)
+
def test_default_when_no_value_given(self):
eq = self.assertEqual
attr = Attribute(name='enable_archives',
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe:
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org