summaryrefslogtreecommitdiff
path: root/Mailman/database/messagestore.py
diff options
context:
space:
mode:
authorBarry Warsaw2007-10-31 17:38:51 -0400
committerBarry Warsaw2007-10-31 17:38:51 -0400
commitf321d85d91a370294e771dbaa22493008d78dfdd (patch)
tree8cf4c3e7cab70ccc9059f147ff1bf4b3bf150115 /Mailman/database/messagestore.py
parent1ad73a52bb9d82ef3af1e34ad9ef66ac2eda2909 (diff)
downloadmailman-f321d85d91a370294e771dbaa22493008d78dfdd.tar.gz
mailman-f321d85d91a370294e771dbaa22493008d78dfdd.tar.zst
mailman-f321d85d91a370294e771dbaa22493008d78dfdd.zip
Much progress, though not perfect, on migrating to SQLAlchemy 0.4 and Elixir
0.4. Lots of things changes, which broke lots of our code. There are still a couple of failures in the test suite that I don't understand. It seems that for pending.txt and requests.txt, sometimes strings come back from the database as 8-bit strings and other times as unicodes. It's impossible to make these tests work both separately and together. users.txt is also failing intermittently. Lots of different behavior between running the full test suite all together and running individual tests. Sigh. Note also that actually, Elixir 0.4.0 doesn't work for us. There's a bug in that version that prevented zope.interfaces and Elixir working together. Get the latest 0.4.0 from source to fix this. Other changes include: - Remove Mailman/lockfile.py. While I haven't totally eliminated locking, I have released the lockfile as a separate Python package called locknix, which Mailman 3.0 now depends on. - Renamed Mailman/interfaces/messagestore.py and added an IMessage interface. - bin/testall raises turns on SQLALCHEMY_ECHO when the verbosity is above 3 (that's three -v's because the default verbosity is 1). - add_domain() in config files now allows url_host to be optional. If not given, it defaults to email_host. - Added a non-public interface IDatabase._reset() used by the test suite to zap the database between doctests. Added an implementation in the model which just runs through all rows in all entities, deleting them. - [I]Pending renamed to [I]Pended - Don't allow Pendings.add() to infloop. - In the model's User impelementations, we don't need to append or remove the address when linking and unlinking. By setting the address.user attribute, SQLAlchemy appears to do the right thing, though I'm not 100% sure of that (see the above mentioned failures).
Diffstat (limited to 'Mailman/database/messagestore.py')
-rw-r--r--Mailman/database/messagestore.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/Mailman/database/messagestore.py b/Mailman/database/messagestore.py
index bbaa6976b..e0e6cd9f1 100644
--- a/Mailman/database/messagestore.py
+++ b/Mailman/database/messagestore.py
@@ -97,11 +97,11 @@ class MessageStore:
return pickle.load(fp)
def get_messages_by_message_id(self, message_id):
- for msgrow in Message.select_by(message_id=message_id):
+ for msgrow in Message.query.filter_by(message_id=message_id):
yield self._msgobj(msgrow)
def get_messages_by_hash(self, hash):
- for msgrow in Message.select_by(hash=hash):
+ for msgrow in Message.query.filter_by(hash=hash):
yield self._msgobj(msgrow)
def _getmsg(self, global_id):
@@ -110,15 +110,15 @@ class MessageStore:
seqno = int(seqno)
except ValueError:
return None
- msgrows = Message.select_by(id=seqno)
- if not msgrows:
+ messages = Message.query.filter_by(id=seqno)
+ if messages.count() == 0:
return None
- assert len(msgrows) == 1, 'Multiple id matches'
- if msgrows[0].hash <> hash:
+ assert messages.count() == 1, 'Multiple id matches'
+ if messages[0].hash <> hash:
# The client lied about which message they wanted. They gave a
# valid sequence number, but the hash did not match.
return None
- return msgrows[0]
+ return messages[0]
def get_message(self, global_id):
msgrow = self._getmsg(global_id)
@@ -126,7 +126,7 @@ class MessageStore:
@property
def messages(self):
- for msgrow in Message.select():
+ for msgrow in Message.query.filter_by().all():
yield self._msgobj(msgrow)
def delete_message(self, global_id):