1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# Copyright (C) 2007 by the Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
from elixir import *
from zope.interface import implements
from Mailman.Utils import split_listname
from Mailman.constants import SystemDefaultPreferences
from Mailman.database.types import EnumType
from Mailman.interfaces import IMember, IPreferences
ADDRESS_KIND = 'Mailman.database.model.address.Address'
PREFERENCE_KIND = 'Mailman.database.model.preferences.Preferences'
class Member(Entity):
implements(IMember)
role = Field(EnumType)
mailing_list = Field(Unicode)
# Relationships
address = ManyToOne(ADDRESS_KIND)
preferences = ManyToOne(PREFERENCE_KIND)
def __repr__(self):
return '<Member: %s on %s as %s>' % (
self.address, self.mailing_list, self.role)
def _lookup(self, preference):
pref = getattr(self.preferences, preference)
if pref is not None:
return pref
pref = getattr(self.address.preferences, preference)
if pref is not None:
return pref
if self.address.user:
pref = getattr(self.address.user.preferences, preference)
if pref is not None:
return pref
return getattr(SystemDefaultPreferences, preference)
@property
def acknowledge_posts(self):
return self._lookup('acknowledge_posts')
@property
def preferred_language(self):
return self._lookup('preferred_language')
@property
def receive_list_copy(self):
return self._lookup('receive_list_copy')
@property
def receive_own_postings(self):
return self._lookup('receive_own_postings')
@property
def delivery_mode(self):
return self._lookup('delivery_mode')
@property
def delivery_status(self):
return self._lookup('delivery_status')
@property
def options_url(self):
# XXX Um, this is definitely wrong
return 'http://example.com/' + self.address.address
def unsubscribe(self):
self.preferences.delete()
self.delete()
|