iris-pex-embedded-python 3.5.0b4__py3-none-any.whl → 3.5.0b6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of iris-pex-embedded-python might be problematic. Click here for more details.

iop/_dispatch.py CHANGED
@@ -31,6 +31,9 @@ def dispatch_serializer(message: Any, is_generator: bool = False) -> Any:
31
31
  if message == "" or message is None:
32
32
  return message
33
33
 
34
+ if hasattr(message, '__iter__'):
35
+ raise TypeError("You may have tried to invoke a generator function without using the 'send_generator_request' method. Please use that method to handle generator functions.")
36
+
34
37
  raise TypeError("The message must be an instance of a class that is a subclass of Message or IRISObject %Persistent class.")
35
38
 
36
39
  def dispatch_deserializer(serial: Any) -> Any:
@@ -115,6 +118,10 @@ def get_handler_info(host: Any, method_name: str) -> Tuple[str, str] | None:
115
118
 
116
119
  param: Parameter = next(iter(params.values()))
117
120
  annotation = param.annotation
121
+
122
+ if isinstance(annotation, str):
123
+ # return it as is, assuming it's a fully qualified class name
124
+ return annotation, method_name
118
125
 
119
126
  if annotation == Parameter.empty or not isinstance(annotation, type):
120
127
  return None
iop/_message.py CHANGED
@@ -1,4 +1,4 @@
1
- from typing import Any
1
+ from typing import Any, Optional
2
2
 
3
3
  from pydantic import BaseModel
4
4
 
@@ -7,7 +7,11 @@ class _Message:
7
7
  This class has no properties or methods. Users subclass Message and add properties.
8
8
  The IOP framework provides the persistence to objects derived from the Message class.
9
9
  """
10
- pass
10
+ _iris_id: Optional[str] = None
11
+
12
+ def get_iris_id(self) -> Optional[str]:
13
+ """Get the IRIS ID of the message."""
14
+ return self._iris_id
11
15
 
12
16
  class _PickleMessage(_Message):
13
17
  """ The abstract class that is the superclass for persistent messages sent from one component to another.
@@ -19,12 +23,18 @@ class _PickleMessage(_Message):
19
23
  class _PydanticMessage(BaseModel):
20
24
  """Base class for Pydantic-based messages that can be serialized to IRIS."""
21
25
 
26
+ _iris_id: Optional[str] = None
27
+
22
28
  def __init__(self, **data: Any):
23
29
  super().__init__(**data)
24
30
 
25
- class _PydanticPickleMessage(BaseModel):
31
+ def get_iris_id(self) -> Optional[str]:
32
+ """Get the IRIS ID of the message."""
33
+ return self._iris_id
34
+
35
+ class _PydanticPickleMessage(_PydanticMessage):
26
36
  """Base class for Pydantic-based messages that can be serialized to IRIS."""
27
-
37
+
28
38
  def __init__(self, **data: Any):
29
39
  super().__init__(**data)
30
40
 
iop/_serialization.py CHANGED
@@ -26,19 +26,10 @@ class TempPydanticModel(BaseModel):
26
26
  class MessageSerializer:
27
27
  """Handles message serialization and deserialization."""
28
28
 
29
- @staticmethod
30
- def _convert_to_json_safe(obj: Any) -> Any:
31
- """Convert objects to JSON-safe format."""
32
- if isinstance(obj, BaseModel):
33
- return obj.model_dump_json()
34
- elif is_dataclass(obj) and isinstance(obj, _Message):
35
- return TempPydanticModel.model_validate(dataclass_to_dict(obj)).model_dump_json()
36
- else:
37
- raise SerializationError(f"Object {obj} must be a Pydantic model or dataclass Message")
38
-
39
29
  @staticmethod
40
30
  def serialize(message: Any, use_pickle: bool = False, is_generator:bool = False) -> Any:
41
31
  """Serializes a message to IRIS format."""
32
+ message = remove_iris_id(message)
42
33
  if use_pickle:
43
34
  return MessageSerializer._serialize_pickle(message, is_generator)
44
35
  return MessageSerializer._serialize_json(message, is_generator)
@@ -58,12 +49,34 @@ class MessageSerializer:
58
49
  else:
59
50
  msg.json = json_string
60
51
  return msg
52
+
53
+ @staticmethod
54
+ def _serialize_pickle(message: Any, is_generator: bool = False) -> Any:
55
+ """Serializes a message to IRIS format using pickle."""
56
+ message = remove_iris_id(message)
57
+ pickle_string = codecs.encode(pickle.dumps(message), "base64").decode()
58
+ if is_generator:
59
+ msg = _iris.get_iris().cls('IOP.Generator.Message.StartPickle')._New()
60
+ else:
61
+ msg = _iris.get_iris().cls('IOP.PickleMessage')._New()
62
+ msg.classname = f"{message.__class__.__module__}.{message.__class__.__name__}"
63
+ msg.jstr = _Utils.string_to_stream(pickle_string)
64
+ return msg
61
65
 
62
66
  @staticmethod
63
67
  def deserialize(serial: Any, use_pickle: bool = False) -> Any:
64
68
  if use_pickle:
65
- return MessageSerializer._deserialize_pickle(serial)
66
- return MessageSerializer._deserialize_json(serial)
69
+ msg=MessageSerializer._deserialize_pickle(serial)
70
+ else:
71
+ msg=MessageSerializer._deserialize_json(serial)
72
+
73
+ try:
74
+ iris_id = serial._Id()
75
+ msg._iris_id = iris_id if iris_id else None
76
+ except Exception as e:
77
+ pass
78
+
79
+ return msg
67
80
 
68
81
  @staticmethod
69
82
  def _deserialize_json(serial: Any) -> Any:
@@ -90,17 +103,6 @@ class MessageSerializer:
90
103
  except Exception as e:
91
104
  raise SerializationError(f"Failed to deserialize JSON: {str(e)}")
92
105
 
93
- @staticmethod
94
- def _serialize_pickle(message: Any, is_generator: bool = False) -> Any:
95
- pickle_string = codecs.encode(pickle.dumps(message), "base64").decode()
96
- if is_generator:
97
- msg = _iris.get_iris().cls('IOP.Generator.Message.StartPickle')._New()
98
- else:
99
- msg = _iris.get_iris().cls('IOP.PickleMessage')._New()
100
- msg.classname = f"{message.__class__.__module__}.{message.__class__.__name__}"
101
- msg.jstr = _Utils.string_to_stream(pickle_string)
102
- return msg
103
-
104
106
  @staticmethod
105
107
  def _deserialize_pickle(serial: Any) -> Any:
106
108
  string = _Utils.stream_to_string(serial.jstr)
@@ -112,6 +114,24 @@ class MessageSerializer:
112
114
  if j <= 0:
113
115
  raise SerializationError(f"Classname must include a module: {classname}")
114
116
  return classname[:j], classname[j+1:]
117
+
118
+ @staticmethod
119
+ def _convert_to_json_safe(obj: Any) -> Any:
120
+ """Convert objects to JSON-safe format."""
121
+ if isinstance(obj, BaseModel):
122
+ return obj.model_dump_json()
123
+ elif is_dataclass(obj) and isinstance(obj, _Message):
124
+ return TempPydanticModel.model_validate(dataclass_to_dict(obj)).model_dump_json()
125
+ else:
126
+ raise SerializationError(f"Object {obj} must be a Pydantic model or dataclass Message")
127
+
128
+
129
+ def remove_iris_id(message: Any) -> Any:
130
+ try:
131
+ del message._iris_id
132
+ except AttributeError:
133
+ pass
134
+ return message
115
135
 
116
136
  def dataclass_from_dict(klass: Type | Any, dikt: Dict) -> Any:
117
137
  """Converts a dictionary to a dataclass instance.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: iris_pex_embedded_python
3
- Version: 3.5.0b4
3
+ Version: 3.5.0b6
4
4
  Summary: Iris Interoperability based on Embedded Python
5
5
  Author-email: grongier <guillaume.rongier@intersystems.com>
6
6
  License: MIT License
@@ -39,17 +39,17 @@ iop/_common.py,sha256=W39gb-K7oh93YdxOIIud0TT64Z6dSogVT4Rpda7_IvU,13986
39
39
  iop/_debugpy.py,sha256=67BC1jxZx4MZfj65trYYnSJ_MVKMTv49n3CqqfgVQdk,4725
40
40
  iop/_decorators.py,sha256=LpK0AK4GIzXbPFSIw_x6zzM3FwsHvFjgQUh-MnqtTE8,2322
41
41
  iop/_director.py,sha256=dJ4uLs5JxBS1wc0OtL25HuaDi3Jh8M9JC5Ra366ic1g,11489
42
- iop/_dispatch.py,sha256=Z62grevFrqRobDmB6Sf1VG0HjHMMgAaKfOxNU4QfTjw,4121
42
+ iop/_dispatch.py,sha256=4LOF0v0e492B3NHuhLdPVAMNCDeFfyOhIjWDPC4bmAw,4499
43
43
  iop/_generator_request.py,sha256=I67JOjfsznN9JlS0bg_D05phcfSXqp6GJlCULJPXKvw,1284
44
44
  iop/_inbound_adapter.py,sha256=yG33VfJ2KxSDVxBTQTjFXqdX1fMEic1zxSAOhP5DqTk,1649
45
45
  iop/_iris.py,sha256=cw1mIKchXNlUJXSxwMhXYQr8DntJEO1hSPnLyJab10w,204
46
46
  iop/_log_manager.py,sha256=SHY2AUBSjh-qZbEHfe0j4c_S8PuU6JFjjmjEX6qnoC4,3407
47
- iop/_message.py,sha256=UUJauHBChQaL92Wp1EpYaz-G4N998PIv4RbdJofN6yg,1136
47
+ iop/_message.py,sha256=iM7LXdhYRGOBEAJu-VH1m9iKyMYtrScWcALc3khmCFY,1465
48
48
  iop/_message_validator.py,sha256=ooDFWp8XvqJWP91RDbkFgpA5V3LbNrQO6IMx2vSjoF8,1516
49
49
  iop/_outbound_adapter.py,sha256=cN7dkZyx9ED89yUGePsUYsUhlR3ze3w1JorCG8HvDCw,723
50
50
  iop/_private_session_duplex.py,sha256=c6Q0k-qnZi_JcIOdpUx1Edu44zVbUE2Kf2aCHM8Eq80,5202
51
51
  iop/_private_session_process.py,sha256=rvZFO6nWVwZtaEWJkSHyLTV-vhzDqQhsVi7INQLLwWI,1685
52
- iop/_serialization.py,sha256=k61wsrAui-GOIPdAXv4wpnpdyrWo-nyZ0HTBa5zWF4w,7232
52
+ iop/_serialization.py,sha256=C9-88bb6vC8A4ugQ3QqjahAbv7NjAD2sZy8_D-X0Ois,7721
53
53
  iop/_utils.py,sha256=yAvssj3O3p9mLVJ_RvDIuawyYNhOIm5WrK0SANaSIwU,21256
54
54
  iop/cls/IOP/BusinessOperation.cls,sha256=E4rnujZi3QFd3uLtZ5YjLiMU_FWoN1gkBe19kxmYO34,932
55
55
  iop/cls/IOP/BusinessProcess.cls,sha256=XJxzbiV0xokzRm-iI2Be5UIJLE3MlXr7W3WS_LkOCYs,3363
@@ -78,9 +78,9 @@ iop/cls/IOP/PrivateSession/Message/Start.cls,sha256=RsJLrhglrONBDGT0RqW2K9MDXa98
78
78
  iop/cls/IOP/PrivateSession/Message/Stop.cls,sha256=7g3gKFUjNg0WXBLuWnj-VnCs5G6hSE09YTzGEp0zbGc,1390
79
79
  iop/cls/IOP/Service/WSGI.cls,sha256=VLNCXEwmHW9dBnE51uGE1nvGX6T4HjhqePT3LVhsjAE,10440
80
80
  iop/wsgi/handlers.py,sha256=NrFLo_YbAh-x_PlWhAiWkQnUUN2Ss9HoEm63dDWCBpQ,2947
81
- iris_pex_embedded_python-3.5.0b4.dist-info/licenses/LICENSE,sha256=rZSiBFId_sfbJ6RL0GjjPX-InNLkNS9ou7eQsikciI8,1089
82
- iris_pex_embedded_python-3.5.0b4.dist-info/METADATA,sha256=WWYcgcEhhzbAbj3FKI4faBbTqisGyMXZepabAygnNNo,4415
83
- iris_pex_embedded_python-3.5.0b4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
84
- iris_pex_embedded_python-3.5.0b4.dist-info/entry_points.txt,sha256=pj-i4LSDyiSP6xpHlVjMCbg1Pik7dC3_sdGY3Yp9Vhk,38
85
- iris_pex_embedded_python-3.5.0b4.dist-info/top_level.txt,sha256=4p0q6hCATmYIVMVi3I8hOUcJE1kwzyBeHygWv_rGvrU,13
86
- iris_pex_embedded_python-3.5.0b4.dist-info/RECORD,,
81
+ iris_pex_embedded_python-3.5.0b6.dist-info/licenses/LICENSE,sha256=rZSiBFId_sfbJ6RL0GjjPX-InNLkNS9ou7eQsikciI8,1089
82
+ iris_pex_embedded_python-3.5.0b6.dist-info/METADATA,sha256=0UEPT7nywOnuI8RTD14oO24QL8ef_M1T6qgbDUl27Ns,4415
83
+ iris_pex_embedded_python-3.5.0b6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
84
+ iris_pex_embedded_python-3.5.0b6.dist-info/entry_points.txt,sha256=pj-i4LSDyiSP6xpHlVjMCbg1Pik7dC3_sdGY3Yp9Vhk,38
85
+ iris_pex_embedded_python-3.5.0b6.dist-info/top_level.txt,sha256=4p0q6hCATmYIVMVi3I8hOUcJE1kwzyBeHygWv_rGvrU,13
86
+ iris_pex_embedded_python-3.5.0b6.dist-info/RECORD,,