Hoy mam problem... nemůžu na to přijít
http://mrl.cs.vsb.cz/people/gaura/spja_course.html#uloha3
toto je mé zadání... nevím jak na to pár lidí mi poslala program hotovy, ale potreboval bych ho vysvetlit...
Server.py
from SimpleXMLRPCServer import SimpleXMLRPCServer
from xml.dom.minidom import parseString
import httplib
class NajdiKnihu(object):
def find_isbn_title(self, isbn):
try:
Pripojeni = httplib.HTTPConnection("xisbn.worldcat.org")
Pripojeni.request("GET", "/webservices/xid/isbn/" + isbn + "?method=getMetadata&format=xml&fl=title")
r = Pripojeni.getresponse()
xml = r.read()
root = parseString(xml)
stat = root.getElementsByTagName('rsp')[0].attributes["stat"].value
if stat == "invalidId":
return "Invalid ISBN"
title = root.getElementsByTagName('isbn')[0].attributes["title"].value
return title
except Exception:
return "Chyba"
def main():
book = NajdiKnihu()
server_address = ('localhost', 10001)
server = SimpleXMLRPCServer(server_address)
server.register_instance(book)
server.register_introspection_functions()
print "Spusteni XML-RPC servru"
server.serve_forever()
main()
Client.py
from xmlrpclib import ServerProxy
def NajdiKnihu(server, isbn):
try:
print server.find_isbn_title(isbn)
except Exception, e:
print e
server = ServerProxy("http://localhost:10001")
NajdiKnihu(server, "80-10-01314-5")
mohl by mi nekdo tento program vysvetlit?