diff options
| author | Barry Warsaw | 2012-07-06 21:08:41 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2012-07-06 21:08:41 -0400 |
| commit | 8d8ab1655b51e277570005b445d3b014afcfbc57 (patch) | |
| tree | 6ba0147d975636e129a787c9dfa64dae8cffae89 /src/mailman/model/uid.py | |
| parent | cd3f84b301c2150fea5402129a2e7bc862fbb52b (diff) | |
| parent | 01415190ab44e69a8f09a6411564a7cb288404e8 (diff) | |
| download | mailman-8d8ab1655b51e277570005b445d3b014afcfbc57.tar.gz mailman-8d8ab1655b51e277570005b445d3b014afcfbc57.tar.zst mailman-8d8ab1655b51e277570005b445d3b014afcfbc57.zip | |
trunk merge
Diffstat (limited to 'src/mailman/model/uid.py')
| -rw-r--r-- | src/mailman/model/uid.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/mailman/model/uid.py b/src/mailman/model/uid.py index c3564aa40..08eae8aff 100644 --- a/src/mailman/model/uid.py +++ b/src/mailman/model/uid.py @@ -17,7 +17,7 @@ """Unique IDs.""" -from __future__ import absolute_import, unicode_literals +from __future__ import absolute_import, print_function, unicode_literals __metaclass__ = type __all__ = [ @@ -28,8 +28,8 @@ __all__ = [ from storm.locals import Int from storm.properties import UUID -from mailman.config import config from mailman.database.model import Model +from mailman.database.transaction import dbconnection @@ -48,23 +48,29 @@ class UID(Model): id = Int(primary=True) uid = UUID() - def __init__(self, uid): + @dbconnection + def __init__(self, store, uid): super(UID, self).__init__() self.uid = uid - config.db.store.add(self) + store.add(self) def __repr__(self): return '<UID {0} at {1}>'.format(self.uid, id(self)) @staticmethod - def record(uid): + @dbconnection + # Note that the parameter order is deliberate reversed here. Normally, + # `store` is the first parameter after `self`, but since this is a + # staticmethod and there is no self, the decorator will see the uid in + # arg[0]. + def record(uid, store): """Record the uid in the database. :param uid: The unique id. :type uid: unicode :raises ValueError: if the id is not unique. """ - existing = config.db.store.find(UID, uid=uid) + existing = store.find(UID, uid=uid) if existing.count() != 0: raise ValueError(uid) return UID(uid) |
