[Opensrf-commits] r1480 - branches/rel_1_0/examples

svn at svn.open-ils.org svn at svn.open-ils.org
Sat Oct 25 13:30:36 EDT 2008


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

Added:
   branches/rel_1_0/examples/math_client.py
Log:
Merge r1479 from trunk to add a basic Python client example

Copied: branches/rel_1_0/examples/math_client.py (from rev 1479, trunk/examples/math_client.py)
===================================================================
--- branches/rel_1_0/examples/math_client.py	                        (rev 0)
+++ branches/rel_1_0/examples/math_client.py	2008-10-25 17:30:29 UTC (rev 1480)
@@ -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