diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-12-29 19:31:28 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-12-29 19:31:28 -0500 |
| commit | b30ef87d27898434188462455f3c850297e335d1 (patch) | |
| tree | 58eddbad639eb05e1756d81db57822e8a4465ae2 /lib/sqlalchemy/orm/instrumentation.py | |
| parent | 559b83312c44f7ebfe94bf7bd3b2de3133c5af9e (diff) | |
| download | sqlalchemy-b30ef87d27898434188462455f3c850297e335d1.tar.gz | |
Extended the :doc:`/core/inspection` system so that all Python descriptors
associated with the ORM or its extensions can be retrieved.
This fulfills the common request of being able to inspect
all :class:`.QueryableAttribute` descriptors in addition to
extension types such as :class:`.hybrid_property` and
:class:`.AssociationProxy`. See :attr:`.Mapper.all_orm_descriptors`.
Diffstat (limited to 'lib/sqlalchemy/orm/instrumentation.py')
| -rw-r--r-- | lib/sqlalchemy/orm/instrumentation.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/instrumentation.py b/lib/sqlalchemy/orm/instrumentation.py index 5a4fc2093..cfd5b600c 100644 --- a/lib/sqlalchemy/orm/instrumentation.py +++ b/lib/sqlalchemy/orm/instrumentation.py @@ -29,7 +29,7 @@ alternate instrumentation forms. """ -from . import exc, collections, events +from . import exc, collections, events, interfaces from operator import attrgetter from .. import event, util state = util.importlater("sqlalchemy.orm", "state") @@ -83,6 +83,24 @@ class ClassManager(dict): # raises unless self.mapper has been assigned raise exc.UnmappedClassError(self.class_) + def _all_sqla_attributes(self, exclude=None): + """return an iterator of all classbound attributes that are + implement :class:`._InspectionAttr`. + + This includes :class:`.QueryableAttribute` as well as extension + types such as :class:`.hybrid_property` and :class:`.AssociationProxy`. + + """ + if exclude is None: + exclude = set() + for supercls in self.class_.__mro__: + for key in set(supercls.__dict__).difference(exclude): + exclude.add(key) + val = supercls.__dict__[key] + if isinstance(val, interfaces._InspectionAttr): + yield key, val + + def _attr_has_impl(self, key): """Return True if the given attribute is fully initialized. |
