Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50984 - in sandbox/SOC/2007/cgi/branches/pickmeup: boost/cgi/detail libs/cgi/build/msvc/9.0/Boost.CGI libs/cgi/build/msvc/9.0/Boost.CGI/cgi_ctemplate_debug_server libs/cgi/example/cgi/DebugServer2
From: lists.drrngrvy_at_[hidden]
Date: 2009-02-02 19:31:43


Author: drrngrvy
Date: 2009-02-02 19:31:42 EST (Mon, 02 Feb 2009)
New Revision: 50984
URL: http://svn.boost.org/trac/boost/changeset/50984

Log:
* Saving the final 'toggle' in, eg. /path/to/script?foo=bar&toggle
* Factor out the HTML in the DebugServer2 example into a separate cTemplate.
* Updated MSVC (v9.0) solution.
Binary files modified:
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/Boost.CGI.suo
Text files modified:
   sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/extract_params.hpp | 7 +++++--
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/Boost.CGI.sln | 6 ++++++
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/cgi_ctemplate_debug_server/cgi_ctemplate_debug_server.vcproj | 5 +++++
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/DebugServer2/TracebackServer.cpp | 9 +++++----
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/DebugServer2/ctemplate.cpp | 38 ++++++++------------------------------
   sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/DebugServer2/debug_view.html | 9 +++++++++
   6 files changed, 38 insertions(+), 36 deletions(-)

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/extract_params.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/extract_params.hpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/boost/cgi/detail/extract_params.hpp 2009-02-02 19:31:42 EST (Mon, 02 Feb 2009)
@@ -70,10 +70,13 @@
        }
      }
      // Save the name if the last n/v pair has no value.
+ if ( !name.empty() )
+ destination[name.c_str()] = current_token;
 #if defined(BOOST_CGI_KEEP_EMPTY_VARS)
- if( !name.empty() )
+ else // Save the final 'toggle' - eg /path/to/script?foo=bar&toggle
+ if ( !current_token.empty() )
+ destination[current_token.c_str()] = "";
 #endif
