[Opensrf-commits] r1479 - trunk/examples

svn at svn.open-ils.org svn at svn.open-ils.org
Sat Oct 25 13:29:26 EDT 2008


Author: dbs
Date: 2008-10-25 13:29:19 -0400 (Sat, 25 Oct 2008)
New Revision: 1479

Added:
   trunk/examples/math_client.py
Log:
Add a basic Python client example


Added: trunk/examples/math_client.py
===================================================================
--- trunk/examples/math_client.py	                        (rev 0)
+++ trunk/examples/math_client.py	2008-10-25 17:29:19 UTC (rev 1479)
@@ -0,0 +1,27 @@
+#!/usr/bin/env python
+import osrf.system
+import osrf.ses
+
+# XXX: Replace with command line arguments
+file = '/opensrf/conf/opensrf_core.xml'
+operator = 'add'
+operand1 = 5
+operand2 = 7
+
+# Pull connection settings from <config><opensrf> section of opensrf_core.xml
+osrf.system.System.connect(config_file=file, config_context='config.opensrf')
+
+# Set up a connection to the opensrf.math service
+session = osrf.ses.ClientSession('opensrf.math')
+
+# Call one of the methods defined by the opensrf.math service
+request = session.request(operator, operand1, operand2)
+
+# Retrieve the response from the method
+response = request.recv(timeout=2)
+
+print(response.content())
+
+# Cleanup request and connection resources
+request.cleanup()
+session.cleanup()



More information about the opensrf-commits mailing list