diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-08-27 16:44:34 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-08-27 16:44:34 -0400 |
| commit | 656cb6461b264935027580a32ce3820a7d73bd7e (patch) | |
| tree | 49f1489773a87e3bc8542e53f6d58ceb0386fa2e /lib/sqlalchemy/ext/declarative/base.py | |
| parent | 640625bc9e98dd4060a1e61c717ddc98f8b3808b (diff) | |
| download | sqlalchemy-656cb6461b264935027580a32ce3820a7d73bd7e.tar.gz | |
- [feature] declared_attr can now be used with
attributes that are not Column or MapperProperty;
including any user-defined value as well
as association proxy objects. [ticket:2517]
Diffstat (limited to 'lib/sqlalchemy/ext/declarative/base.py')
| -rw-r--r-- | lib/sqlalchemy/ext/declarative/base.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/sqlalchemy/ext/declarative/base.py b/lib/sqlalchemy/ext/declarative/base.py index e42ec2645..40c8c6ef6 100644 --- a/lib/sqlalchemy/ext/declarative/base.py +++ b/lib/sqlalchemy/ext/declarative/base.py @@ -136,7 +136,7 @@ def _as_declarative(cls, classname, dict_): clsregistry.add_class(classname, cls) our_stuff = util.OrderedDict() - for k in dict_: + for k in list(dict_): # TODO: improve this ? all dunders ? if k in ('__table__', '__tablename__', '__mapper_args__'): @@ -153,6 +153,9 @@ def _as_declarative(cls, classname, dict_): "left at the end of the line?" % k) continue if not isinstance(value, (Column, MapperProperty)): + if not k.startswith('__'): + dict_.pop(k) + setattr(cls, k, value) continue if k == 'metadata': raise exc.InvalidRequestError( |
