Add a basic Python client example
authordbs <dbs@9efc2488-bf62-4759-914b-345cdb29e865>
Sat, 25 Oct 2008 17:29:19 +0000 (17:29 +0000)
committerdbs <dbs@9efc2488-bf62-4759-914b-345cdb29e865>
Sat, 25 Oct 2008 17:29:19 +0000 (17:29 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1479 9efc2488-bf62-4759-914b-345cdb29e865

examples/math_client.py [new file with mode: 0644]

diff --git a/examples/math_client.py b/examples/math_client.py
new file mode 100644 (file)
index 0000000..7dcbdbf
--- /dev/null
@@ -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()