summaryrefslogtreecommitdiff
path: root/src/mailman/database/mailinglist.py
diff options
context:
space:
mode:
authorBarry Warsaw2009-02-12 20:36:21 -0500
committerBarry Warsaw2009-02-12 20:36:21 -0500
commit62f4c909f90535986614a411db982bdcccaec3a1 (patch)
tree2fe5dd3316cea73f63cb34230d848758050eade3 /src/mailman/database/mailinglist.py
parent2b28803e7165e91d812cd9e9e3804a6d9bdce8a1 (diff)
downloadmailman-62f4c909f90535986614a411db982bdcccaec3a1.tar.gz
mailman-62f4c909f90535986614a411db982bdcccaec3a1.tar.zst
mailman-62f4c909f90535986614a411db982bdcccaec3a1.zip
Much clean up of the language code, though more can be done. Factor out the
language manager stuff into a separate Language class, and be clearer in the APIs about whether we want a language code or a Language instance. The impetus to this was to get rid of Utils.GetCharSet(), which is done.
Diffstat (limited to 'src/mailman/database/mailinglist.py')
-rw-r--r--src/mailman/database/mailinglist.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/mailman/database/mailinglist.py b/src/mailman/database/mailinglist.py
index e380a71b1..605c51cd6 100644
--- a/src/mailman/database/mailinglist.py
+++ b/src/mailman/database/mailinglist.py
@@ -151,7 +151,7 @@ class MailingList(Model):
personalize = Enum()
pipeline = Unicode()
post_id = Int()
- preferred_language = Unicode()
+ _preferred_language = Unicode(name='preferred_language')
private_roster = Bool()
real_name = Unicode()
reject_these_nonmembers = Pickle()
@@ -200,6 +200,10 @@ class MailingList(Model):
self.digest_members = roster.DigestMemberRoster(self)
self.subscribers = roster.Subscribers(self)
+ def __repr__(self):
+ return '<mailing list "{0}" at {1:#x}>'.format(
+ self.fqdn_listname, id(self))
+
@property
def fqdn_listname(self):
"""See `IMailingList`."""
@@ -267,6 +271,14 @@ class MailingList(Model):
cookie = cookie))
return '{0}@{1}'.format(local_part, self.host_name)
- def __repr__(self):
- return '<mailing list "{0}" at {1:#x}>'.format(
- self.fqdn_listname, id(self))
+ @property
+ def preferred_language(self):
+ return config.languages[self._preferred_language]
+
+ @preferred_language.setter
+ def preferred_language(self, language):
+ # Accept both a language code and a `Language` instance.
+ try:
+ self._preferred_language = language.code
+ except AttributeError:
+ self._preferred_language = language