[Quickfix-developers] Python issues
Brought to you by:
orenmnero
|
From: Jeff B. <jef...@ya...> - 2006-09-14 22:12:32
|
I'm using Quickfix with Python and I've found a few issues:
1. overloading __init__
In the quickfix.i SWIG interface file, at the bottom, there is code to control the overloading of the constructors for both SocketInitiator and SocketAcceptor. However, Python doesn't allow the __init__ operator to be overloaded. As a result, the following code will fail:
file = sys.argv[1]
settings = fix.SessionSettings( file )
application = Application()
storeFactory = fix.FileStoreFactory( settings )
initiator = fix.SocketInitiator( application, storeFactory, settings ) # No logFactory present
Python will complain that we are not passing enough parameters to the __init__ call of SocketInitiator. So, the code in quickfix.i should be changed as follows:
class SocketInitiator(SocketInitiatorBase):
application = 0
storeFactory = 0
setting = 0
logFactory = 0
def __init__(self, application, storeFactory, settings, logFactory=None):
if logFactory == None:
SocketInitiatorBase.__init__(self, application, storeFactory, settings)
else:
SocketInitiatorBase.__init__(self, application, storeFactory, settings, logFactory)
self.application = application
self.storeFactory = storeFactory
self.settings = settings
self.logFactory = logFactory
<The same changes should be made to SocketAcceptor as well>
2. Programmatically configuring SessionSettings
I'm trying to programatically configure the
SessionSettings using Python:
settings = fix.SessionSettings()
defaults[fix.CONNECTION_TYPE] = "initiator"
defaults[fix.HEARTBTINT] = "30"
defaults[fix.FILE_STORE_PATH] = "store"
...
settings.set( settings, defaults )
When I attempt to execute the "set" function, I get the
following error:
NotImplementedError: No matching function for
overloaded 'SessionSettings_set' by the SWIG code in
the function *_wrap_SessionSettings_get().
Not too sure, but I'm guessing the libraries want a
Dictionary type for the second argument to SessionSettings::set. However, the
SWIG wrapper does not seem to generate a Python object
for the Dictionary class. I'm not too sure why.
3. SWIG output does not compile under Visual Studio
This has been mentioned on the mailing list before, but I thought I would bring it up again. In general, most of the code compiles. However, in the C++ code, there are typedefs for CHAR, INT and BOOLEAN all of which are already defined by Windows. This leads to ambiguity errors. The typedefs in FieldTypes.h should probably have QF_ prepended or something (so QF_CHAR, rather than CHAR).
Besides the ambiguity errors, there are other problems popping up as well that seem to prevent the SWIG code from building. Not too sure how to fix those.
Thanks,
Jeff Bartley
---------------------------------
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail. |