summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/declarative.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-07-13 11:55:08 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-07-13 11:55:08 -0400
commiteb890eb402fea95f8fbe66622d40ba8189cb2b45 (patch)
tree924381efdac0285eac84e09cab43a47736403ef0 /lib/sqlalchemy/ext/declarative.py
parent800448ad621a7cbe50726b6e208f55264dc623bc (diff)
downloadsqlalchemy-eb890eb402fea95f8fbe66622d40ba8189cb2b45.tar.gz
- pull out type() ahead of time to cut down on fn calls.
Would replace this with set(dir(self)) but not sure if some class schemes may have issues with dir() (also for low numbers of args, not using the set() probably faster).
Diffstat (limited to 'lib/sqlalchemy/ext/declarative.py')
-rwxr-xr-xlib/sqlalchemy/ext/declarative.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/sqlalchemy/ext/declarative.py b/lib/sqlalchemy/ext/declarative.py
index ff0dc6bfc..909fb5cba 100755
--- a/lib/sqlalchemy/ext/declarative.py
+++ b/lib/sqlalchemy/ext/declarative.py
@@ -1162,11 +1162,12 @@ def _declarative_constructor(self, **kwargs):
attributes of the instance's class are allowed. These could be,
for example, any mapped columns or relationships.
"""
+ cls_ = type(self)
for k in kwargs:
- if not hasattr(type(self), k):
+ if not hasattr(cls_, k):
raise TypeError(
"%r is an invalid keyword argument for %s" %
- (k, type(self).__name__))
+ (k, cls_.__name__))
setattr(self, k, kwargs[k])
_declarative_constructor.__name__ = '__init__'