Menu

Access module config in handler constructor

2006-01-11
2013-05-15
  • Sébastien Grignard

    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 ?

     
    • John K. Sterling

      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.

       
    • Sébastien Grignard

      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).

       
      • John K. Sterling

        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

         
        • Sébastien Grignard

          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.

           
    • John K. Sterling

      Either way - I should be able to get to it this week, at least in cvs.

      John

       
      • Sébastien Grignard

        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.

         
        • John K. Sterling

          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

           
    • John K. Sterling

      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

       
      • Sébastien Grignard

        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.

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.