One option here could be to have the compiler actually generate differently named objects. i.e. you could have a TwistedServiceClient or something. That naming is pretty ugly -- maybe do something more in line with twisted conventions (I'm not sure if there are any, I haven't programmed in Twisted before).
But this way, your server can import gen-py.twisted.TwistedServiceClient or whatever it is, and your client can just grab the regular stuff. Overloading the same names seems nice but I worry it'll just create more confusion in the long run than explicit naming would. -----Original Message----- From: Matthieu Imbert [mailto:[email protected]] Sent: Friday, July 03, 2009 10:11 PM To: [email protected] Subject: thrift + python twisted Hi, I'm currently rewriting a thrift server code in python to use twisted instead of the default server implementations (TThreadedServer or TThreadPoolServer). But i also have several client code in python that i don't want to switch to twisted, because using the default thrift client code is easier to deal with (also: i have users that just write clients, and i don't want to impose them to learn twisted to use the server). I thought that just replacing TBufferedTransport by TFramedTransport in python client code would be sufficient, but actually, generating the client service with "thrift-gen py:twisted" changes more than that: now the service constructor takes two parameters instead of one. I tried to generate both the default service and the twisted one in separate directories: ./gen-py and ./gen-py-twisted, and have my server import from ./gen-py-twisted and the clients import from ./gen-py, but it's not a working solution since i also have service modules, both imported from the client and the server, that perform conversions between thrift structures and application specific structures. This modules need to import either from ./gen-py-twisted or ./gen-py, but in any case, at some point, this results in an incoherence in the imports (eg: the client imports ./gen-py and imports the service module which itself imports from ./gen-py-twisted) I wonder what could be the best way to solve this problem? By the way, thanks all the thrift team for the great software, and Esteve for the twisted stuff. cheers, -- Matthieu
