diff options
| author | Abhilash Raj | 2014-09-19 06:59:12 +0530 |
|---|---|---|
| committer | Abhilash Raj | 2014-09-19 06:59:12 +0530 |
| commit | 6dd2ac32ee1f1e8f588c08fd5363f0f794d0a6b1 (patch) | |
| tree | bf68d953616cd85bc14d3dee866998272fdfb506 | |
| parent | 917c7fab696151743e4765560d55565ec8e8e38e (diff) | |
| download | mailman-6dd2ac32ee1f1e8f588c08fd5363f0f794d0a6b1.tar.gz mailman-6dd2ac32ee1f1e8f588c08fd5363f0f794d0a6b1.tar.zst mailman-6dd2ac32ee1f1e8f588c08fd5363f0f794d0a6b1.zip | |
| -rw-r--r-- | src/mailman/app/subscriptions.py | 2 | ||||
| -rw-r--r-- | src/mailman/database/base.py | 12 | ||||
| -rw-r--r-- | src/mailman/database/types.py | 4 | ||||
| -rw-r--r-- | src/mailman/model/autorespond.py | 3 | ||||
| -rw-r--r-- | src/mailman/model/bans.py | 2 | ||||
| -rw-r--r-- | src/mailman/model/user.py | 9 | ||||
| -rw-r--r-- | src/mailman/utilities/importer.py | 20 |
7 files changed, 31 insertions, 21 deletions
diff --git a/src/mailman/app/subscriptions.py b/src/mailman/app/subscriptions.py index a53d22e72..303303e70 100644 --- a/src/mailman/app/subscriptions.py +++ b/src/mailman/app/subscriptions.py @@ -126,7 +126,7 @@ class SubscriptionService: if len(address_ids) == 0 or user is None: return [] query.append(or_(Member.user_id == user.id, - Member.address_id.is_in(address_ids))) + Member.address_id.in_(address_ids))) # Calculate the rest of the query expression, which will get And'd # with the Or clause above (if there is one). if list_id is not None: diff --git a/src/mailman/database/base.py b/src/mailman/database/base.py index b66513a2c..5eec853d6 100644 --- a/src/mailman/database/base.py +++ b/src/mailman/database/base.py @@ -107,18 +107,6 @@ class SABaseDatabase: self.store = session() self.store.commit() - # def initialize_testing(self): - # url = expand(config.database.url, config.paths) - # log.debug('Database url: %s', url) - # self.url = url - # self._prepare(url) - # self.engine = create_engine(url) - # connection = self.engine.connect() - # self.transaction = connection.begin_nested() - # self.store = Session(connection) - # self.store.commit() - - def load_migrations(self, until=None): """Load schema migrations. diff --git a/src/mailman/database/types.py b/src/mailman/database/types.py index 81721781d..a6f0b32ca 100644 --- a/src/mailman/database/types.py +++ b/src/mailman/database/types.py @@ -49,9 +49,7 @@ class Enum(TypeDecorator): def process_bind_param(self, value, dialect): if value is None: return None - if not isinstance(value, self.enum): - raise ValueError("{} must be a value of the {} enum".format( - value, self.enum.__name__)) + return value.value diff --git a/src/mailman/model/autorespond.py b/src/mailman/model/autorespond.py index 17fe5fadc..c3aff174a 100644 --- a/src/mailman/model/autorespond.py +++ b/src/mailman/model/autorespond.py @@ -28,6 +28,7 @@ __all__ = [ from sqlalchemy import (Column, Integer, String, Unicode, ForeignKey, Date) +from sqlalchemy import desc from sqlalchemy.orm import relationship from zope.interface import implementer @@ -95,5 +96,5 @@ class AutoResponseSet: address = address, mailing_list = self._mailing_list, response_type = response_type - ).order_by(Desc(AutoResponseRecord.date_sent)) + ).order_by(desc(AutoResponseRecord.date_sent)) return (None if results.count() == 0 else results.first()) diff --git a/src/mailman/model/bans.py b/src/mailman/model/bans.py index d0f3b2519..fbbecaebd 100644 --- a/src/mailman/model/bans.py +++ b/src/mailman/model/bans.py @@ -75,7 +75,7 @@ class BanManager: ban = store.query(Ban).filter_by(email=email, list_id=self._list_id).first() if ban is not None: - store.remove(ban) + store.delete(ban) @dbconnection def is_banned(self, store, email): diff --git a/src/mailman/model/user.py b/src/mailman/model/user.py index 12f4643f1..37fb29e65 100644 --- a/src/mailman/model/user.py +++ b/src/mailman/model/user.py @@ -62,13 +62,16 @@ class User(Model): addresses = relationship('Address', backref='user', - foreign_keys='[Address.user_id]') + primaryjoin= + id==Address.user_id) _preferred_address_id = Column(Integer, ForeignKey('address.id', use_alter=True, - name='prefered_address_id')) + name='_preferred_address')) _preferred_address = relationship('Address', - foreign_keys=[_preferred_address_id]) + primaryjoin= + _preferred_address_id==Address.id, + post_update=True) preferences_id = Column(Integer, ForeignKey('preferences.id')) preferences = relationship('Preferences', diff --git a/src/mailman/utilities/importer.py b/src/mailman/utilities/importer.py index cf22af24f..9856a8223 100644 --- a/src/mailman/utilities/importer.py +++ b/src/mailman/utilities/importer.py @@ -198,6 +198,14 @@ NAME_MAPPINGS = dict( send_welcome_msg='send_welcome_message', ) +# Datetime Fields that need a type conversion to python datetime +# object for SQLite database. +DATETIME_OBJECTS = [ + 'created_at', + 'digest_last_sent_at', + 'last_post_time', +] + EXCLUDES = set(( 'digest_members', 'members', @@ -217,6 +225,9 @@ def import_config_pck(mlist, config_dict): # Some attributes must not be directly imported. if key in EXCLUDES: continue + # Created at must not be set, it needs a type conversion + if key in DATETIME_OBJECTS: + continue # Some attributes from Mailman 2 were renamed in Mailman 3. key = NAME_MAPPINGS.get(key, key) # Handle the simple case where the key is an attribute of the @@ -238,6 +249,15 @@ def import_config_pck(mlist, config_dict): except (TypeError, KeyError): print('Type conversion error for key "{}": {}'.format( key, value), file=sys.stderr) + for key in DATETIME_OBJECTS: + try: + value = datetime.datetime.utcfromtimestamp(config_dict[key]) + except KeyError: + continue + if key == 'last_post_time': + setattr(mlist, 'last_post_at', value) + continue + setattr(mlist, key, value) # Handle the archiving policy. In MM2.1 there were two boolean options # but only three of the four possible states were valid. Now there's just # an enum. |
