Skip to content

Commit

Permalink
better support for eager loading
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Apr 8, 2015
1 parent 1c7c6b5 commit 660e54b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/appier/model.py
Expand Up @@ -116,6 +116,15 @@
values for each for them, these meta type values are going
to be used mostly for presentation purposes """

TYPE_REFERENCES = (
typesf.Reference,
typesf.References
)
""" The various data types that are considered to be references
so that they are lazy loaded from the data source, these kind
of types should be compliant to a common interface so that they
may be used "blindly" from an external entity """

REVERSE = dict(
descending = "ascending",
ascending = "descending",
Expand Down Expand Up @@ -1005,6 +1014,8 @@ def _eager(cls, model, names):
# for each of them so that they are properly eager loaded
for name in names:
value = model[name]
if not value: continue
if not isinstance(value, TYPE_REFERENCES): continue
model[name] = value.resolve()

# returns the resulting model to the caller method, most of the
Expand Down

0 comments on commit 660e54b

Please sign in to comment.