diff options
| author | Abhilash Raj | 2014-09-06 15:43:47 +0530 |
|---|---|---|
| committer | Abhilash Raj | 2014-09-06 15:43:47 +0530 |
| commit | db1f5638fe1ab83406a305c3f108c4a1bcfd9cd7 (patch) | |
| tree | e80b7f649cac12d35fa23383adaceabc43406b8b /src/mailman/database/model.py | |
| parent | 46018e4c5624b8cc1b281d97f6df870028adb806 (diff) | |
| download | mailman-db1f5638fe1ab83406a305c3f108c4a1bcfd9cd7.tar.gz mailman-db1f5638fe1ab83406a305c3f108c4a1bcfd9cd7.tar.zst mailman-db1f5638fe1ab83406a305c3f108c4a1bcfd9cd7.zip | |
Diffstat (limited to 'src/mailman/database/model.py')
| -rw-r--r-- | src/mailman/database/model.py | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/src/mailman/database/model.py b/src/mailman/database/model.py index 5fbf4005d..4b8478fc6 100644 --- a/src/mailman/database/model.py +++ b/src/mailman/database/model.py @@ -24,26 +24,21 @@ __all__ = [ 'Model', ] - from operator import attrgetter from sqlalchemy.ext.declarative import declarative_base -from storm.properties import PropertyPublisherMeta - -Base = declerative_base() - -class ModelMeta(PropertyPublisherMeta): +class ModelMeta(object): """Do more magic on table classes.""" _class_registry = set() def __init__(self, name, bases, dict): - # Before we let the base class do it's thing, force an __storm_table__ + # Before we let the base class do it's thing, force an __tablename__ # property to enforce our table naming convention. - self.__storm_table__ = name.lower() - super(ModelMeta, self).__init__(name, bases, dict) + self.__tablename__ = name.lower() + # super(ModelMeta, self).__init__(name, bases, dict) # Register the model class so that it can be more easily cleared. # This is required by the test framework so that the corresponding # table can be reset between tests. @@ -60,12 +55,8 @@ class ModelMeta(PropertyPublisherMeta): config.db._pre_reset(store) # Make sure this is deterministic, by sorting on the storm table name. classes = sorted(ModelMeta._class_registry, - key=attrgetter('__storm_table__')) + key=attrgetter('__tablename__')) for model_class in classes: - store.find(model_class).remove() - + store.query(model_class).delete() - -class Model: - """Like Storm's `Storm` subclass, but with a bit extra.""" - __metaclass__ = Base +Model = declarative_base(cls=ModelMeta) |
