PERFORCE change 123531 for review

Andrew Turner andrew at FreeBSD.org
Sun Jul 15 11:58:24 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=123531

Change 123531 by andrew at 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


More information about the p4-projects mailing list