Hello.
I'm writing a handler and I'd like to read its configuration (passed in by PassCPPVar) in its constructor.
Is it currently possible, or do I have to modify mod_cplusplus sources ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you use the PassCPPVar you should be able to get that value from your handler using the get_cpp_var method. For example:
get_cpp_var(pRequest, "key")
I suggest looking at AuthHandler class (in mod_cplusplus/example/handler/test_auth.cpp) as an example. The test config file (in tests/t/conf/extra.conf.in) passes the expected user name, then the handler uses the get_cpp_var method to retrieve the configured value.
Let us know if you have more questions.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, I've already noticed the get_cpp_var method, but it needs a ApacheRequestRec object and as far as I know there isn't one available in the ApacheHandler constructor.
I'd like to do my handler's initialization in its constructor as it takes some time (severals file parsing to do).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That has been requested before. In the past people have lazy loaded things like that (first request slow, rest fast), but I see the need. Although there is no request at construction time, there is a server - so I can add a server to the constructor, that way you can use the PassCPPServerVar directive and get_server_var during your constructor. I'll work on that and test it out.
John
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok, I've made the modifications, it works with the tests and also with my handler.
I've also made a patch against the current cvs, but it seems sourceforge won't let me submit it to the project now... I'll try again later on.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes I've tried and it works without any problem.
Quite logic since the CVS and my modified version are essentially the same... Sorry not to have sent my changes earlier.
Sebastien.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello.
I'm writing a handler and I'd like to read its configuration (passed in by PassCPPVar) in its constructor.
Is it currently possible, or do I have to modify mod_cplusplus sources ?
Hi -
If you use the PassCPPVar you should be able to get that value from your handler using the get_cpp_var method. For example:
get_cpp_var(pRequest, "key")
I suggest looking at AuthHandler class (in mod_cplusplus/example/handler/test_auth.cpp) as an example. The test config file (in tests/t/conf/extra.conf.in) passes the expected user name, then the handler uses the get_cpp_var method to retrieve the configured value.
Let us know if you have more questions.
Yes, I've already noticed the get_cpp_var method, but it needs a ApacheRequestRec object and as far as I know there isn't one available in the ApacheHandler constructor.
I'd like to do my handler's initialization in its constructor as it takes some time (severals file parsing to do).
Yeah -
That has been requested before. In the past people have lazy loaded things like that (first request slow, rest fast), but I see the need. Although there is no request at construction time, there is a server - so I can add a server to the constructor, that way you can use the PassCPPServerVar directive and get_server_var during your constructor. I'll work on that and test it out.
John
Yes, This is what I was thinking to do too... If you're too busy to do it know, I can start working on that and send you back my changes.
Thanks again,
Sebastien.
Either way - I should be able to get to it this week, at least in cvs.
John
Ok, I've made the modifications, it works with the tests and also with my handler.
I've also made a patch against the current cvs, but it seems sourceforge won't let me submit it to the project now... I'll try again later on.
Hi -
I'm about to check in a change that will allow for passing ApacheServerRec * to all cpp_factory methods.
NOTE: This is not backward compatible, so developers will need to change their factory method signatures and recompile when upgrading. If there are
Have you gotten a chance to look at CVS and make sure this works for you? I'm planning on bundling a release this weekend.
Thanks -
John
Yes I've tried and it works without any problem.
Quite logic since the CVS and my modified version are essentially the same... Sorry not to have sent my changes earlier.
Sebastien.