Added: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/recurring_timer.py
URL: 
http://svn.apache.org/viewvc/qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/recurring_timer.py?rev=1681791&view=auto
==============================================================================
--- 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/recurring_timer.py
 (added)
+++ 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/recurring_timer.py
 Tue May 26 16:24:06 2015
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+from proton.reactor import Container, Handler
+
+class Recurring(Handler):
+    def __init__(self, period):
+        self.period = period
+
+    def on_reactor_init(self, event):
+        self.container = event.reactor
+        self.container.schedule(self.period, self)
+
+    def on_timer_task(self, event):
+        print "Tick..."
+        self.container.schedule(self.period, self)
+
+try:
+    container = Container(Recurring(1.0))
+    container.run()
+except KeyboardInterrupt:
+    container.stop()
+    print
+
+

Propchange: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/recurring_timer.py
------------------------------------------------------------------------------
    svn:executable = *

Added: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/recurring_timer_tornado.py
URL: 
http://svn.apache.org/viewvc/qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/recurring_timer_tornado.py?rev=1681791&view=auto
==============================================================================
--- 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/recurring_timer_tornado.py
 (added)
+++ 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/recurring_timer_tornado.py
 Tue May 26 16:24:06 2015
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import time
+from proton.reactor import Handler
+from proton_tornado import TornadoLoop
+
+class Recurring(Handler):
+    def __init__(self, period):
+        self.period = period
+
+    def on_start(self, event):
+        self.container = event.container
+        self.container.schedule(time.time() + self.period, subject=self)
+
+    def on_timer(self, event):
+        print "Tick..."
+        self.container.schedule(time.time() + self.period, subject=self)
+
+try:
+    container = TornadoLoop(Recurring(1.0))
+    container.run()
+except KeyboardInterrupt:
+    container.stop()
+    print
+
+

Propchange: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/recurring_timer_tornado.py
------------------------------------------------------------------------------
    svn:executable = *

Added: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/selected_recv.py
URL: 
http://svn.apache.org/viewvc/qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/selected_recv.py?rev=1681791&view=auto
==============================================================================
--- 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/selected_recv.py
 (added)
+++ 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/selected_recv.py
 Tue May 26 16:24:06 2015
@@ -0,0 +1,40 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+from proton.reactor import Container, Selector
+from proton.handlers import MessagingHandler
+
+class Recv(MessagingHandler):
+    def __init__(self):
+        super(Recv, self).__init__()
+
+    def on_start(self, event):
+        conn = event.container.connect("localhost:5672")
+        event.container.create_receiver(conn, "examples", 
options=Selector(u"colour = 'green'"))
+
+    def on_message(self, event):
+        print event.message.body
+
+try:
+    Container(Recv()).run()
+except KeyboardInterrupt: pass
+
+
+

Propchange: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/selected_recv.py
------------------------------------------------------------------------------
    svn:executable = *

Added: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/server.py
URL: 
http://svn.apache.org/viewvc/qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/server.py?rev=1681791&view=auto
==============================================================================
--- qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/server.py 
(added)
+++ qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/server.py 
Tue May 26 16:24:06 2015
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+from proton import Message
+from proton.handlers import MessagingHandler
+from proton.reactor import Container
+
+class Server(MessagingHandler):
+    def __init__(self, url, address):
+        super(Server, self).__init__()
+        self.url = url
+        self.address = address
+        self.senders = {}
+
+    def on_start(self, event):
+        print "Listening on", self.url
+        self.container = event.container
+        self.conn = event.container.connect(self.url)
+        self.receiver = event.container.create_receiver(self.conn, 
self.address)
+        self.relay = None
+
+    def on_connection_opened(self, event):
+        if event.connection.remote_offered_capabilities and 'ANONYMOUS-RELAY' 
in event.connection.remote_offered_capabilities:
+            self.relay = self.container.create_sender(self.conn, None)
+
+    def on_message(self, event):
+        print "Received", event.message
+        sender = self.relay or self.senders.get(event.message.reply_to)
+        if not sender:
+            sender = self.container.create_sender(self.conn, 
event.message.reply_to)
+            self.senders[event.message.reply_to] = sender
+        sender.send(Message(address=event.message.reply_to, 
body=event.message.body.upper(),
+                            correlation_id=event.message.correlation_id))
+
+try:
+    Container(Server("0.0.0.0:5672", "examples")).run()
+except KeyboardInterrupt: pass
+
+
+

Propchange: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/server.py
------------------------------------------------------------------------------
    svn:executable = *

Added: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/server_direct.py
URL: 
http://svn.apache.org/viewvc/qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/server_direct.py?rev=1681791&view=auto
==============================================================================
--- 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/server_direct.py
 (added)
+++ 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/server_direct.py
 Tue May 26 16:24:06 2015
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+from proton import generate_uuid, Message
+from proton.handlers import MessagingHandler
+from proton.reactor import Container
+
+class Server(MessagingHandler):
+    def __init__(self, url):
+        super(Server, self).__init__()
+        self.url = url
+        self.senders = {}
+
+    def on_start(self, event):
+        print "Listening on", self.url
+        self.container = event.container
+        self.acceptor = event.container.listen(self.url)
+
+    def on_link_opening(self, event):
+        if event.link.is_sender:
+            if event.link.remote_source and event.link.remote_source.dynamic:
+                event.link.source.address = str(generate_uuid())
+                self.senders[event.link.source.address] = event.link
+            elif event.link.remote_target and event.link.remote_target.address:
+                event.link.target.address = event.link.remote_target.address
+                self.senders[event.link.remote_target.address] = event.link
+            elif event.link.remote_source:
+                event.link.source.address = event.link.remote_source.address
+        elif event.link.remote_target:
+            event.link.target.address = event.link.remote_target.address
+
+    def on_message(self, event):
+        print "Received", event.message
+        sender = self.senders.get(event.message.reply_to)
+        if not sender:
+            print "No link for reply"
+            return
+        sender.send(Message(address=event.message.reply_to, 
body=event.message.body.upper(),
+                            correlation_id=event.message.correlation_id))
+
+try:
+    Container(Server("0.0.0.0:8888")).run()
+except KeyboardInterrupt: pass
+
+
+

Propchange: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/server_direct.py
------------------------------------------------------------------------------
    svn:executable = *

