summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/declarative.py
diff options
context:
space:
mode:
authorJason Kirtland <jek@discorporate.us>2008-03-10 18:32:07 +0000
committerJason Kirtland <jek@discorporate.us>2008-03-10 18:32:07 +0000
commitac13a8445b60e5c4373bcba301a3df16cf743311 (patch)
treebc880168fab8bb19905a42f874e6901c07f399b7 /lib/sqlalchemy/ext/declarative.py
parent79004f1ede9f74b6b6f04424ee36d2f442f839c1 (diff)
downloadsqlalchemy-ac13a8445b60e5c4373bcba301a3df16cf743311.tar.gz
- Added __autoload__ = True for declarative
- declarative Base.__init__ is pickier about its kwargs
Diffstat (limited to 'lib/sqlalchemy/ext/declarative.py')
-rw-r--r--lib/sqlalchemy/ext/declarative.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/sqlalchemy/ext/declarative.py b/lib/sqlalchemy/ext/declarative.py
index 77bffad7a..fbb68f579 100644
--- a/lib/sqlalchemy/ext/declarative.py
+++ b/lib/sqlalchemy/ext/declarative.py
@@ -170,9 +170,16 @@ class DeclarativeMeta(type):
if '__table__' not in cls.__dict__:
if '__tablename__' in cls.__dict__:
tablename = cls.__tablename__
+ autoload = cls.__dict__.get('__autoload__')
+ if autoload is True:
+ table_kw = {'autoload': True}
+ elif autoload:
+ table_kw = {'autoload': True, 'autoload_with': autoload}
+ else:
+ table_kw = {}
cls.__table__ = table = Table(tablename, cls.metadata, *[
c for c in our_stuff.values() if isinstance(c, Column)
- ])
+ ], **table_kw)
else:
table = cls.__table__
@@ -234,6 +241,9 @@ def declarative_base(engine=None, metadata=None):
_decl_class_registry = {}
def __init__(self, **kwargs):
for k in kwargs:
+ if not hasattr(type(self), k):
+ raise TypeError('%r is an invalid keyword argument for %s' %
+ (k, type(self).__name__))
setattr(self, k, kwargs[k])
return Base