I am working with a python implementation of quickfix.
http://www.quickfixengine.org
I would like to set SocketConnectHost other than via the configuration '.ini' file, but have not discovered how to do this.
I have discovered that the SessionSettings class has a member SOCKET_CONNECT_HOST, but I don't seem able to 'set' this other than via the '.ini' file.
Nor can I see how to 'get' members individually either.
Printing a string representation of a SessionSettings instance gives a C++ ish reference to a location in memory and...
<quickfix.SessionSettings; proxy of <Swig Object of type 'FIX::SessionSettings' at 0x7f5a1c1333390>.
So it looks like the SessionSettings stuff is being handled in the C++ quickfix engine layer.
Can I get or set just SocketConnectHost from python?
Thanks,
Ben
I can't speak for Python, but there's a SessionSettings instance you need to create a SocketInitiator.
Usually you would create this instance from the QuickFIX configuration file. After initializing it from the configuration file, you can change settings with the setter methods, eg SessionSettings.setString(SessionID s, String key, String value). The key would be SocketConnectHost in your case.
Related
Is it possible to configure Quartz through a mixture of properties held in a config file (either quartz.properties or app.config / web.config) and also some via the StdSchedulerFactory constructor?
I would like to pass the AdoJobStore connectionstring via the constructor, as it is dynamic depending on the environment, but the rest of the settings are static so would be better placed in a config file.
I've tried passing in only the quartz.dataSource.myDS.connectionString property via the constructor, whilst having the rest of the properties in a quartz.config in the working directory. However, I get the error:
Provider not specified for DataSource: myDS
So I guess this means that if you use the constructor that accepts the NameValueCollection, then it doesn't bother checking the config file(s).
I know that the quartz.config file is in the right place, because if I put the connectionstring in there and use the default constructor, it all works
In the end, they are all simply named-value pairs.
You can have "most" of them in an .xml file...then "add in" the ones you want via code.
Or have all of them in code.
See the UnitTests for the source code, and you'll see this fairly clearly.
Something like this:
NameValueCollection config = (NameValueCollection)ConfigurationManager.GetSection("quartz");
config.Add("MyCodedUpKey", "MyCodedUpValue");
If you have a "collision" (a "key" in the config file that you want to override..apply some simple name-valued-pair "update existing key" logic"
Check if Key Exists in NameValueCollection
I have an F# library project that I'm using from a C# web project. I would like to use the Entity Framework Type Provider in my F# project, and have it get the connection string from the Web.config - but I'm having trouble getting this working.
type internal FooDb =
SqlEntityConnection<ConnectionStringName="FooDb", Pluralize=true>
At design time, I'm required to have an App.config file in the F# library project with a connection string having the matching name.
At runtime, when calling my F# code from the C# web project, I get an error that it can't locate the "App.config" file. This surprises me, because I was expecting that at runtime it would just use ConfigurationManager.ConnectionStrings to load the connection string from the currently-active config file (in the case of a web app, Web.config). However this doesn't seem to be the case.
I tried adding the ConfigFile parameter:
type internal FooDb =
SqlEntityConnection<ConnectionStringName="FooDb", ConfigFile="Web.config", Pluralize=true>
But this just made it complain at design time that it couldn't find Web.config.
Then I renamed the App.config file in the F# library project to Web.config and that seems to have gotten things working. However, I'm uneasy about this solution. Is this really how it's intended to work? I have to have a web.config file in my library project? What would I do if I wanted to use the same library from a command-line executable, and in that environment the config file is called AssemblyName.exe.config?
Forcing me to hard-code the name of a config file that can have different names in different contexts seems very brittle, and a poor design. Please tell me I'm missing something.
The issue you've encountered seems rather unfortunate indeed, and I don't know whether you are missing something or not. However, the SqlEntityConnection documentation says that FooDb should have a GetDataContext overload where a "connectionString parameter may be used when the connection string is determined at runtime." Perhaps that will give you a decent enough work around (i.e. pass in the connection string from ConfigurationManager.ConnectionStrings yourself).
I'm trying to change some otherwise working code by pulling all the classes into separate files. This works for most classes, except for the part where it reads class window.Timeline. The error message reads ReferenceError: window is not defined
Any suggestions?
It sounds like your file containing that class isn't getting loaded into the window context. Is it possible that it got loaded in the context of another class? Could you post some cod examples in a jsFiddle?
The pattern that I usually follow when exporting coffeescript symbols to the parent context is
exports = exports ? this
class MyClass
someField: false
exports.MyClass = MyClass
If you are using a modern browser and know how to access the debugging console, you could put
console.log this
At the end of the file that is throwing the reference error. This will allow you to have a look to see what the this context is, which may help you troubleshoot.
I'm embedding Python into a C++ application. I plan to use PyEval_EvalCode to execute Python code, but instead of providing the locals and globals as dictionaries, I'm looking for a way to have my program resolve symbol references dynamically.
For example, let's say my Python code consists of the following expression:
bear + lion * bunny
Instead of placing bear, lion and bunny and their associated objects into the dictionaries that I'm passing to PyEval_EvalCode, I'd like the Python interpreter to call back my program and request these named objects.
Is there a way to accomplish this?
By providing the locals and globals dictionaries, you are providing the environment in which the evaled code is executed. That effectively provides you with an interface to map names to objects defined in the C++ app.
Can you clarify why you do not want to use the dictionaries?
Another thing you could do is process the string in C++ and do string substitution before you eval the code....
Possibly. I've never tried this but in theory you might be able to implement a small extension class in C++ that overrides the __getattr__ method (probably via the tp_as_mapping or tp_getattro function pointers of PyTypeObject). Pass an instance of this as locals and/or globals to PyEval_EvalCode and your C++ method should be asked to resolve your lions, tigers, & bears for you.
In xcode you can use po object to see a textual representation of a given object. Is it possible to convert from this textual representation to a real objective c object?
Thanks
I suppose you could parse out the address, assign it to a pointer, and retrieve the object from memory that way, but that IS A HORRIBLY BAD IDEA AND YOU SHOULD NEVER DO THAT.
Real question: what are you trying to do?
I have a project that may inspire you, its on GitHub and its called NDJSON. Basically it uses runtime introspection to get properties an object has and set those properties using a json key of the same value. You could do something like that but get the property values instead of set. To help in situation where the type can not be determined like the type of objects to go in a collection or to map a json key to differently named property I have defined an informal protocol that has some methods that return dictionary mapping json key to property names or class to use for property name, there are also method to return a list of json keys to ignore or alternatively the only keys to accept. If you look at my code on git hub there is a class called NDJSONDeserializer which contains this logic. There is a function called getTypeNameFromPropertyAttributes() which parses out the string result of Apples runtime method property_getAttributes() which you will want to look at.
No, the representation you see from po <instance> is the result of -[<instance> debugDescription], which by default returns -[<instance> description], as described in http://developer.apple.com/mac/library/technotes/tn2004/tn2124.html.
Unless the instance you're dealing with just happens to provide a description which is a serialized form of itself, you're SOL. Most objects don't.
The real question, as Dave points out is, what are you trying to do? po only works in the gdb console, so I assume this is a debugging issue. In that case, do you know that the gdb console supports sending messages to instances? So you can do:
po [<myInstance> methodReturningAnOtherObject]
or
po [<myInstance> valueForKeyPath:#"some.long.key.path"]
to follow the object graph from within the debugger console.