I am trying to convert my app to use Twisted. The original version handles a gui, some business logic, and a database connection, all in one program. I have split it into a 'client' program, that handles the gui; and a server program, that handles the business logic and the database connection, and communicates with the client using pb.
The original program has some logic to validate user input. The data to be validated is passed up through 3 or 4 classes. Here is some very simplified pseudo code -
class1(): def check1(data): perform test if test failed: return False if not class2.check2(data): return False return True
class2(): def check2(data): perform test if test failed: return False if not class3.check3(data): return False return True
class3(): def check3(data): perform test if test failed: return False if not class4.check4(data): return False return True
class4(): def check4(data): perform test if test failed: return False return True
In my new program, classes 1-3 run on the client, class4 runs on the server. Therefore I tried to change class3 as follows -
class3(): def check3(data): avatar.callRemote(check4,data).addCallback(afterCheck)
def afterCheck(result): return result
This does not work, as check1 and check2 never receive the result.
I would like to avoid going through my entire program and changing each occurrence of check1 and check2 into a deferred and a callback. I do not particularly mind if the client program blocks, as I do not want the user to proceed until the result is known.
Is there any way to accomplish this?
Thanks for any advice