You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rh...@apache.org on 2010/01/05 19:19:38 UTC

svn commit: r896159 - in /qpid/trunk/qpid/python: Makefile examples/api/spout qpid/address.py qpid/concurrency.py qpid/messaging.py qpid/tests/address.py tests_0-9/queue.py

Author: rhs
Date: Tue Jan  5 18:19:37 2010
New Revision: 896159

URL: http://svn.apache.org/viewvc?rev=896159&view=rev
Log:
merged documentation and address changes from rnr branch

Modified:
    qpid/trunk/qpid/python/Makefile
    qpid/trunk/qpid/python/examples/api/spout   (contents, props changed)
    qpid/trunk/qpid/python/qpid/address.py
    qpid/trunk/qpid/python/qpid/concurrency.py   (props changed)
    qpid/trunk/qpid/python/qpid/messaging.py
    qpid/trunk/qpid/python/qpid/tests/address.py
    qpid/trunk/qpid/python/tests_0-9/queue.py   (props changed)

Modified: qpid/trunk/qpid/python/Makefile
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/Makefile?rev=896159&r1=896158&r2=896159&view=diff
==============================================================================
--- qpid/trunk/qpid/python/Makefile (original)
+++ qpid/trunk/qpid/python/Makefile Tue Jan  5 18:19:37 2010
@@ -50,7 +50,7 @@
 
 doc:
 	@mkdir -p $(BUILD)
-	PYTHONPATH=. epydoc qpid.messaging -o $(BUILD)/doc --no-private --no-sourcecode --include-log
+	PYTHONPATH=. epydoc -v qpid.messaging -o $(BUILD)/doc --no-private --no-sourcecode --include-log
 
 install: build
 	install -d $(PYTHON_LIB)

Modified: qpid/trunk/qpid/python/examples/api/spout
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/examples/api/spout?rev=896159&r1=896158&r2=896159&view=diff
==============================================================================
--- qpid/trunk/qpid/python/examples/api/spout (original)
+++ qpid/trunk/qpid/python/examples/api/spout Tue Jan  5 18:19:37 2010
@@ -43,8 +43,9 @@
 parser.add_option("-i", "--id", help="use the supplied id instead of generating one")
 parser.add_option("-r", "--reply-to", help="specify reply-to address")
 parser.add_option("-P", "--property", dest="properties", action="append", default=[],
-                  help="specify message property")
+                  metavar="NAME=VALUE", help="specify message property")
 parser.add_option("-M", "--map", dest="entries", action="append", default=[],
+                  metavar="KEY=VALUE",
                   help="specify map entry for message body")
 
 opts, args = parser.parse_args()

Propchange: qpid/trunk/qpid/python/examples/api/spout
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan  5 18:19:37 2010
@@ -0,0 +1 @@
+/qpid/branches/qpid.rnr/python/examples/api/spout:894071-896158

Modified: qpid/trunk/qpid/python/qpid/address.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/qpid/address.py?rev=896159&r1=896158&r2=896159&view=diff
==============================================================================
--- qpid/trunk/qpid/python/qpid/address.py (original)
+++ qpid/trunk/qpid/python/qpid/address.py Tue Jan  5 18:19:37 2010
@@ -102,8 +102,8 @@
 
     result = {}
     while True:
-      if self.matches(ID):
-        n, v = self.nameval()
+      if self.matches(NUMBER, STRING, ID, LBRACE, LBRACK):
+        n, v = self.keyval()
         result[n] = v
         if self.matches(COMMA):
           self.eat(COMMA)
@@ -114,16 +114,17 @@
       elif self.matches(RBRACE):
         break
       else:
-        raise ParseError(self.next(), ID, RBRACE)
+        raise ParseError(self.next(), NUMBER, STRING, ID, LBRACE, LBRACK,
+                         RBRACE)
 
     self.eat(RBRACE)
     return result
 
-  def nameval(self):
-    name = self.eat(ID).value
+  def keyval(self):
+    key = self.value()
     self.eat(COLON)
     val = self.value()
-    return (name, val)
+    return (key, val)
 
   def value(self):
     if self.matches(NUMBER, STRING, ID):

Propchange: qpid/trunk/qpid/python/qpid/concurrency.py
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan  5 18:19:37 2010
@@ -0,0 +1 @@
+/qpid/branches/qpid.rnr/python/qpid/concurrency.py:894071-896158

