~sambuddhabasu1/mailman/fix_mailman_run_error

« back to all changes in this revision

Viewing changes to src/mailman/app/subscriptions.py

  • Committer: Barry Warsaw
  • Date: 2014-11-02 19:55:10 UTC
  • mfrom: (7254 3.0)
  • mto: This revision was merged to the branch mainline in revision 7260.
  • Revision ID: barry@list.org-20141102195510-chj4lvutfzo1o93w
Trunk merge.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
from operator import attrgetter
30
30
from passlib.utils import generate_password as generate
31
 
from storm.expr import And, Or
 
31
from sqlalchemy import and_, or_
32
32
from uuid import UUID
33
33
from zope.component import getUtility
34
34
from zope.interface import implementer
88
88
    @dbconnection
89
89
    def get_member(self, store, member_id):
90
90
        """See `ISubscriptionService`."""
91
 
        members = store.find(
92
 
            Member,
93
 
            Member._member_id == member_id)
 
91
        members = store.query(Member).filter(Member._member_id == member_id)
94
92
        if members.count() == 0:
95
93
            return None
96
94
        else:
117
115
                # This probably could be made more efficient.
118
116
                if address is None or user is None:
119
117
                    return []
120
 
                query.append(Or(Member.address_id == address.id,
121
 
                                Member.user_id == user.id))
 
118
                query.append(or_(Member.address_id == address.id,
 
119
                                 Member.user_id == user.id))
122
120
            else:
123
121
                # subscriber is a user id.
124
122
                user = user_manager.get_user_by_id(subscriber)
126
124
                                   if address.id is not None)
127
125
                if len(address_ids) == 0 or user is None:
128
126
                    return []
129
 
                query.append(Or(Member.user_id == user.id,
130
 
                                Member.address_id.is_in(address_ids)))
 
127
                query.append(or_(Member.user_id == user.id,
 
128
                                 Member.address_id.in_(address_ids)))
131
129
        # Calculate the rest of the query expression, which will get And'd
132
130
        # with the Or clause above (if there is one).
133
131
        if list_id is not None:
134
132
            query.append(Member.list_id == list_id)
135
133
        if role is not None:
136
134
            query.append(Member.role == role)
137
 
        results = store.find(Member, And(*query))
 
135
        results = store.query(Member).filter(and_(*query))
138
136
        return sorted(results, key=_membership_sort_key)
139
137
 
140
138
    def __iter__(self):