Added: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/server_tx.py
URL: 
http://svn.apache.org/viewvc/qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/server_tx.py?rev=1681791&view=auto
==============================================================================
--- 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/server_tx.py 
(added)
+++ 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/server_tx.py 
Tue May 26 16:24:06 2015
@@ -0,0 +1,78 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+from proton import Message
+from proton.reactor import Container
+from proton.handlers import MessagingHandler, TransactionHandler
+
+class TxRequest(TransactionHandler):
+    def __init__(self, response, sender, request_delivery):
+        super(TxRequest, self).__init__()
+        self.response = response
+        self.sender = sender
+        self.request_delivery = request_delivery
+
+    def on_transaction_declared(self, event):
+        event.transaction.send(self.sender, self.response)
+        event.transaction.accept(self.request_delivery)
+        event.transaction.commit()
+
+    def on_transaction_committed(self, event):
+        print "Request processed successfully"
+
+    def on_transaction_aborted(self, event):
+        print "Request processing aborted"
+
+
+class TxServer(MessagingHandler):
+    def __init__(self, host, address):
+        super(TxServer, self).__init__(auto_accept=False)
+        self.host = host
+        self.address = address
+
+    def on_start(self, event):
+        self.container = event.container
+        self.conn = event.container.connect(self.host, reconnect=False)
+        self.receiver = event.container.create_receiver(self.conn, 
self.address)
+        self.senders = {}
+        self.relay = None
+
+    def on_message(self, event):
+        sender = self.relay
+        if not sender:
+            sender = self.senders.get(event.message.reply_to)
+        if not sender:
+            sender = self.container.create_sender(self.conn, 
event.message.reply_to)
+            self.senders[event.message.reply_to] = sender
+
+        response = Message(address=event.message.reply_to, 
body=event.message.body.upper(),
+                           correlation_id=event.message.correlation_id)
+        self.container.declare_transaction(self.conn, 
handler=TxRequest(response, sender, event.delivery))
+
+    def on_connection_open(self, event):
+        if event.connection.remote_offered_capabilities and 'ANONYMOUS-RELAY' 
in event.connection.remote_offered_capabilities:
+            self.relay = self.container.create_sender(self.conn, None)
+
+try:
+    Container(TxServer("localhost:5672", "examples")).run()
+except KeyboardInterrupt: pass
+
+
+

Propchange: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/server_tx.py
------------------------------------------------------------------------------
    svn:executable = *

