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 bf0dd1b
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion odata/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,33 @@ 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 "/".join([
urljoin(
cls.__odata_service__.url,
cls.__odata_scope__()
),
cls.__odata_collection__

])
else:
return "/".join([
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 bf0dd1b

Please sign in to comment.