Skip to content

Commit

Permalink
Hacking in an OData scope
Browse files Browse the repository at this point in the history
  • Loading branch information
suhrawardi committed Jun 24, 2020
1 parent 4f06367 commit 9241636
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion odata/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,27 @@ class EntityBase(object):
__odata_type__ = 'ODataSchema.Entity'
__odata_singleton__ = False
__odata_schema__ = None
__odata_scope__ = None

@classmethod
def __odata_url__(cls):
# used by Query
if cls.__odata_collection__:
return urljoin(cls.__odata_service__.url, cls.__odata_collection__)
if cls.__odata_scope__:
if callable(cls.__odata_scope__):
return urljoin(
cls.__odata_service__.url,
cls.__odata_scope__(),
cls.__odata_collection__
)
else:
return urljoin(
cls.__odata_service__.url,
cls.__odata_scope__,
cls.__odata_collection__
)
else:
return urljoin(cls.__odata_service__.url, cls.__odata_collection__)

def __new__(cls, *args, **kwargs):
i = super(EntityBase, cls).__new__(cls)
Expand Down

0 comments on commit 9241636

Please sign in to comment.