Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion odata/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


class Context:
def __init__(self, session=None, auth=None, extra_headers: dict = None, server_flags: ODataServerFlags = None):
def __init__(self, session=None, auth=None, extra_headers: dict = None, server_flags: ODataServerFlags = ODataServerFlags()):
self.log = logging.getLogger('odata.context')
self.connection = ODataConnection(session=session, auth=auth, extra_headers=extra_headers)
self.server_flags = server_flags
Expand Down
5 changes: 5 additions & 0 deletions odata/enumtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ def __init__(self, name, enum_class=EnumType):
super(EnumTypeProperty, self).__init__(name)
self.enum_class = enum_class

def escape_value(self, value):
if self.enum_class.__module__:
return f"Microsoft.Dynamics.DataEntities.{self.enum_class.__name__}'{value.name}'"
return f"{self.enum_class.__name__}'{value.name}'"

def serialize(self, value):
return value.name

Expand Down
2 changes: 0 additions & 2 deletions odata/reflect-templates/enum_entity.mako
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


<%page args="name, entity"/>\
<% short_name = name.split(".")[-1] %>\
${short_name} = Enum("${short_name}", {\
Expand Down
2 changes: 1 addition & 1 deletion odata/reflector.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"FloatProperty": "float",
"BooleanProperty": "bool",
"UUIDProperty": "uuid.UUID",
"EnumTypeProperty": "str"
"EnumTypeProperty": "Enum"
}


Expand Down
1 change: 1 addition & 0 deletions odata/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class ODataService(object):
:param auth: Custom Requests auth object to use for credentials
:param console: Rich console instance to use for messages. If set to None a new console will be created. Console will inherit quiet flag from quiet_progress.
:param quiet_progress: Don't show any progress information while reflecting metadata and while other long duration tasks are running. Default is to show progress
:param server_flags: Server specific flags for an OData server
:raises ODataConnectionError: Fetching metadata failed. Server returned an HTTP error code
"""

Expand Down