Date: Sun, 15 Jul 2007 11:58:23 GMT From: Andrew Turner <andrew@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 123531 for review Message-ID: <200707151158.l6FBwNtD063588@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=123531 Change 123531 by andrew@andrew_hermies on 2007/07/15 11:58:15 Add a response object to hold the response from the server Allow a call's response to be set Add the ability for other classes to lock the response to alow syncronisation of the response Affected files ... .. //depot/projects/soc2007/andrew-update/frontend/facund/call.py#2 edit Differences ... ==== //depot/projects/soc2007/andrew-update/frontend/facund/call.py#2 (text+ko) ==== @@ -24,16 +24,48 @@ # SUCH DAMAGE. # +import threading + class Call: def __init__(self, name, args): self.__name = name self.__args = args self.__response = None + self.__responseLock = threading.Lock() + def getCall(self): # TODO: Use a better call ID return "<call id=\"1\" name=\"%s\">%s</call>" % (self.__name, self.__args) + def getID(self): + return 1 + + def setResponse(self, response): + self.__response = response + def getResponse(self): return self.__response + + def acquireLock(self): + '''Aquires the lock to use to set the response.''' + self.__responseLock.acquire() + + def releaseLock(self): + '''Releases the lock to use and set the response.''' + self.__responseLock.release() + +class Response: + def __init__(self, id, code, message, data = None): + self.__id = id + self.__code = code + self.__message = message + self.__data = data + + def __str__(self): + return "<response id=\"%s\" message=\"%s\" code=\"%s\">%s</response>" \ + % (self.__id, self.__message, self.__code, str(self.__data)) + + def getData(self): + return self.__data
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200707151158.l6FBwNtD063588>