1
# Copyright (C) 2006-2007 by the Free Software Foundation, Inc.
3
# This program is free software; you can redistribute it and/or
4
# modify it under the terms of the GNU General Public License
5
# as published by the Free Software Foundation; either version 2
6
# of the License, or (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
18
"""Base class for all database classes."""
25
from storm.properties import PropertyPublisherMeta
29
class ModelMeta(PropertyPublisherMeta):
30
"""Do more magic on table classes."""
32
_class_registry = set()
34
def __init__(self, name, bases, dict):
35
# Before we let the base class do it's thing, force an __storm_table__
36
# property to enforce our table naming convention.
37
self.__storm_table__ = name.lower()
38
super(ModelMeta, self).__init__(name, bases, dict)
39
# Register the model class so that it can be more easily cleared.
40
# This is required by the test framework.
43
ModelMeta._class_registry.add(self)
47
for model_class in ModelMeta._class_registry:
48
for row in store.find(model_class):
54
"""Like Storm's `Storm` subclass, but with a bit extra."""
55
__metaclass__ = ModelMeta