Added: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/simple_recv.py
URL: 
http://svn.apache.org/viewvc/qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/simple_recv.py?rev=1681791&view=auto
==============================================================================
--- 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/simple_recv.py 
(added)
+++ 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/simple_recv.py 
Tue May 26 16:24:06 2015
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import optparse
+from proton.handlers import MessagingHandler
+from proton.reactor import Container
+
+class Recv(MessagingHandler):
+    def __init__(self, url, count):
+        super(Recv, self).__init__()
+        self.url = url
+        self.expected = count
+        self.received = 0
+
+    def on_start(self, event):
+        event.container.create_receiver(self.url)
+
+    def on_message(self, event):
+        if event.message.id and event.message.id < self.received:
+            # ignore duplicate message
+            return
+        if self.expected == 0 or self.received < self.expected:
+            print event.message.body
+            self.received += 1
+            if self.received == self.expected:
+                event.receiver.close()
+                event.connection.close()
+
+parser = optparse.OptionParser(usage="usage: %prog [options]")
+parser.add_option("-a", "--address", default="localhost:5672/examples",
+                  help="address from which messages are received (default 
%default)")
+parser.add_option("-m", "--messages", type="int", default=100,
+                  help="number of messages to receive; 0 receives indefinitely 
(default %default)")
+opts, args = parser.parse_args()
+
+try:
+    Container(Recv(opts.address, opts.messages)).run()
+except KeyboardInterrupt: pass
+
+
+

Propchange: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/simple_recv.py
------------------------------------------------------------------------------
    svn:executable = *

Added: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/simple_send.py
URL: 
http://svn.apache.org/viewvc/qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/simple_send.py?rev=1681791&view=auto
==============================================================================
--- 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/simple_send.py 
(added)
+++ 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/simple_send.py 
Tue May 26 16:24:06 2015
@@ -0,0 +1,62 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import optparse
+from proton import Message
+from proton.handlers import MessagingHandler
+from proton.reactor import Container
+
+class Send(MessagingHandler):
+    def __init__(self, url, messages):
+        super(Send, self).__init__()
+        self.url = url
+        self.sent = 0
+        self.confirmed = 0
+        self.total = messages
+
+    def on_start(self, event):
+        event.container.create_sender(self.url)
+
+    def on_sendable(self, event):
+        while event.sender.credit and self.sent < self.total:
+            msg = Message(id=(self.sent+1), body={'sequence':(self.sent+1)})
+            event.sender.send(msg)
+            self.sent += 1
+
+    def on_accepted(self, event):
+        self.confirmed += 1
+        if self.confirmed == self.total:
+            print "all messages confirmed"
+            event.connection.close()
+
+    def on_disconnected(self, event):
+        self.sent = self.confirmed
+
+parser = optparse.OptionParser(usage="usage: %prog [options]",
+                               description="Send messages to the supplied 
address.")
+parser.add_option("-a", "--address", default="localhost:5672/examples",
+                  help="address to which messages are sent (default %default)")
+parser.add_option("-m", "--messages", type="int", default=100,
+                  help="number of messages to send (default %default)")
+opts, args = parser.parse_args()
+
+try:
+    Container(Send(opts.address, opts.messages)).run()
+except KeyboardInterrupt: pass

Propchange: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/simple_send.py
------------------------------------------------------------------------------
    svn:executable = *

Added: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/sync_client.py
URL: 
http://svn.apache.org/viewvc/qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/sync_client.py?rev=1681791&view=auto
==============================================================================
--- 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/sync_client.py 
(added)
+++ 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/sync_client.py 
Tue May 26 16:24:06 2015
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+"""
+Demonstrates the client side of the synchronous request-response pattern
+(also known as RPC or Remote Procecure Call) using proton.
+
+"""
+
+import optparse
+from proton import Message, Url, ConnectionException, Timeout
+from proton.utils import SyncRequestResponse, BlockingConnection
+from proton.handlers import IncomingMessageHandler
+import sys
+
+parser = optparse.OptionParser(usage="usage: %prog [options]",
+                               description="Send requests to the supplied 
address and print responses.")
+parser.add_option("-a", "--address", default="localhost:5672/examples",
+                  help="address to which messages are sent (default %default)")
+parser.add_option("-t", "--timeout", type="float", default=5,
+                  help="Give up after this time out (default %default)")
+opts, args = parser.parse_args()
+
+url = Url(opts.address)
+client = SyncRequestResponse(BlockingConnection(url, timeout=opts.timeout), 
url.path)
+
+try:
+    REQUESTS= ["Twas brillig, and the slithy toves",
+               "Did gire and gymble in the wabe.",
+               "All mimsy were the borogroves,",
+               "And the mome raths outgrabe."]
+    for request in REQUESTS:
+        response = client.call(Message(body=request))
+        print "%s => %s" % (request, response.body)
+finally:
+    client.connection.close()
+

Propchange: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/sync_client.py
------------------------------------------------------------------------------
    svn:executable = *

Added: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/test_examples.py
URL: 
http://svn.apache.org/viewvc/qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/test_examples.py?rev=1681791&view=auto
==============================================================================
--- 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/test_examples.py
 (added)
+++ 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/test_examples.py
 Tue May 26 16:24:06 2015
@@ -0,0 +1,130 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import subprocess
+import time
+import unittest
+
+class ExamplesTest(unittest.TestCase):
+    def test_helloworld(self, example="helloworld.py"):
+        p = subprocess.Popen([example], stderr=subprocess.STDOUT, 
stdout=subprocess.PIPE)
+        p.wait()
+        output = [l.strip() for l in p.stdout]
+        self.assertEqual(output, ['Hello World!'])
+
+    def test_helloworld_direct(self):
+        self.test_helloworld('helloworld_direct.py')
+
+    def test_helloworld_blocking(self):
+        self.test_helloworld('helloworld_blocking.py')
+
+    def test_helloworld_tornado(self):
+        self.test_helloworld('helloworld_tornado.py')
+
+    def test_helloworld_direct_tornado(self):
+        self.test_helloworld('helloworld_direct_tornado.py')
+
+    def test_simple_send_recv(self, recv='simple_recv.py', 
send='simple_send.py'):
+        r = subprocess.Popen([recv], stderr=subprocess.STDOUT, 
stdout=subprocess.PIPE)
+        s = subprocess.Popen([send], stderr=subprocess.STDOUT, 
stdout=subprocess.PIPE)
+        s.wait()
+        r.wait()
+        actual = [l.strip() for l in r.stdout]
+        expected = ["{'sequence': %iL}" % (i+1) for i in range(100)]
+        self.assertEqual(actual, expected)
+
+    def test_client_server(self, client=['client.py'], server=['server.py'], 
sleep=0):
+        s = subprocess.Popen(server, stderr=subprocess.STDOUT, 
stdout=subprocess.PIPE)
+        if sleep:
+            time.sleep(sleep)
+        c = subprocess.Popen(client, stderr=subprocess.STDOUT, 
stdout=subprocess.PIPE)
+        c.wait()
+        s.terminate()
+        actual = [l.strip() for l in c.stdout]
+        inputs = ["Twas brillig, and the slithy toves",
+                    "Did gire and gymble in the wabe.",
+                    "All mimsy were the borogroves,",
+                    "And the mome raths outgrabe."]
+        expected = ["%s => %s" % (l, l.upper()) for l in inputs]
+        self.assertEqual(actual, expected)
+
+    def test_sync_client_server(self):
+        self.test_client_server(client=['sync_client.py'])
+
+    def test_client_server_tx(self):
+        self.test_client_server(server=['server_tx.py'])
+
+    def test_sync_client_server_tx(self):
+        self.test_client_server(client=['sync_client.py'], 
server=['server_tx.py'])
+
+    def test_client_server_direct(self):
+        self.test_client_server(client=['client.py', '-a', 
'localhost:8888/examples'], server=['server_direct.py'], sleep=0.5)
+
+    def test_sync_client_server_direct(self):
+        self.test_client_server(client=['sync_client.py', '-a', 
'localhost:8888/examples'], server=['server_direct.py'], sleep=0.5)
+
+    def test_db_send_recv(self):
+        self.maxDiff = None
+        # setup databases
+        subprocess.check_call(['db_ctrl.py', 'init', './src_db'])
+        subprocess.check_call(['db_ctrl.py', 'init', './dst_db'])
+        fill = subprocess.Popen(['db_ctrl.py', 'insert', './src_db'], 
stdin=subprocess.PIPE, stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
+        for i in range(100):
+            fill.stdin.write("Message-%i\n" % (i+1))
+        fill.stdin.close()
+        fill.wait()
+        # run send and recv
+        r = subprocess.Popen(['db_recv.py', '-m', '100'], 
stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
+        s = subprocess.Popen(['db_send.py', '-m', '100'], 
stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
+        s.wait()
+        r.wait()
+        # verify output of receive
+        actual = [l.strip() for l in r.stdout]
+        expected = ["inserted message %i" % (i+1) for i in range(100)]
+        self.assertEqual(actual, expected)
+        # verify state of databases
+        v = subprocess.Popen(['db_ctrl.py', 'list', './dst_db'], 
stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
+        v.wait()
+        expected = ["(%i, u'Message-%i')" % ((i+1), (i+1)) for i in range(100)]
+        actual = [l.strip() for l in v.stdout]
+        self.assertEqual(actual, expected)
+
+    def test_tx_send_tx_recv(self):
+        self.test_simple_send_recv(recv='tx_recv.py', send='tx_send.py')
+
+    def test_simple_send_direct_recv(self):
+        self.maxDiff = None
+        r = subprocess.Popen(['direct_recv.py', '-a', 'localhost:8888'], 
stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
+        time.sleep(0.5)
+        s = subprocess.Popen(['simple_send.py', '-a', 'localhost:8888'], 
stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
+        s.wait()
+        r.wait()
+        actual = [l.strip() for l in r.stdout]
+        expected = ["{'sequence': %iL}" % (i+1) for i in range(100)]
+        self.assertEqual(actual, expected)
+
+    def test_direct_send_simple_recv(self):
+        s = subprocess.Popen(['direct_send.py', '-a', 'localhost:8888'], 
stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
+        time.sleep(0.5)
+        r = subprocess.Popen(['simple_recv.py', '-a', 'localhost:8888'], 
stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
+        r.wait()
+        s.wait()
+        actual = [l.strip() for l in r.stdout]
+        expected = ["{'sequence': %iL}" % (i+1) for i in range(100)]
+        self.assertEqual(actual, expected)

Propchange: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/test_examples.py
------------------------------------------------------------------------------
    svn:executable = *

Added: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/tx_recv.py
URL: 
http://svn.apache.org/viewvc/qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/tx_recv.py?rev=1681791&view=auto
==============================================================================
--- qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/tx_recv.py 
(added)
+++ qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/tx_recv.py 
Tue May 26 16:24:06 2015
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import optparse
+from proton import Url
+from proton.reactor import Container
+from proton.handlers import MessagingHandler, TransactionHandler
+
+class TxRecv(MessagingHandler, TransactionHandler):
+    def __init__(self, url, messages, batch_size):
+        super(TxRecv, self).__init__(prefetch=0, auto_accept=False)
+        self.url = Url(url)
+        self.expected = messages
+        self.batch_size = batch_size
+        self.current_batch = 0
+        self.committed = 0
+
+    def on_start(self, event):
+        self.container = event.container
+        self.conn = self.container.connect(self.url)
+        self.receiver = self.container.create_receiver(self.conn, 
self.url.path)
+        self.container.declare_transaction(self.conn, handler=self)
+        self.transaction = None
+
+    def on_message(self, event):
+        print event.message.body
+        self.transaction.accept(event.delivery)
+        self.current_batch += 1
+        if self.current_batch == self.batch_size:
+            self.transaction.commit()
+            self.transaction = None
+
+    def on_transaction_declared(self, event):
+        self.receiver.flow(self.batch_size)
+        self.transaction = event.transaction
+
+    def on_transaction_committed(self, event):
+        self.committed += self.current_batch
+        self.current_batch = 0
+        if self.expected == 0 or self.committed < self.expected:
+            self.container.declare_transaction(self.conn, handler=self)
+        else:
+            event.connection.close()
+
+    def on_disconnected(self, event):
+        self.current_batch = 0
+
+parser = optparse.OptionParser(usage="usage: %prog [options]")
+parser.add_option("-a", "--address", default="localhost:5672/examples",
+                  help="address from which messages are received (default 
%default)")
+parser.add_option("-m", "--messages", type="int", default=100,
+                  help="number of messages to receive; 0 receives indefinitely 
(default %default)")
+parser.add_option("-b", "--batch-size", type="int", default=10,
+                  help="number of messages in each transaction (default 
%default)")
+opts, args = parser.parse_args()
+
+try:
+    Container(TxRecv(opts.address, opts.messages, opts.batch_size)).run()
+except KeyboardInterrupt: pass
+
+
+

Propchange: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/tx_recv.py
------------------------------------------------------------------------------
    svn:executable = *

Added: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/tx_recv_interactive.py
URL: 
http://svn.apache.org/viewvc/qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/tx_recv_interactive.py?rev=1681791&view=auto
==============================================================================
--- 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/tx_recv_interactive.py
 (added)
+++ 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/tx_recv_interactive.py
 Tue May 26 16:24:06 2015
@@ -0,0 +1,83 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import sys
+import threading
+from proton.reactor import ApplicationEvent, Container
+from proton.handlers import MessagingHandler, TransactionHandler
+
+class TxRecv(MessagingHandler, TransactionHandler):
+    def __init__(self):
+        super(TxRecv, self).__init__(prefetch=0, auto_accept=False)
+
+    def on_start(self, event):
+        self.container = event.container
+        self.conn = self.container.connect("localhost:5672")
+        self.receiver = self.container.create_receiver(self.conn, "examples")
+        self.container.declare_transaction(self.conn, handler=self, 
settle_before_discharge=True)
+        self.transaction = None
+
+    def on_message(self, event):
+        print event.message.body
+        self.transaction.accept(event.delivery)
+
+    def on_transaction_declared(self, event):
+        self.transaction = event.transaction
+        print "transaction declared"
+
+    def on_transaction_committed(self, event):
+        print "transaction committed"
+        self.container.declare_transaction(self.conn, handler=self)
+
+    def on_transaction_aborted(self, event):
+        print "transaction aborted"
+        self.container.declare_transaction(self.conn, handler=self)
+
+    def on_commit(self, event):
+        self.transaction.commit()
+
+    def on_abort(self, event):
+        self.transaction.abort()
+
+    def on_fetch(self, event):
+        self.receiver.flow(1)
+
+    def on_quit(self, event):
+        c = self.receiver.connection
+        self.receiver.close()
+        c.close()
+
+try:
+    reactor = Container(TxRecv())
+    events = reactor.get_event_trigger()
+    thread = threading.Thread(target=reactor.run)
+    thread.daemon=True
+    thread.start()
+
+    print "Enter 'fetch', 'commit' or 'abort'"
+    while True:
+        line = sys.stdin.readline()
+        if line:
+            events.trigger(ApplicationEvent(line.strip()))
+        else:
+            break
+except KeyboardInterrupt: pass
+
+

Propchange: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/tx_recv_interactive.py
------------------------------------------------------------------------------
    svn:executable = *

Added: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/tx_send.py
URL: 
http://svn.apache.org/viewvc/qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/tx_send.py?rev=1681791&view=auto
==============================================================================
--- qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/tx_send.py 
(added)
+++ qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/tx_send.py 
Tue May 26 16:24:06 2015
@@ -0,0 +1,88 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import optparse
+from proton import Message, Url
+from proton.reactor import Container
+from proton.handlers import MessagingHandler, TransactionHandler
+
+class TxSend(MessagingHandler, TransactionHandler):
+    def __init__(self, url, messages, batch_size):
+        super(TxSend, self).__init__()
+        self.url = Url(url)
+        self.current_batch = 0
+        self.committed = 0
+        self.confirmed = 0
+        self.total = messages
+        self.batch_size = batch_size
+
+    def on_start(self, event):
+        self.container = event.container
+        self.conn = self.container.connect(self.url)
+        self.sender = self.container.create_sender(self.conn, self.url.path)
+        self.container.declare_transaction(self.conn, handler=self)
+        self.transaction = None
+
+    def on_transaction_declared(self, event):
+        self.transaction = event.transaction
+        self.send()
+
+    def on_sendable(self, event):
+        self.send()
+
+    def send(self):
+        while self.transaction and self.sender.credit and (self.committed + 
self.current_batch) < self.total:
+            seq = self.committed + self.current_batch + 1
+            msg = Message(id=seq, body={'sequence':seq})
+            self.transaction.send(self.sender, msg)
+            self.current_batch += 1
+            if self.current_batch == self.batch_size:
+                self.transaction.commit()
+                self.transaction = None
+
+    def on_accepted(self, event):
+        if event.sender == self.sender:
+            self.confirmed += 1
+
+    def on_transaction_committed(self, event):
+        self.committed += self.current_batch
+        if self.committed == self.total:
+            print "all messages committed"
+            event.connection.close()
+        else:
+            self.current_batch = 0
+            self.container.declare_transaction(self.conn, handler=self)
+
+    def on_disconnected(self, event):
+        self.current_batch = 0
+
+parser = optparse.OptionParser(usage="usage: %prog [options]",
+                               description="Send messages transactionally to 
the supplied address.")
+parser.add_option("-a", "--address", default="localhost:5672/examples",
+                  help="address to which messages are sent (default %default)")
+parser.add_option("-m", "--messages", type="int", default=100,
+                  help="number of messages to send (default %default)")
+parser.add_option("-b", "--batch-size", type="int", default=10,
+                  help="number of messages in each transaction (default 
%default)")
+opts, args = parser.parse_args()
+
+try:
+    Container(TxSend(opts.address, opts.messages, opts.batch_size)).run()
+except KeyboardInterrupt: pass

Propchange: 
qpid/site/docs/releases/qpid-proton-0.9.1/proton/python/examples/tx_send.py
------------------------------------------------------------------------------
    svn:executable = *

Modified: qpid/site/input/documentation.md
URL: 
http://svn.apache.org/viewvc/qpid/site/input/documentation.md?rev=1681791&r1=1681790&r2=1681791&view=diff
==============================================================================
--- qpid/site/input/documentation.md (original)
+++ qpid/site/input/documentation.md Tue May 26 16:24:06 2015
@@ -17,8 +17,9 @@ The documentation on this page is for ou
  - [Overview](@site-url@/proton/index.html)
  - [C API reference](@current-proton-release-url@/proton/c/api/files.html)
  - [C examples](@current-proton-release-url@/messenger/c/examples/index.html)
+ - [Python 
tutorial](@current-proton-release-url@/proton/python/tutorial/tutorial.html)
  - [Python API 
reference](@current-proton-release-url@/proton/python/api/index.html)
- - [Python 
examples](@current-proton-release-url@/messenger/python/examples/index.html)
+ - [Python 
examples](@current-proton-release-url@/proton/python/examples/index.html)
 
 </section>
 <section markdown="1">

Modified: qpid/site/input/proton/index.md
URL: 
http://svn.apache.org/viewvc/qpid/site/input/proton/index.md?rev=1681791&r1=1681790&r2=1681791&view=diff
==============================================================================
--- qpid/site/input/proton/index.md (original)
+++ qpid/site/input/proton/index.md Tue May 26 16:24:06 2015
@@ -49,8 +49,10 @@ platform, environment, or language. More
 
  - [C API reference](@current-proton-release-url@/proton/c/api/files.html)
  - [Java API 
reference](@current-proton-release-url@/proton/java/api/index.html)
+ - [Python 
tutorial](@current-proton-release-url@/proton/python/tutorial/tutorial.html)
  - [Python API 
reference](@current-proton-release-url@/proton/python/api/index.html)
- - [Installing Qpid 
Proton](https://git-wip-us.apache.org/repos/asf?p=qpid-proton.git;a=blob_plain;f=README;hb=@current-proton-release@)
+ - [Python 
examples](@current-proton-release-url@/proton/python/examples/index.html)
+ - [Installing Qpid 
Proton](https://git-wip-us.apache.org/repos/asf?p=qpid-proton.git;a=blob_plain;f=INSTALL.md;hb=@current-proton-release@)
 
 </div>
 </div>

Added: qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/README
URL: 
http://svn.apache.org/viewvc/qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/README?rev=1681791&view=auto
==============================================================================
--- qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/README 
(added)
+++ qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/README 
Tue May 26 16:24:06 2015
@@ -0,0 +1,151 @@
+Most (though not all) of the current examples require a broker or
+similar intermediary that supports the AMQP 1.0 protocol, allows
+anonymous connections and accepts links to and from a node named
+'examples'. A very simple broker emulating script - broker.py - is
+provided against which the examples can also be run (transactions are
+not yet supported in this script).
+
+------------------------------------------------------------------
+
+helloworld.py
+
+Basic example that connects to an intermediary on localhost:5672,
+establishes a subscription from the 'examples' node on that
+intermediary, then creates a sending link to the same node and sends
+one message. On receving the message back via the subcription, the
+connection is closed.
+
+helloworld_blocking.py
+
+The same as the basic helloworld.py, but using a
+synchronous/sequential style wrapper on top of the
+asynchronous/reactive API. The purpose of this example is just to show
+how different functionality can be easily layered should it be
+desired.
+
+helloworld_direct.py
+
+A variant of the basic hellpwprld example, that does not use an
+intermediary, but listens for incoming connections itself. It
+establishes a connection to itself with a link over which a single
+message is sent. This demonstrates the ease with which a simple daemon
+can be built using the API.
+
+helloworld_tornado.py
+helloworld_direct_tornado.py
+
+These are variant of the helloworld.py and helloworld_direct.py
+examples that use the event loop from the tornado library, rather than
+that provided within proton itself and demonstrate how proton can be
+used with external loops.
+
+-------------------------------------------------------------------
+
+simple_send.py
+
+An example of sending a fixed number of messages and tracking their
+(asynchronous) acknowledgement. Handles disconnection while
+maintaining an at-least-once guarantee (there may be duplicates, but
+no message in the sequence should be lost). Messages are sent through
+the 'examples' node on an intermediary accessible on port 5672 on
+localhost.
+
+simple_recv.py
+
+Subscribes to the 'examples' node on an intermediary accessible on port 5672 on
+localhost. Simply prints out the body of received messages.
+
+db_send.py
+
+A more realistic sending example, where the messages come from records
+in a simple database table. On being acknowledged the records can be
+deleted from the table. The database access is done in a separate
+thread, so as not to block the event thread during data
+access. Messages are sent through the 'examples' node on an
+intermediary accessible on port 5672 on localhost.
+
+db_recv.py
+
+A receiving example that records messages received from the 'examples'
+node on localhost:5672 in a database table and only acknowledges them
+when the insert completes. Database access is again done in a separate
+thread from the event loop.
+
+db_ctrl.py
+
+A utility for setting up the database tables for the two examples
+above. Takes two arguments, the action to perform and the name of the
+database on which to perfom it. The database used by db_send.py is
+src_db, that by db_recv.py is dst_db. The valid actions are 'init',
+which creates the table, 'list' which displays the contents and
+'insert' which inserts records from standard-in and is used to
+populate src_db, e.g. for i in `seq 1 50`; do echo "Message-$i"; done
+| ./db_ctrl.py insert src_db.
+
+tx_send.py
+
+A sender that sends messages in atomic batches using local
+transactions (this example does not persist the messages in anyway).
+
+tx_recv.py
+
+A receiver example that accepts batches of messages using local
+transactions.
+
+tx_recv_interactive.py
+
+A testing utility that allow interactive control of the
+transactions. Actions are keyed in to the console, 'fetch' will
+request another message, 'abort' will abort the transaction, 'commit'
+will commit it.
+
+The various send/recv examples can be mixed and matched if desired.
+
+-------------------------------------------------------------------
+
+client.py
+
+The client part of a request-response example. Sends requests and
+prints out responses. Requires an intermediary that support the AMQP
+1.0 dynamic nodes on which the responses are received. The requests
+are sent through the 'examples' node.
+
+server.py
+
+The server part of a request-response example, that receives requests
+via the examples node, converts the body to uppercase and sends the
+result back to the indicated reply address.
+
+sync_client.py
+
+A variant of the client part, that uses a blocking/synchronous style
+instead of the reactive/asynchronous style.
+
+client_http.py
+
+A variant of the client part that takes the input to be submitted in
+the request over HTTP (point your browser to localhost:8888/client)
+
+server_tx.py
+
+A variant of the server part that consumes the request and sends out
+the response atomically in a local transaction.
+
+-------------------------------------------------------------------
+
+selected_recv.py
+
+An example that uses a selector filter.
+
+-------------------------------------------------------------------
+
+recurring_timer.py
+
+An example showing a simple timer event.
+
+recurring_timer_tornado.py
+
+A variant of the above that uses the tornado eventloop instead.
+
+-------------------------------------------------------------------
+

Added: 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/abstract_server.py
URL: 
http://svn.apache.org/viewvc/qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/abstract_server.py?rev=1681791&view=auto
==============================================================================
--- 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/abstract_server.py
 (added)
+++ 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/abstract_server.py
 Tue May 26 16:24:06 2015
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+from proton_server import Server
+
+class Application(Server):
+    def __init__(self, host, address):
+        super(Application, self).__init__(host, address)
+
+    def on_request(self, request, reply_to):
+        response = request.upper()
+        self.send(response, reply_to)
+        print "Request from: %s" % reply_to
+
+try:
+    Application("localhost:5672", "examples").run()
+except KeyboardInterrupt: pass
+

Propchange: 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/abstract_server.py
------------------------------------------------------------------------------
    svn:executable = *

Added: 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/broker.py
URL: 
http://svn.apache.org/viewvc/qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/broker.py?rev=1681791&view=auto
==============================================================================
--- qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/broker.py 
(added)
+++ qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/broker.py 
Tue May 26 16:24:06 2015
@@ -0,0 +1,124 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import collections, optparse
+from proton import Endpoint, generate_uuid
+from proton.handlers import MessagingHandler
+from proton.reactor import Container
+
+class Queue(object):
+    def __init__(self, dynamic=False):
+        self.dynamic = dynamic
+        self.queue = collections.deque()
+        self.consumers = []
+
+    def subscribe(self, consumer):
+        self.consumers.append(consumer)
+
+    def unsubscribe(self, consumer):
+        if consumer in self.consumers:
+            self.consumers.remove(consumer)
+        return len(self.consumers) == 0 and (self.dynamic or self.queue.count 
== 0)
+
+    def publish(self, message):
+        self.queue.append(message)
+        self.dispatch()
+
+    def dispatch(self, consumer=None):
+        if consumer:
+            c = [consumer]
+        else:
+            c = self.consumers
+        while self._deliver_to(c): pass
+
+    def _deliver_to(self, consumers):
+        try:
+            result = False
+            for c in consumers:
+                if c.credit:
+                    c.send(self.queue.popleft())
+                    result = True
+            return result
+        except IndexError: # no more messages
+            return False
+
+class Broker(MessagingHandler):
+    def __init__(self, url):
+        super(Broker, self).__init__()
+        self.url = url
+        self.queues = {}
+
+    def on_start(self, event):
+        self.acceptor = event.container.listen(self.url)
+
+    def _queue(self, address):
+        if address not in self.queues:
+            self.queues[address] = Queue()
+        return self.queues[address]
+
+    def on_link_opening(self, event):
+        if event.link.is_sender:
+            if event.link.remote_source.dynamic:
+                address = str(generate_uuid())
+                event.link.source.address = address
+                q = Queue(True)
+                self.queues[address] = q
+                q.subscribe(event.link)
+            elif event.link.remote_source.address:
+                event.link.source.address = event.link.remote_source.address
+                self._queue(event.link.source.address).subscribe(event.link)
+        elif event.link.remote_target.address:
+            event.link.target.address = event.link.remote_target.address
+
+    def _unsubscribe(self, link):
+        if link.source.address in self.queues and 
self.queues[link.source.address].unsubscribe(link):
+            del self.queues[link.source.address]
+
+    def on_link_closing(self, event):
+        if event.link.is_sender:
+            self._unsubscribe(event.link)
+
+    def on_connection_closing(self, event):
+        self.remove_stale_consumers(event.connection)
+
+    def on_disconnected(self, event):
+        self.remove_stale_consumers(event.connection)
+
+    def remove_stale_consumers(self, connection):
+        l = connection.link_head(Endpoint.REMOTE_ACTIVE)
+        while l:
+            if l.is_sender:
+                self._unsubscribe(l)
+            l = l.next(Endpoint.REMOTE_ACTIVE)
+
+    def on_sendable(self, event):
+        self._queue(event.link.source.address).dispatch(event.link)
+
+    def on_message(self, event):
+        self._queue(event.link.target.address).publish(event.message)
+
+parser = optparse.OptionParser(usage="usage: %prog [options]")
+parser.add_option("-a", "--address", default="localhost:5672",
+                  help="address router listens on (default %default)")
+opts, args = parser.parse_args()
+
+try:
+    Container(Broker(opts.address)).run()
+except KeyboardInterrupt: pass

Propchange: 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/broker.py
------------------------------------------------------------------------------
    svn:executable = *

Added: 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/client.py
URL: 
http://svn.apache.org/viewvc/qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/client.py?rev=1681791&view=auto
==============================================================================
--- qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/client.py 
(added)
+++ qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/client.py 
Tue May 26 16:24:06 2015
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import optparse
+from proton import Message
+from proton.handlers import MessagingHandler
+from proton.reactor import Container, DynamicNodeProperties
+
+class Client(MessagingHandler):
+    def __init__(self, url, requests):
+        super(Client, self).__init__()
+        self.url = url
+        self.requests = requests
+
+    def on_start(self, event):
+        self.sender = event.container.create_sender(self.url)
+        self.receiver = 
event.container.create_receiver(self.sender.connection, None, dynamic=True)
+
+    def next_request(self):
+        if self.receiver.remote_source.address:
+            req = Message(reply_to=self.receiver.remote_source.address, 
body=self.requests[0])
+            self.sender.send(req)
+
+    def on_link_opened(self, event):
+        if event.receiver == self.receiver:
+            self.next_request()
+
+    def on_message(self, event):
+        print "%s => %s" % (self.requests.pop(0), event.message.body)
+        if self.requests:
+            self.next_request()
+        else:
+            event.connection.close()
+
+REQUESTS= ["Twas brillig, and the slithy toves",
+           "Did gire and gymble in the wabe.",
+           "All mimsy were the borogroves,",
+           "And the mome raths outgrabe."]
+
+parser = optparse.OptionParser(usage="usage: %prog [options]",
+                               description="Send requests to the supplied 
address and print responses.")
+parser.add_option("-a", "--address", default="localhost:5672/examples",
+                  help="address to which messages are sent (default %default)")
+opts, args = parser.parse_args()
+
+Container(Client(opts.address, args or REQUESTS)).run()
+

Propchange: 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/client.py
------------------------------------------------------------------------------
    svn:executable = *

Added: 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/client_http.py
URL: 
http://svn.apache.org/viewvc/qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/client_http.py?rev=1681791&view=auto
==============================================================================
--- 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/client_http.py
 (added)
+++ 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/client_http.py
 Tue May 26 16:24:06 2015
@@ -0,0 +1,113 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import tornado.ioloop
+import tornado.web
+from proton import Message
+from proton.handlers import MessagingHandler
+from proton_tornado import Container
+
+class Client(MessagingHandler):
+    def __init__(self, host, address):
+        super(Client, self).__init__()
+        self.host = host
+        self.address = address
+        self.sent = []
+        self.pending = []
+        self.reply_address = None
+        self.sender = None
+        self.receiver = None
+
+    def on_start(self, event):
+        conn = event.container.connect(self.host)
+        self.sender = event.container.create_sender(conn, self.address)
+        self.receiver = event.container.create_receiver(conn, None, 
dynamic=True)
+
+    def on_link_opened(self, event):
+        if event.receiver == self.receiver:
+            self.reply_address = event.link.remote_source.address
+            self.do_request()
+
+    def on_sendable(self, event):
+        self.do_request()
+
+    def on_message(self, event):
+        if self.sent:
+            request, handler = self.sent.pop(0)
+            print "%s => %s" % (request, event.message.body)
+            handler(event.message.body)
+            self.do_request()
+
+    def do_request(self):
+        if self.pending and self.reply_address and self.sender.credit:
+            request, handler = self.pending.pop(0)
+            self.sent.append((request, handler))
+            req = Message(reply_to=self.reply_address, body=request)
+            self.sender.send(req)
+
+    def request(self, body, handler):
+        self.pending.append((body, handler))
+        self.do_request()
+        self.container.touch()
+
+class ExampleHandler(tornado.web.RequestHandler):
+    def initialize(self, client):
+        self.client = client
+
+    def get(self):
+        self._write_open()
+        self._write_form()
+        self._write_close()
+
+    @tornado.web.asynchronous
+    def post(self):
+        client.request(self.get_body_argument("message"), lambda x: 
self.on_response(x))
+
+    def on_response(self, body):
+        self.set_header("Content-Type", "text/html")
+        self._write_open()
+        self._write_form()
+        self.write("Response: " + body)
+        self._write_close()
+        self.finish()
+
+    def _write_open(self):
+        self.write('<html><body>')
+
+    def _write_close(self):
+        self.write('</body></html>')
+
+    def _write_form(self):
+        self.write('<form action="/client" method="POST">'
+                   'Request: <input type="text" name="message">'
+                   '<input type="submit" value="Submit">'
+                   '</form>')
+
+
+loop = tornado.ioloop.IOLoop.instance()
+client = Client("localhost:5672", "examples")
+client.container = Container(client, loop=loop)
+client.container.initialise()
+app = tornado.web.Application([tornado.web.url(r"/client", ExampleHandler, 
dict(client=client))])
+app.listen(8888)
+try:
+    loop.start()
+except KeyboardInterrupt:
+    loop.stop()

Propchange: 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/client_http.py
------------------------------------------------------------------------------
    svn:executable = *

Added: 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/db_common.py
URL: 
http://svn.apache.org/viewvc/qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/db_common.py?rev=1681791&view=auto
==============================================================================
--- 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/db_common.py 
(added)
+++ 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/db_common.py 
Tue May 26 16:24:06 2015
@@ -0,0 +1,114 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import Queue
+import sqlite3
+import threading
+
+class Db(object):
+    def __init__(self, db, injector):
+        self.db = db
+        self.injector = injector
+        self.tasks = Queue.Queue()
+        self.position = None
+        self.pending_events = []
+        self.running = True
+        self.thread = threading.Thread(target=self._process)
+        self.thread.daemon=True
+        self.thread.start()
+
+    def close(self):
+        self.tasks.put(lambda conn: self._close())
+
+    def reset(self):
+        self.tasks.put(lambda conn: self._reset())
+
+    def load(self, records, event=None):
+        self.tasks.put(lambda conn: self._load(conn, records, event))
+
+    def get_id(self, event):
+        self.tasks.put(lambda conn: self._get_id(conn, event))
+
+    def insert(self, id, data, event=None):
+        self.tasks.put(lambda conn: self._insert(conn, id, data, event))
+
+    def delete(self, id, event=None):
+        self.tasks.put(lambda conn: self._delete(conn, id, event))
+
+    def _reset(self, ignored=None):
+        self.position = None
+
+    def _close(self, ignored=None):
+        self.running = False
+
+    def _get_id(self, conn, event):
+        cursor = conn.execute("SELECT * FROM records ORDER BY id DESC")
+        row = cursor.fetchone()
+        if event:
+            if row:
+                event.id = row['id']
+            else:
+                event.id = 0
+            self.injector.trigger(event)
+
+    def _load(self, conn, records, event):
+        if self.position:
+            cursor = conn.execute("SELECT * FROM records WHERE id > ? ORDER BY 
id", (self.position,))
+        else:
+            cursor = conn.execute("SELECT * FROM records ORDER BY id")
+        while not records.full():
+            row = cursor.fetchone()
+            if row:
+                self.position = row['id']
+                records.put(dict(row))
+            else:
+                break
+        if event:
+            self.injector.trigger(event)
+
+    def _insert(self, conn, id, data, event):
+        if id:
+            conn.execute("INSERT INTO records(id, description) VALUES (?, ?)", 
(id, data))
+        else:
+            conn.execute("INSERT INTO records(description) VALUES (?)", 
(data,))
+        if event:
+            self.pending_events.append(event)
+
+    def _delete(self, conn, id, event):
+        conn.execute("DELETE FROM records WHERE id=?", (id,))
+        if event:
+            self.pending_events.append(event)
+
+    def _process(self):
+        conn = sqlite3.connect(self.db)
+        conn.row_factory = sqlite3.Row
+        with conn:
+            while self.running:
+                f = self.tasks.get(True)
+                try:
+                    while True:
+                        f(conn)
+                        f = self.tasks.get(False)
+                except Queue.Empty: pass
+                conn.commit()
+                for event in self.pending_events:
+                    self.injector.trigger(event)
+                self.pending_events = []
+        self.injector.close()

Propchange: 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/db_common.py
------------------------------------------------------------------------------
    svn:executable = *

Added: 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/db_ctrl.py
URL: 
http://svn.apache.org/viewvc/qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/db_ctrl.py?rev=1681791&view=auto
==============================================================================
--- 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/db_ctrl.py 
(added)
+++ 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/db_ctrl.py 
Tue May 26 16:24:06 2015
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import sqlite3
+import sys
+
+if len(sys.argv) < 3:
+    print "Usage: %s [init|insert|list] db" % sys.argv[0]
+else:
+    conn = sqlite3.connect(sys.argv[2])
+    with conn:
+        if sys.argv[1] == "init":
+            conn.execute("DROP TABLE IF EXISTS records")
+            conn.execute("CREATE TABLE records(id INTEGER PRIMARY KEY 
AUTOINCREMENT, description TEXT)")
+            conn.commit()
+        elif sys.argv[1] == "list":
+            cursor = conn.cursor()
+            cursor.execute("SELECT * FROM records")
+            rows = cursor.fetchall()
+            for r in rows:
+                print r
+        elif sys.argv[1] == "insert":
+            while True:
+                l = sys.stdin.readline()
+                if not l: break
+                conn.execute("INSERT INTO records(description) VALUES (?)", 
(l.rstrip(),))
+            conn.commit()
+        else:
+            print "Unrecognised command: %s" %  sys.argv[1]

Propchange: 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/db_ctrl.py
------------------------------------------------------------------------------
    svn:executable = *

Added: 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/db_recv.py
URL: 
http://svn.apache.org/viewvc/qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/db_recv.py?rev=1681791&view=auto
==============================================================================
--- 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/db_recv.py 
(added)
+++ 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/db_recv.py 
Tue May 26 16:24:06 2015
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import optparse
+from proton.handlers import MessagingHandler
+from proton.reactor import ApplicationEvent, Container, EventInjector
+from db_common import Db
+
+class Recv(MessagingHandler):
+    def __init__(self, url, count):
+        super(Recv, self).__init__(auto_accept=False)
+        self.url = url
+        self.delay = 0
+        self.last_id = None
+        self.expected = count
+        self.received = 0
+        self.accepted = 0
+        self.db = Db("dst_db", EventInjector())
+
+    def on_start(self, event):
+        event.container.selectable(self.db.injector)
+        e = ApplicationEvent("id_loaded")
+        e.container = event.container
+        self.db.get_id(e)
+
+    def on_id_loaded(self, event):
+        self.last_id = event.id
+        event.container.create_receiver(self.url)
+
+    def on_record_inserted(self, event):
+        self.accept(event.delivery)
+        self.accepted += 1
+        if self.accepted == self.expected:
+            event.connection.close()
+            self.db.close()
+
+    def on_message(self, event):
+        id = int(event.message.id)
+        if (not self.last_id) or id > self.last_id:
+            if self.received < self.expected:
+                self.received += 1
+                self.last_id = id
+                self.db.insert(id, event.message.body, 
ApplicationEvent("record_inserted", delivery=event.delivery))
+                print "inserted message %s" % id
+            else:
+                self.release(event.delivery)
+        else:
+            self.accept(event.delivery)
+
+parser = optparse.OptionParser(usage="usage: %prog [options]")
+parser.add_option("-a", "--address", default="localhost:5672/examples",
+                  help="address from which messages are received (default 
%default)")
+parser.add_option("-m", "--messages", type="int", default=0,
+                  help="number of messages to receive; 0 receives indefinitely 
(default %default)")
+opts, args = parser.parse_args()
+
+try:
+    Container(Recv(opts.address, opts.messages)).run()
+except KeyboardInterrupt: pass
+
+
+

Propchange: 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/db_recv.py
------------------------------------------------------------------------------
    svn:executable = *

Added: 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/db_send.py
URL: 
http://svn.apache.org/viewvc/qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/db_send.py?rev=1681791&view=auto
==============================================================================
--- 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/db_send.py 
(added)
+++ 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/db_send.py 
Tue May 26 16:24:06 2015
@@ -0,0 +1,105 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import optparse
+import Queue
+import time
+from proton import Message
+from proton.handlers import MessagingHandler
+from proton.reactor import ApplicationEvent, Container, EventInjector
+from db_common import Db
+
+class Send(MessagingHandler):
+    def __init__(self, url, count):
+        super(Send, self).__init__()
+        self.url = url
+        self.delay = 0
+        self.sent = 0
+        self.confirmed = 0
+        self.load_count = 0
+        self.records = Queue.Queue(maxsize=50)
+        self.target = count
+        self.db = Db("src_db", EventInjector())
+
+    def keep_sending(self):
+        return self.target == 0 or self.sent < self.target
+
+    def on_start(self, event):
+        self.container = event.container
+        self.container.selectable(self.db.injector)
+        self.sender = self.container.create_sender(self.url)
+
+    def on_records_loaded(self, event):
+        if self.records.empty():
+            if event.subject == self.load_count:
+                print "Exhausted available data, waiting to recheck..."
+                # check for new data after 5 seconds
+                self.container.schedule(5, self)
+        else:
+            self.send()
+
+    def request_records(self):
+        if not self.records.full():
+            print "loading records..."
+            self.load_count += 1
+            self.db.load(self.records, 
event=ApplicationEvent("records_loaded", link=self.sender, 
subject=self.load_count))
+
+    def on_sendable(self, event):
+        self.send()
+
+    def send(self):
+        while self.sender.credit and not self.records.empty():
+            if not self.keep_sending(): return
+            record = self.records.get(False)
+            id = record['id']
+            self.sender.send(Message(id=id, durable=True, 
body=record['description']), tag=str(id))
+            self.sent += 1
+            print "sent message %s" % id
+        self.request_records()
+
+    def on_settled(self, event):
+        id = int(event.delivery.tag)
+        self.db.delete(id)
+        print "settled message %s" % id
+        self.confirmed += 1
+        if self.confirmed == self.target:
+            event.connection.close()
+            self.db.close()
+
+    def on_disconnected(self, event):
+        self.db.reset()
+        self.sent = self.confirmed
+
+    def on_timer_task(self, event):
+        print "Rechecking for data..."
+        self.request_records()
+
+parser = optparse.OptionParser(usage="usage: %prog [options]",
+                               description="Send messages to the supplied 
address.")
+parser.add_option("-a", "--address", default="localhost:5672/examples",
+                  help="address to which messages are sent (default %default)")
+parser.add_option("-m", "--messages", type="int", default=0,
+                  help="number of messages to send; 0 sends indefinitely 
(default %default)")
+opts, args = parser.parse_args()
+
+try:
+    Container(Send(opts.address, opts.messages)).run()
+except KeyboardInterrupt: pass
+

Propchange: 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/db_send.py
------------------------------------------------------------------------------
    svn:executable = *

Added: 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/direct_recv.py
URL: 
http://svn.apache.org/viewvc/qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/direct_recv.py?rev=1681791&view=auto
==============================================================================
--- 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/direct_recv.py
 (added)
+++ 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/direct_recv.py
 Tue May 26 16:24:06 2015
@@ -0,0 +1,59 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import optparse
+from proton.handlers import MessagingHandler
+from proton.reactor import Container
+
+class Recv(MessagingHandler):
+    def __init__(self, url, count):
+        super(Recv, self).__init__()
+        self.url = url
+        self.expected = count
+        self.received = 0
+
+    def on_start(self, event):
+        self.acceptor = event.container.listen(self.url)
+
+    def on_message(self, event):
+        if event.message.id and event.message.id < self.received:
+            # ignore duplicate message
+            return
+        if self.expected == 0 or self.received < self.expected:
+            print event.message.body
+            self.received += 1
+            if self.received == self.expected:
+                event.receiver.close()
+                event.connection.close()
+                self.acceptor.close()
+
+parser = optparse.OptionParser(usage="usage: %prog [options]")
+parser.add_option("-a", "--address", default="localhost:5672/examples",
+                  help="address from which messages are received (default 
%default)")
+parser.add_option("-m", "--messages", type="int", default=100,
+                  help="number of messages to receive; 0 receives indefinitely 
(default %default)")
+opts, args = parser.parse_args()
+
+try:
+    Container(Recv(opts.address, opts.messages)).run()
+except KeyboardInterrupt: pass
+
+
+

Propchange: 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/direct_recv.py
------------------------------------------------------------------------------
    svn:executable = *

Added: 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/direct_send.py
URL: 
http://svn.apache.org/viewvc/qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/direct_send.py?rev=1681791&view=auto
==============================================================================
--- 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/direct_send.py
 (added)
+++ 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/direct_send.py
 Tue May 26 16:24:06 2015
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import optparse
+from proton import Message
+from proton.handlers import MessagingHandler
+from proton.reactor import Container
+
+class Send(MessagingHandler):
+    def __init__(self, url, messages):
+        super(Send, self).__init__()
+        self.url = url
+        self.sent = 0
+        self.confirmed = 0
+        self.total = messages
+
+    def on_start(self, event):
+        self.acceptor = event.container.listen(self.url)
+
+    def on_sendable(self, event):
+        while event.sender.credit and self.sent < self.total:
+            msg = Message(id=(self.sent+1), body={'sequence':(self.sent+1)})
+            event.sender.send(msg)
+            self.sent += 1
+
+    def on_accepted(self, event):
+        self.confirmed += 1
+        if self.confirmed == self.total:
+            print "all messages confirmed"
+            event.connection.close()
+            self.acceptor.close()
+
+    def on_disconnected(self, event):
+        self.sent = self.confirmed
+
+parser = optparse.OptionParser(usage="usage: %prog [options]",
+                               description="Send messages to the supplied 
address.")
+parser.add_option("-a", "--address", default="localhost:5672/examples",
+                  help="address to which messages are sent (default %default)")
+parser.add_option("-m", "--messages", type="int", default=100,
+                  help="number of messages to send (default %default)")
+opts, args = parser.parse_args()
+
+try:
+    Container(Send(opts.address, opts.messages)).run()
+except KeyboardInterrupt: pass

Propchange: 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/direct_send.py
------------------------------------------------------------------------------
    svn:executable = *

Added: 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/helloworld.py
URL: 
http://svn.apache.org/viewvc/qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/helloworld.py?rev=1681791&view=auto
==============================================================================
--- 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/helloworld.py 
(added)
+++ 
qpid/site/input/releases/qpid-proton-0.9.1/proton/python/examples/helloworld.py 
Tue May 26 16:24:06 2015
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+from proton import Message
+from proton.handlers import MessagingHandler
+from proton.reactor import Container
+
+class HelloWorld(MessagingHandler):
+    def __init__(self, server, address):
+        super(HelloWorld, self).__init__()
+        self.server = server
+        self.address = address
+
+    def on_start(self, event):
+        conn = event.container.connect(self.server)
+        event.container.create_receiver(conn, self.address)
+        event.container.create_sender(conn, self.address)
+
+    def on_sendable(self, event):
+        event.sender.send(Message(body=u"Hello World!"))
+        event.sender.close()
+
+    def on_message(self, event):
+        print event.message.body
+        event.connection.close()
+
+Container(HelloWorld("localhost:5672", "examples")).run()



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

Reply via email to