- destination[name.c_str()] = current_token;
 
      return ec;
    }

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/Boost.CGI.sln
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/Boost.CGI.sln (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/Boost.CGI.sln 2009-02-02 19:31:42 EST (Mon, 02 Feb 2009)
@@ -19,6 +19,8 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cgi_ctemplate_debug_server", "cgi_ctemplate_debug_server\cgi_ctemplate_debug_server.vcproj", "{CED278B4-18C9-41F5-9026-1DB8CD0AC5D4}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DebugServer3", "DebugServer3\DebugServer3.vcproj", "{C0B7A721-6E2B-4594-94DD-94A6D21919DB}"
+EndProject
 Global
         GlobalSection(SolutionConfigurationPlatforms) = preSolution
                 Debug|Win32 = Debug|Win32
@@ -61,6 +63,10 @@
                 {CED278B4-18C9-41F5-9026-1DB8CD0AC5D4}.Debug|Win32.Build.0 = Release|Win32
                 {CED278B4-18C9-41F5-9026-1DB8CD0AC5D4}.Release|Win32.ActiveCfg = Release|Win32
                 {CED278B4-18C9-41F5-9026-1DB8CD0AC5D4}.Release|Win32.Build.0 = Release|Win32
+ {C0B7A721-6E2B-4594-94DD-94A6D21919DB}.Debug|Win32.ActiveCfg = Debug|Win32
+ {C0B7A721-6E2B-4594-94DD-94A6D21919DB}.Debug|Win32.Build.0 = Debug|Win32
+ {C0B7A721-6E2B-4594-94DD-94A6D21919DB}.Release|Win32.ActiveCfg = Release|Win32
+ {C0B7A721-6E2B-4594-94DD-94A6D21919DB}.Release|Win32.Build.0 = Release|Win32
         EndGlobalSection
         GlobalSection(SolutionProperties) = preSolution
                 HideSolutionNode = FALSE

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/Boost.CGI.suo
==============================================================================
Binary files. No diff available.

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/cgi_ctemplate_debug_server/cgi_ctemplate_debug_server.vcproj
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/cgi_ctemplate_debug_server/cgi_ctemplate_debug_server.vcproj (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/build/msvc/9.0/Boost.CGI/cgi_ctemplate_debug_server/cgi_ctemplate_debug_server.vcproj 2009-02-02 19:31:42 EST (Mon, 02 Feb 2009)
@@ -163,6 +163,7 @@
                         />
                         <Tool
                                 Name="VCPostBuildEventTool"
+ CommandLine="copy &quot;$(TargetPath)&quot; &quot;c:\code\c++\boost.cgi\cgi-bin\$(TargetName)&quot;&#x0D;&#x0A;copy &quot;$(SolutionDir)\..\..\..\..\example\cgi\DebugServer2\debug_view.css&quot; &quot;c:\code\c++\boost.cgi\htdocs\css\debug_view.css&quot;&#x0D;&#x0A;copy &quot;$(SolutionDir)\..\..\..\..\example\cgi\DebugServer2\debug_view.js&quot; &quot;c:\code\c++\boost.cgi\htdocs\js\debug_view.js&quot;&#x0D;&#x0A;copy &quot;$(SolutionDir)\..\..\..\..\example\cgi\DebugServer2\debug_view.html&quot; &quot;c:\code\c++\boost.cgi\templates\debug_view.html&quot;&#x0D;&#x0A;copy &quot;$(SolutionDir)\..\..\..\..\example\cgi\DebugServer2\default_view.html&quot; &quot;c:\code\c++\boost.cgi\templates\default_view.html&quot;&#x0D;&#x0A;"
                         />
                 </Configuration>
         </Configurations>
@@ -211,6 +212,10 @@
                         RelativePath="..\..\..\..\..\example\cgi\DebugServer2\debug_view.js"
>
                 </File>
+ <File
+ RelativePath="..\..\..\..\..\example\cgi\DebugServer2\default_view.html"
+ >
+ </File>
         </Files>
         <Globals>
         </Globals>

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/DebugServer2/TracebackServer.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/DebugServer2/TracebackServer.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/DebugServer2/TracebackServer.cpp 2009-02-02 19:31:42 EST (Mon, 02 Feb 2009)
@@ -47,12 +47,12 @@
 
 void TracebackServer::dump_times(dictionary_type& dict)
 {
- dict.ShowSection("RUNNING_TIME");
     dict.SetValue("RUNNING_TIME_RESOLUTION", "microseconds");
     dict.SetFormattedValue("REAL_TIME", "%d us", detail::get_microseconds(stop_times_.real));
     dict.SetFormattedValue("CPU_TIME", "%d us", detail::get_microseconds(stop_times_.user + stop_times_.system));
     dict.SetFormattedValue("USER_TIME", "%d us", detail::get_microseconds(stop_times_.user));
     dict.SetFormattedValue("SYSTEM_TIME", "%d us", detail::get_microseconds(stop_times_.system));
+ dict.ShowSection("RUNNING_TIME");
 }
 
 void TracebackServer::bomb_out(std::string const& error, response_type& response, request_type& request)
@@ -83,8 +83,9 @@
 
 
 void TracebackServer::bomb_out(boost::system::system_error* err, response_type& response, request_type& request) {
+ //dictionary_type* sub_dict = dict.AddSectionDictionary("REQUEST_DATA_MAP");
     typedef request_type::string_type string;
- string err_msg("<ul class=nvpair>boost::system::system_error*<li class=name>Code:</li>");
+ string err_msg("boost::system::system_error*<ul class=nvpair><li class=name>Code:</li>");
     err_msg += string("<li class=value>") + boost::lexical_cast<std::string>(err->code()) + "</li>"
             + "<li class=name>What:</li>"
             + "<li class=value>" + err->what() + "</li>"
@@ -95,7 +96,7 @@
 
 void TracebackServer::bomb_out(std::exception* e, response_type& response, request_type& request) {
     typedef request_type::string_type string;
- string err_msg("<ul class=nvpair>std::exception*<li class=name>What:</li>");
+ string err_msg("std::exception*<ul class=nvpair><li class=name>What:</li>");
     err_msg += string("<li class=value>") + e->what() + "</li>"
             + "<li class=name>Type:</li>"
             + "<li class=value>" + typeid(*e).name() + "</li><br class=clear /></ul>";
@@ -104,7 +105,7 @@
 
 void TracebackServer::bomb_out(std::exception& e, response_type& response, request_type& request) {
     typedef request_type::string_type string;
- string err_msg("<ul class=nvpair>std::exception<li class=name>What:</li>");
+ string err_msg("std::exception<ul class=nvpair><li class=name>What:</li>");
     err_msg += string("<li class=value>") + e.what() + "</li>"
             + "<li class=name>Type:</li>"
             + "<li class=value>" + typeid(e).name() + "</li><br class=clear /></ul>";

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/DebugServer2/ctemplate.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/DebugServer2/ctemplate.cpp (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/DebugServer2/ctemplate.cpp 2009-02-02 19:31:42 EST (Mon, 02 Feb 2009)
@@ -21,38 +21,16 @@
         std::sqrt(123.456L); // waste time
     }
     */
+
+ // Load the HTML template and strip all whitespace...
+ google::Template* tmpl = google::Template::GetTemplate("../templates/default_view.html", google::STRIP_WHITESPACE);
+ // Since this is a really basic template, this is all we need to load. We can expand it into a string.
+ std::string output;
+ tmpl->Expand(&output, NULL);
     resp<< header("X-Custom-Header: some value")
         << content_type("text/html")
- << "<html>"
- "<head>"
- "<title>Debug Server</title>"
- "</head>"
- "<body>"
- "<h1>Debugging Server Example</h1>"
- "<p>"
- "The server used in this example will catch exceptions thrown by "
- "your request handler, or a non-zero return value. It will print "
- "some presumably helpful info about what might have caused the "
- "problem - obviously this is just an example, which you'd "
- "probably want to ammend."
- "</p>"
- "<p>"
- "The handler in this example will throw a std::runtime_error if "
- "you pass 'badger=bait!' to the script, for example by following "
- "<a href=\"?badger=bait%21\">this link</a>."
- "</p>"
- "<p>"
- "The handler in this example will also return false if you pass "
- "pass 'spam' to the script, for example by clicking "
- "<a href=\"?spam=1\">here</a>."
- "</p>"
- "<p>"
- "Finally, you can simulate an error and get traceback details "
- "regardless of whether the script completed by passing 'debug=1',"
- " or by following <a href=\"?debug=1\">this link</a>."
- "</p>"
- "</body>"
- "</html>";
+ << output;
+
     if (req[form]["badger"] == "bait!") throw std::runtime_error("AOUHFAEOUHAEOUHAEOUHOUH!!!!!!");
     else if (has_key(req[form], "spam")) return 33;
     return 0;

Modified: sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/DebugServer2/debug_view.html
==============================================================================
--- sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/DebugServer2/debug_view.html (original)
+++ sandbox/SOC/2007/cgi/branches/pickmeup/libs/cgi/example/cgi/DebugServer2/debug_view.html 2009-02-02 19:31:42 EST (Mon, 02 Feb 2009)
@@ -26,6 +26,15 @@
 </p>
 <div class="info">
         {{ERROR}}
+ {{#SYSTEM_ERROR}}
+ <ul class=nvpair><p>{{ERROR_MSG}}</p>
+ <li class=name>Code:</li>");
+ err_msg += string("<li class=value>") + boost::lexical_cast<std::string>(err->code()) + "</li>"
+ + "<li class=name>What:</li>"
+ + "<li class=value>" + err->what() + "</li>"
+ + "<li class=name>Type:</li>"
+ + "<li class=value>" + typeid(*err).name() + "</li><br class=clear /></ul>";
+ {{/SYSTEM_ERROR}}
 </div>
 
 Some details about the request:


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk