astitcher commented on a change in pull request #192: Changed Python API to 
better handle strings where symbo…
URL: https://github.com/apache/qpid-proton/pull/192#discussion_r334040232
 
 

 ##########
 File path: python/proton/_message.py
 ##########
 @@ -430,6 +430,31 @@ def _set_reply_to_group_id(self, value):
         :raise: :exc:`MessageException` if there is any Proton error when 
using the setter.        
         """)
 
+    def _get_instructions(self):
+        return self.instruction_dict
+    def _set_instructions(self, instructions):
+        if isinstance(instructions, dict):
+            self.instruction_dict = AnnotationDict(instructions, throw=False)
+        else:
+            self.instruction_dict = instructions
+    instructions = property(_get_instructions, _set_instructions, doc="""
+    Delivery annotations as a dictionary of key/values. The AMQP 1.0
+    specification restricts this dictionary to have keys that are either
+    :class:`symbol` or :class:`ulong` types. It is possible to use
+    the special ``dict`` subclass :class:`AnnotationDict` as it
+    will by default enforce these restrictions on construction. In addition,
+    if a string type is used, it will be silently converted into the
+    required symbol.
+
+        >>> from proton import symbol, ulong, Message, AnnotationDict
+        >>> msg = Message()
+        >>> msg.instructions = AnnotationDict({'one':1, symbol('two'):2, 
ulong(3):'three'})
+        >>> msg.instructions
+        AnnotationDict({symbol('one'): 1, symbol('two'): 2, ulong(3): 'three'})
+
+    :type: :class:`AnnotationDict`. Any ``dict`` with :class:`ulong` or 
:class:`symbol` keys.
+    """)
+
 
 Review comment:
   FWIW it's also contrary to the usual PYthon formatting standard PEP8 - I 
recommend you use an editor that has an automatic check or run the code through 
pylint or similar (flake8 pep8 ...).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to