diff --git a/odata/context.py b/odata/context.py index f98bb52..4e9c02c 100644 --- a/odata/context.py +++ b/odata/context.py @@ -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 diff --git a/odata/enumtype.py b/odata/enumtype.py index 8c032fa..59f8613 100644 --- a/odata/enumtype.py +++ b/odata/enumtype.py @@ -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 diff --git a/odata/reflect-templates/enum_entity.mako b/odata/reflect-templates/enum_entity.mako index 23cb22b..bcc2f7c 100644 --- a/odata/reflect-templates/enum_entity.mako +++ b/odata/reflect-templates/enum_entity.mako @@ -1,5 +1,3 @@ - - <%page args="name, entity"/>\ <% short_name = name.split(".")[-1] %>\ ${short_name} = Enum("${short_name}", {\ diff --git a/odata/reflector.py b/odata/reflector.py index e2e5f23..138c8d4 100644 --- a/odata/reflector.py +++ b/odata/reflector.py @@ -94,7 +94,7 @@ "FloatProperty": "float", "BooleanProperty": "bool", "UUIDProperty": "uuid.UUID", - "EnumTypeProperty": "str" + "EnumTypeProperty": "Enum" } diff --git a/odata/service.py b/odata/service.py index dc2aa68..dc7e03a 100644 --- a/odata/service.py +++ b/odata/service.py @@ -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 """