Modified: qpid/trunk/qpid/python/qpid/messaging.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/qpid/messaging.py?rev=896159&r1=896158&r2=896159&view=diff
==============================================================================
--- qpid/trunk/qpid/python/qpid/messaging.py (original)
+++ qpid/trunk/qpid/python/qpid/messaging.py Tue Jan  5 18:19:37 2010
@@ -22,8 +22,6 @@
 
 Areas that still need work:
 
-  - asynchronous send
-  - asynchronous error notification
   - definition of the arguments for L{Session.sender} and L{Session.receiver}
   - standard L{Message} properties
   - L{Message} content encoding
@@ -247,8 +245,180 @@
 
   """
   Sessions provide a linear context for sending and receiving
-  messages, and manage various Senders and Receivers.
-  """
+  L{Messages<Message>}. L{Messages<Message>} are sent and received
+  using the L{Sender.send} and L{Receiver.fetch} methods of the
+  L{Sender} and L{Receiver} objects associated with a Session.
+
+  Each L{Sender} and L{Receiver} is created by supplying either a
+  target or source address to the L{sender} and L{receiver} methods of
+  the Session. The address is supplied via a string syntax documented
+  below.
+
+  Addresses
+  =========
+
+  An address identifies a source or target for messages. In its
+  simplest form this is just a name. In general a target address may
+  also be used as a source address, however not all source addresses
+  may be used as a target, e.g. a source might additionally have some
+  filtering criteria that would not be present in a target.
+
+  A subject may optionally be specified along with the name. When an
+  address is used as a target, any subject specified in the address is
+  used as the default subject of outgoing messages for that target.
+  When an address is used as a source, any subject specified in the
+  address is pattern matched against the subject of available messages
+  as a filter for incoming messages from that source.
+
+  The options map contains additional information about the address
+  including:
+
+    - policies for automatically creating, and deleting the node to
+      which an address refers
+
+    - policies for asserting facts about the node to which an address
+      refers
+
+    - extension points that can be used for sender/receiver
+      configuration
+
+  Mapping to AMQP 0-10
+  --------------------
+  The name is resolved to either an exchange or a queue by querying
+  the broker.
+
+  The subject is set as a property on the message. Additionally, if
+  the name refers to an exchange, the routing key is set to the
+  subject.
+
+  Syntax
+  ------
+  The following regular expressions define the tokens used to parse
+  addresses::
+    LBRACE: \\{
+    RBRACE: \\}
+    LBRACK: \\[
+    RBRACK: \\]
+    COLON:  :
+    SEMI:   ;
+    SLASH:  /
+    COMMA:  ,
+    NUMBER: [+-]?[0-9]*\\.?[0-9]+
+    ID:     [a-zA-Z_](?:[a-zA-Z0-9_-]*[a-zA-Z0-9_])?
+    STRING: "(?:[^\\\\"]|\\\\.)*"|\'(?:[^\\\\\']|\\\\.)*\'
+    ESC:    \\\\[^ux]|\\\\x[0-9a-fA-F][0-9a-fA-F]|\\\\u[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]
+    SYM:    [.#*%@$^!+-]
+    WSPACE: [ \\n\\r\\t]+
+
+  The formal grammar for addresses is given below::
+    address = name [ "/" subject ] [ ";" options ]
+       name = ( part | quoted )+
+    subject = ( part | quoted | "/" )*
+     quoted = STRING / ESC
+       part = LBRACE / RBRACE / COLON / COMMA / NUMBER / ID / SYM
+    options = map
+        map = "{" ( keyval ( "," keyval )* )? "}"
+     keyval = ID ":" value
+      value = NUMBER / STRING / ID / map / list
+       list = "[" ( value ( "," value )* )? "]"
+
+  This grammar resuls in the following informal syntax::
+
+    <name> [ / <subject> ] [ ; <options> ]
+
+  Where options is::
+
+    { <key> : <value>, ... }
+
+  And values may be:
+    - numbers
+    - single, double, or non quoted strings
+    - maps (dictionaries)
+    - lists
+
+  Options
+  -------
+  The options map permits the following parameters::
+
+    <name> [ / <subject> ] {
+      create: <create-policy>,
+      delete: <delete-policy>,
+      assert: <assert-policy>,
+      node-properties: {
+        type: <node-type>,
+        durable: <node-durability>,
+        x-properties: {
+          bindings: ["<exchange>/<key>", ...],
+          <passthrough-key>: <passthrough-value>
+        }
+      }
+    }
+
+  The create, delete, and assert policies specify who should perfom
+  the associated action:
+
+   - I{always}: the action will always be performed
+   - I{sender}: the action will only be performed by the sender
+   - I{receiver}: the action will only be performed by the receiver
+   - I{never}: the action will never be performed (this is the default)
+
+  The node-type is one of:
+
+    - I{topic}: a topic node will default to the topic exchange,
+      x-properties may be used to specify other exchange types
+    - I{queue}: this is the default node-type
+
+  The x-properties map permits arbitrary additional keys and values to
+  be specified. These keys and values are passed through when creating
+  a node or asserting facts about an existing node. Any passthrough
+  keys and values that do not match a standard field of the underlying
+  exchange or queue declare command will be sent in the arguments map.
+
+  Examples
+  --------
+  A simple name resolves to any named node, usually a queue or a
+  topic::
+
+    my-queue-or-topic
+
+  A simple name with a subject will also resolve to a node, but the
+  presence of the subject will cause a sender using this address to
+  set the subject on outgoing messages, and receivers to filter based
+  on the subject::
+
+    my-queue-or-topic/my-subject
+
+  A subject pattern can be used and will cause filtering if used by
+  the receiver. If used for a sender, the literal value gets set as
+  the subject::
+
+    my-queue-or-topic/my-*
+
+  In all the above cases, the address is resolved to an existing node.
+  If you want the node to be auto-created, then you can do the
+  following. By default nonexistent nodes are assumed to be queues::
+
+    my-queue; {create: always}
+
+  You can customize the properties of the queue::
+
+    my-queue; {create: always, node-properties: {durable: True}}
+
+  You can create a topic instead if you want::
+
+    my-queue; {create: always, node-properties: {type: topic}}
+
+  You can assert that the address resolves to a node with particular
+  properties::
+
+    my-transient-topic; {
+      assert: always,
+      node-properties: {
+        type: topic,
+        durable: False
+      }
+    }
+ """
 
   def __init__(self, connection, name, transactional):
     self.connection = connection

Modified: qpid/trunk/qpid/python/qpid/tests/address.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/qpid/tests/address.py?rev=896159&r1=896158&r2=896159&view=diff
==============================================================================
--- qpid/trunk/qpid/python/qpid/tests/address.py (original)
+++ qpid/trunk/qpid/python/qpid/tests/address.py Tue Jan  5 18:19:37 2010
@@ -136,12 +136,13 @@
 
   def testBadOptions1(self):
     self.invalid("name/subject; {",
-                 "expecting (ID, RBRACE), got EOF line:1,15:name/subject; {")
+                 "expecting (NUMBER, STRING, ID, LBRACE, LBRACK, RBRACE), "
+                 "got EOF line:1,15:name/subject; {")
 
   def testBadOptions2(self):
     self.invalid("name/subject; { 3",
-                 "expecting (ID, RBRACE), got NUMBER('3') "
-                 "line:1,16:name/subject; { 3")
+                 "expecting COLON, got EOF "
+                 "line:1,17:name/subject; { 3")
 
   def testBadOptions3(self):
     self.invalid("name/subject; { key:",
@@ -160,7 +161,7 @@
 
   def testBadOptions6(self):
     self.invalid("name/subject; { key: value,",
-                 "expecting (ID, RBRACE), got EOF "
+                 "expecting (NUMBER, STRING, ID, LBRACE, LBRACK, RBRACE), got EOF "
                  "line:1,27:name/subject; { key: value,")
 
   def testBadOptions7(self):
@@ -197,3 +198,14 @@
   def testBadList4(self):
     self.invalid("name/subject; { key: [ 1 2 ] }", "expecting (COMMA, RBRACK), "
                  "got NUMBER('2') line:1,25:name/subject; { key: [ 1 2 ] }")
+
+  def testMap1(self):
+    self.valid("name/subject; { 'key': value }",
+               "name", "subject", {"key": "value"})
+
+  def testMap2(self):
+    self.valid("name/subject; { 1: value }", "name", "subject", {1: "value"})
+
+  def testMap3(self):
+    self.valid('name/subject; { "foo.bar": value }',
+               "name", "subject", {"foo.bar": "value"})

Propchange: qpid/trunk/qpid/python/tests_0-9/queue.py
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan  5 18:19:37 2010
@@ -0,0 +1 @@
+/qpid/branches/qpid.rnr/python/tests_0-9/queue.py:894071-896158



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org