Hello! WEnvironment object is bound to WApplication object. In main(), WApplication::instance() returns 0, since no active WApplication is processed. WApplication::instance() returns non-0 in event loop.
BTW, database session object is also bound to WApplication object. Good place to initialize database session is constructor of your custom class, inherited from WApplication. Regards, Boris Nagaev On Fri, Mar 7, 2014 at 6:11 AM, Jeffrey Scott Flesher Gmail <[email protected]> wrote: > > I am writing a CMS and need to switch databases based on hostName from > Environment, this is based on wt-home example. > > This causes a crash: > > try > { > Wt::WServer server(argv[0]); > server.setServerConfiguration(argc, argv, WTHTTP_CONFIGURATION); > const Wt::WEnvironment &myEnv = > Wt::WApplication::instance()->environment(); > QString filePath = server.appRoot().c_str(); > filePath.append("domains.xml"); > readDomains(myEnv.hostName().c_str(), filePath); > ... > > > ------------------------------------------------------------------------------ > Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce. > With Perforce, you get hassle-free workflows. Merge that actually works. > Faster operations. Version large binaries. Built-in WAN optimization and the > freedom to use Git, Perforce or both. Make the move to Perforce. > http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk > _______________________________________________ > witty-interest mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/witty-interest > ------------------------------------------------------------------------------ Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce. With Perforce, you get hassle-free workflows. Merge that actually works. Faster operations. Version large binaries. Built-in WAN optimization and the freedom to use Git, Perforce or both. Make the move to Perforce. http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk _______________________________________________ witty-interest mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/witty-interest
