SAP / SAP/python-pyodata

Handling deferred attributes automatically

Open
#118 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
268
Forks
100
PR merge metrics
No merged PRs in 30d

Description

Right now if an entity has a navigation property, the object must be completely reloaded (as below) to load in deferred data in navigation properties. For example:

orders = service.orders.get_entities()

for o in orders:
    do_some_stuff_with(o.Customers)  # This is an empty list right now so nothing will get done.

# The data must be reloaded as per the below for anything to happen.
orders = service.orders.get_entities().expand("Customers")

I propose that we use the OData __deferred attribute to fire a request on demand to load these attributes in. This would allow the API to look like this:

orders = service.orders.get_entities()

for o in orders:
   do_some_stuff_with(o.Customers)  # Request is automatically made using the `__deferred` attribute which transparently offers the missing data back to the class.

WDYT: @filak-sap

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing service.orders.get_entities(), navigation properties such as Customers, and the existing expand("Customers") behavior. Determine how the OData __deferred attribute could trigger on-demand loading while preserving the entity API; done means accessing o.Customers transparently provides the deferred data without explicitly calling expand.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.