Author: jsdelfino
Date: Sat Dec 2 01:17:39 2006
New Revision: 481525
URL: http://svn.apache.org/viewvc?view=rev&rev=481525
Log:
Added update and delete to the REST sample.
Modified:
incubator/tuscany/cpp/sca/samples/RestCustomer/sample.customer.restclient/CustomerRestClient.py
incubator/tuscany/cpp/sca/samples/RestCustomer/sample.customer/CustomerResource.py
Modified:
incubator/tuscany/cpp/sca/samples/RestCustomer/sample.customer.restclient/CustomerRestClient.py
URL:
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/RestCustomer/sample.customer.restclient/CustomerRestClient.py?view=diff&rev=481525&r1=481524&r2=481525
==============================================================================
---
incubator/tuscany/cpp/sca/samples/RestCustomer/sample.customer.restclient/CustomerRestClient.py
(original)
+++
incubator/tuscany/cpp/sca/samples/RestCustomer/sample.customer.restclient/CustomerRestClient.py
Sat Dec 2 01:17:39 2006
@@ -24,22 +24,31 @@
from xml.etree import ElementTree as et
import sca
-import sys
# Locate the customer service
customerService = sca.locateservice("Customer")
# Invoke the CRUD operations on the customer resource
-customer = et.fromstring("""<customer
xmlns="http://sample.customer"><id>1234</id><firstName>Jane</firstName><lastName>Doe</lastName></customer>""")
-print et.tostring(customer)
+customer = customerService.retrieve("2345")
+print "Retrieved customer " + et.tostring(customer)
+customer = et.fromstring("""<customer
xmlns="http://sample.customer"><id>1234</id><firstName>Jane</firstName><lastName>Doe</lastName></customer>""")
url = customerService.create(customer)
-print url
+print "Created customer " + url
+
+customer = customerService.retrieve("1234")
+print "Retrieved customer " + et.tostring(customer)
+
+customer = customerService.retrieve(url)
+print "Retrieved by url " + et.tostring(customer)
-#customer = customerService.retrieve("1234")
-#print et.tostring(customer)
+customer.find("{http://sample.customer}lastName").text="Smith"
+customerService.update("1234", customer)
+print "Updated customer 1234"
-#customer = customerService.retrieve("2345")
-#print et.tostring(customer)
+customer = customerService.retrieve("1234")
+print "Retrieved customer " + et.tostring(customer)
+customerService.delete("1234")
+print "Deleted customer 1234"
Modified:
incubator/tuscany/cpp/sca/samples/RestCustomer/sample.customer/CustomerResource.py
URL:
http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/samples/RestCustomer/sample.customer/CustomerResource.py?view=diff&rev=481525&r1=481524&r2=481525
==============================================================================
---
incubator/tuscany/cpp/sca/samples/RestCustomer/sample.customer/CustomerResource.py
(original)
+++
incubator/tuscany/cpp/sca/samples/RestCustomer/sample.customer/CustomerResource.py
Sat Dec 2 01:17:39 2006
@@ -22,7 +22,6 @@
# manages Customer resources.
#
-import sys
import os
import shutil
from xml.etree import ElementTree as et
@@ -39,7 +38,7 @@
f = open(dir + "/" + id + ".xml", "w")
f.write(et.tostring(customer))
f.close()
- return id
+ return id
def retrieve(self, id):
print "Python - CustomerResourceImpl.retrieve " + id
@@ -48,8 +47,7 @@
f.close()
return customer
- def update(self, customer):
- id = customer.findtext(qname)
+ def update(self, id, customer):
print "Python - CustomerResourceImpl.update " + id
f = open(dir + "/" + id + ".xml", "w")
f.write(et.tostring(customer))
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]