diff options
| author | Barry Warsaw | 2007-11-10 13:14:51 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2007-11-10 13:14:51 -0500 |
| commit | 58b8ca1c929c5bc0ea1b36fb5e6e683a8830e963 (patch) | |
| tree | 4d87cdececa390c0bcc1460f60c6102e0e81f87d /Mailman/database/model | |
| parent | 3d7b9702e4ff97f86025f8d7ae9b29220f5bf264 (diff) | |
| download | mailman-58b8ca1c929c5bc0ea1b36fb5e6e683a8830e963.tar.gz mailman-58b8ca1c929c5bc0ea1b36fb5e6e683a8830e963.tar.zst mailman-58b8ca1c929c5bc0ea1b36fb5e6e683a8830e963.zip | |
All the simple test fixes are now in, and while there are still some failing
tests, we're making very good progress. Just the tough ones are left. This
change did modify the the schema a bit, for better naming and typing.
E.g. 'type' -> 'request_type' and using a RawStr for a hash type.
Diffstat (limited to 'Mailman/database/model')
| -rw-r--r-- | Mailman/database/model/mailman.sql | 2 | ||||
| -rw-r--r-- | Mailman/database/model/message.py | 15 | ||||
| -rw-r--r-- | Mailman/database/model/pending.py | 2 | ||||
| -rw-r--r-- | Mailman/database/model/requests.py | 39 |
4 files changed, 29 insertions, 29 deletions
diff --git a/Mailman/database/model/mailman.sql b/Mailman/database/model/mailman.sql index 3dabad8c6..a20b1b118 100644 --- a/Mailman/database/model/mailman.sql +++ b/Mailman/database/model/mailman.sql @@ -1,7 +1,7 @@ CREATE TABLE _request ( id INTEGER NOT NULL, "key" TEXT, - type TEXT, + request_type TEXT, data_hash TEXT, mailing_list_id INTEGER, PRIMARY KEY (id), diff --git a/Mailman/database/model/message.py b/Mailman/database/model/message.py index 7a6d7371a..c4ea4a636 100644 --- a/Mailman/database/model/message.py +++ b/Mailman/database/model/message.py @@ -18,6 +18,7 @@ from storm.locals import * from zope.interface import implements +from Mailman.configuration import config from Mailman.database import Model from Mailman.interfaces import IMessage @@ -28,8 +29,14 @@ class Message(Model): implements(IMessage) - id = Int(primary=True) - hash = Unicode() - path = Unicode() - # This is a Messge-ID field representation, not a database row id. + id = Int(primary=True, default=AutoReload) message_id = Unicode() + hash = RawStr() + path = RawStr() + # This is a Messge-ID field representation, not a database row id. + + def __init__(self, message_id, hash, path): + self.message_id = message_id + self.hash = hash + self.path = path + config.db.store.add(self) diff --git a/Mailman/database/model/pending.py b/Mailman/database/model/pending.py index 970e3c16e..be180d7f2 100644 --- a/Mailman/database/model/pending.py +++ b/Mailman/database/model/pending.py @@ -110,7 +110,7 @@ class Pendings(object): return token def confirm(self, token, expunge=True): - pendings = Pended.query.filter_by(token=token) + pendings = config.db.store.find(Pended, token=token) if pendings.count() == 0: return None assert pendings.count() == 1, ( diff --git a/Mailman/database/model/requests.py b/Mailman/database/model/requests.py index 5e92e70b2..0817388e3 100644 --- a/Mailman/database/model/requests.py +++ b/Mailman/database/model/requests.py @@ -53,7 +53,7 @@ class ListRequests: def count_of(self, request_type): return config.db.store.find( _Request, - mailing_list=self.mailing_list, type=request_type).count() + mailing_list=self.mailing_list, request_type=request_type).count() @property def held_requests(self): @@ -65,7 +65,7 @@ class ListRequests: def of_type(self, request_type): results = config.db.store.find( _Request, - mailing_list=self.mailing_list, type=request_type) + mailing_list=self.mailing_list, request_type=request_type) for request in results: yield request @@ -83,25 +83,12 @@ class ListRequests: pendable.update(data) token = config.db.pendings.add(pendable, timedelta(days=5000)) data_hash = token - # XXX This would be a good other way to do it, but it causes the - # select_by()'s in .count and .held_requests() to fail, even with - # flush()'s. -## result = _Request.table.insert().execute( -## key=key, type=request_type, -## mailing_list=self.mailing_list, -## data_hash=data_hash) -## row_id = result.last_inserted_ids()[0] -## return row_id - result = _Request(key=key, type=request_type, - mailing_list=self.mailing_list, - data_hash=data_hash) - # XXX We need a handle on last_inserted_ids() instead of requiring a - # flush of the database to get a valid id. - config.db.flush() - return result.id + request = _Request(key, request_type, self.mailing_list, data_hash) + config.db.store.add(request) + return request.id def get_request(self, request_id): - result = _Request.get(request_id) + result = config.db.store.get(_Request, request_id) if result is None: return None if result.data_hash is None: @@ -132,10 +119,16 @@ class Requests: class _Request(Model): """Table for mailing list hold requests.""" - id = Int(primary=True) + id = Int(primary=True, default=AutoReload) key = Unicode() - type = Enum() - data_hash = Unicode() + request_type = Enum() + data_hash = RawStr() mailing_list_id = Int() - mailing_list = Reference(mailing_list_id, 'MailingList') + mailing_list = Reference(mailing_list_id, 'MailingList.id') + + def __init__(self, key, request_type, mailing_list, data_hash): + self.key = key + self.request_type = request_type + self.mailing_list = mailing_list + self.data_hash = data_hash |
