diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-02-22 22:31:49 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-02-22 22:31:49 +0000 |
| commit | 75c5c0322ff47cec37d39eb4db48f574b0b79be0 (patch) | |
| tree | db04dbe784369dc9cd87668e84fbb9d039a5a87f /lib/sqlalchemy/ext/declarative.py | |
| parent | c6dd43b25245a4e6cd184995357e97a0a8a1dbe7 (diff) | |
| download | sqlalchemy-75c5c0322ff47cec37d39eb4db48f574b0b79be0.tar.gz | |
- DeclarativeMeta exclusively uses cls.__dict__ (not dict_)
as the source of class information; _as_declarative exclusively
uses the dict_ passed to it as the source of class information
(which when using DeclarativeMeta is cls.__dict__). This should
in theory make it easier for custom metaclasses to modify
the state passed into _as_declarative.
Diffstat (limited to 'lib/sqlalchemy/ext/declarative.py')
| -rw-r--r-- | lib/sqlalchemy/ext/declarative.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/sqlalchemy/ext/declarative.py b/lib/sqlalchemy/ext/declarative.py index 234aac17c..d5bd2906b 100644 --- a/lib/sqlalchemy/ext/declarative.py +++ b/lib/sqlalchemy/ext/declarative.py @@ -468,11 +468,11 @@ def _as_declarative(cls, classname, dict_): del our_stuff[key] table = None - if '__table__' not in cls.__dict__: - if '__tablename__' in cls.__dict__: + if '__table__' not in dict_: + if '__tablename__' in dict_: tablename = cls.__tablename__ - table_args = cls.__dict__.get('__table_args__') + table_args = dict_.get('__table_args__') if isinstance(table_args, dict): args, table_kw = (), table_args elif isinstance(table_args, tuple): @@ -486,7 +486,7 @@ def _as_declarative(cls, classname, dict_): else: args, table_kw = (), {} - autoload = cls.__dict__.get('__autoload__') + autoload = dict_.get('__autoload__') if autoload: table_kw['autoload'] = True @@ -497,7 +497,8 @@ def _as_declarative(cls, classname, dict_): if cols: for c in cols: if not table.c.contains_column(c): - raise exceptions.ArgumentError("Can't add additional column %r when specifying __table__" % key) + raise exceptions.ArgumentError( + "Can't add additional column %r when specifying __table__" % key) mapper_args = getattr(cls, '__mapper_args__', {}) if 'inherits' not in mapper_args: @@ -557,8 +558,8 @@ class DeclarativeMeta(type): def __init__(cls, classname, bases, dict_): if '_decl_class_registry' in cls.__dict__: return type.__init__(cls, classname, bases, dict_) - - _as_declarative(cls, classname, dict_) + + _as_declarative(cls, classname, cls.__dict__) return type.__init__(cls, classname, bases, dict_) def __setattr__(cls, key, value): |
