~raj-abhilash1/mailman/gsoc

« back to all changes in this revision

Viewing changes to src/mailman/model/member.py

  • Committer: Barry Warsaw
  • Date: 2014-03-02 21:38:32 UTC
  • Revision ID: barry@list.org-20140302213832-tkgvano62vsw67r0
* Module coding style consistency.
* handle_SubscriptionEvent(): We're always guaranteed to get a language from a
  member, since lookup falls back ultimately to the system preferences.  So
  this method can be simplified.
* Bump up code coverage for several modules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
136
136
                if self._address is None
137
137
                else getUtility(IUserManager).get_user(self._address.email))
138
138
 
139
 
    def _lookup(self, preference):
 
139
    def _lookup(self, preference, default=None):
140
140
        pref = getattr(self.preferences, preference)
141
141
        if pref is not None:
142
142
            return pref
147
147
            pref = getattr(self.address.user.preferences, preference)
148
148
            if pref is not None:
149
149
                return pref
150
 
        return getattr(system_preferences, preference)
 
150
        if default is None:
 
151
            return getattr(system_preferences, preference)
 
152
        return default
151
153
 
152
154
    @property
153
155
    def acknowledge_posts(self):
157
159
    @property
158
160
    def preferred_language(self):
159
161
        """See `IMember`."""
160
 
        return self._lookup('preferred_language')
 
162
        missing = object()
 
163
        language = self._lookup('preferred_language', missing)
 
164
        if language is missing:
 
165
            language = ((self.mailing_list and
 
166
                         self.mailing_list.preferred_language) or
 
167
                        system_preferences.preferred_language)
 
168
        return language
161
169
 
162
170
    @property
163
171
    def receive_list_copy(self):