$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r60158 - in sandbox/SOC/2007/cgi/trunk: boost/cgi boost/cgi/cgi boost/cgi/common boost/cgi/utility libs/cgi/example/cgi/cookies libs/cgi/example/cgi/sessions libs/cgi/example/fcgi/file_browser libs/cgi/example/scgi
From: lists.drrngrvy_at_[hidden]
Date: 2010-03-04 18:36:34
Author: drrngrvy
Date: 2010-03-04 18:36:33 EST (Thu, 04 Mar 2010)
New Revision: 60158
URL: http://svn.boost.org/trac/boost/changeset/60158
Log:
More work on experimental session support. See the cgi/sessions example. Tested on ubuntu with g++ 4.3.3.
Added:
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/sessions/Jamfile.v2   (contents, props changed)
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/file_browser/Jamfile.v2   (contents, props changed)
Removed:
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/scgi/
Text files modified: 
   sandbox/SOC/2007/cgi/trunk/boost/cgi/basic_request.hpp                 |    68 +++++++++++++++++++++++++-------------- 
   sandbox/SOC/2007/cgi/trunk/boost/cgi/cgi/request_service.hpp           |     2                                         
   sandbox/SOC/2007/cgi/trunk/boost/cgi/common/basic_protocol_service.hpp |    40 +++++++++--------------                 
   sandbox/SOC/2007/cgi/trunk/boost/cgi/common/commit.hpp                 |     4 +-                                      
   sandbox/SOC/2007/cgi/trunk/boost/cgi/common/parse_options.hpp          |     6 +++                                     
   sandbox/SOC/2007/cgi/trunk/boost/cgi/common/protocol_traits.hpp        |     5 ++                                      
   sandbox/SOC/2007/cgi/trunk/boost/cgi/common/request_base.hpp           |    59 +++++++++++++++++++++++++++++++++-      
   sandbox/SOC/2007/cgi/trunk/boost/cgi/utility/sessions.hpp              |    35 ++++++++++++++++++-                     
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/cookies/Jamfile.v2     |     1                                         
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/cookies/main.cpp       |     1                                         
   sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/sessions/main.cpp      |    41 ++++++++++++++++++-----                 
   11 files changed, 196 insertions(+), 66 deletions(-)
Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/basic_request.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/basic_request.hpp	(original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/basic_request.hpp	2010-03-04 18:36:33 EST (Thu, 04 Mar 2010)
@@ -50,17 +50,16 @@
 #endif 
 
 BOOST_CGI_NAMESPACE_BEGIN
- 
  namespace common {
 
-   /// Get a hashed interpretation of the request.
-   /**
-    * You cannot consider this completely unique to each
-    * request, but it should be quite useful anyway.
-    * You can use this for logging or tracking, for example.
-    */
-   template<typename P>
-   std::size_t hash_value(basic_request<P> const& req);
+  /// Get a hashed interpretation of the request.
+  /**
+   * You cannot consider this completely unique to each
+   * request, but it should be quite useful anyway.
+   * You can use this for logging or tracking, for example.
+   */
+  template<typename P>
+  std::size_t hash_value(basic_request<P> const& req);
 
   /// The basic_request class, primary entry point to the library
   /**
@@ -98,7 +97,6 @@
 #ifdef BOOST_CGI_ENABLE_SESSIONS
     typedef typename traits::session_type              session_type;
 
-    string_type session_id_;
     session_type session;
 #endif // BOOST_CGI_ENABLE_SESSIONS
     
@@ -114,6 +112,7 @@
       , char** base_env = NULL)
         : detail::basic_io_object<service_type>()
     {
+      set_protocol_service();
       if ((parse_options)opts > parse_none) load((parse_options)opts, base_env);
     }
 
@@ -122,6 +121,7 @@
       , char** base_env = NULL)
         : detail::basic_io_object<service_type>()
     {
+      set_protocol_service();
       if (opts > parse_none) load(opts, base_env);
     }
 
@@ -131,6 +131,7 @@
                  , char** base_env = NULL)
       : detail::basic_io_object<service_type>()
     {
+      set_protocol_service();
       if (opts > parse_none) load(opts, ec);
     }
 
@@ -183,18 +184,23 @@
       //  close(http::internal_server_error, 0);
 #ifdef BOOST_CGI_ENABLE_SESSIONS
       try {
-          if (!session_id_.empty())
-          {
-            if (session.id().empty())
-              session.id(session_id_);
-            this->implementation.service_->save(session);
-          }
+          if (!session.id().empty())
+            this->service.session_manager().save(session);
       } catch(...) {
          // pass
       }
 #endif // BOOST_CGI_ENABLE_SESSIONS
     }
     
+#ifdef BOOST_CGI_ENABLE_SESSIONS
+    void start_session()
+    {
+      std::cerr<< "Starting session" << std::endl;
+      if (session.id().empty())
+        session.id(this->service.make_session_id());
+      std::cerr<< "Started session" << std::endl;
+    }
+#endif // BOOST_CGI_ENABLE_SESSIONS
     protocol_service_type& get_protocol_service()
     {
       return *(this->implementation.service_);
@@ -210,6 +216,11 @@
       return pointer(new self_type());
     }
 
+    void set_protocol_service()
+    {
+      //this->service.set_service(this->implementation, ps);
+    }
+
     void set_protocol_service(protocol_service_type& ps)
     {
       this->service.set_service(this->implementation, ps);
@@ -281,11 +292,6 @@
         }
         if (parse_opts & parse_cookies) {
           cookies.set(cookie_vars(this->implementation.vars_));
-#ifdef BOOST_CGI_ENABLE_SESSIONS
-          if (cookies.count("$ssid")) {
-            session_id_ = cookies["$ssid"];
-          }
-#endif // BOOST_CGI_ENABLE_SESSIONS
         }
         if (parse_opts & parse_form_only)
         {
@@ -296,10 +302,24 @@
           );
         }
 #ifdef BOOST_CGI_ENABLE_SESSIONS
-        if (!session_id_.empty())
+        if (parse_opts & parse_session_only)
         {
-          session.id(session_id_);
-          this->implementation.service_->load(session);
+          if (!!cookies && cookies.count("$ssid"))
+          {
+            std::cerr<< "Loading pre-existing session." << std::endl;
+            session.id(cookies["$ssid"]);
+          }
+          else
+          if (traits::auto_start_session)
+          {
+            std::cerr<< "Starting new session." << std::endl;
+            session.id(this->service.make_session_id());
+          }
+          if (!session.id().empty())
+          {
+            this->service.session_manager().load(session);
+            std::cerr<< "Started session" << std::endl;
+          }
         }
 #endif // BOOST_CGI_ENABLE_SESSIONS
       }
Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/cgi/request_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/cgi/request_service.hpp	(original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/cgi/request_service.hpp	2010-03-04 18:36:33 EST (Thu, 04 Mar 2010)
@@ -98,7 +98,7 @@
     void construct(implementation_type& impl)
     {
       impl.client_.set_connection(
-        implementation_type::connection_type::create(this->get_io_service())
+        connection_type::create(this->get_io_service())
       );
     }
 
Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/common/basic_protocol_service.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/common/basic_protocol_service.hpp	(original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/common/basic_protocol_service.hpp	2010-03-04 18:36:33 EST (Thu, 04 Mar 2010)
@@ -22,9 +22,6 @@
 #include "boost/cgi/fwd/basic_request_fwd.hpp"
 #include "boost/cgi/fwd/basic_protocol_service_fwd.hpp"
 #include "boost/cgi/import/io_service.hpp"
-#ifdef BOOST_CGI_ENABLE_SESSIONS
-#  include "boost/cgi/utility/sessions.hpp"
-#endif // BOOST_CGI_ENABLE_SESSIONS
 
 BOOST_CGI_NAMESPACE_BEGIN
  namespace common {
@@ -41,22 +38,34 @@
     typedef Protocol                                 protocol_type;
     typedef IoServiceProvider                        ios_provider_type;
     typedef typename protocol_traits<Protocol>::type traits;
+    typedef typename traits::string_type             string_type;
     typedef typename traits::request_type            request_type;
     typedef typename request_type::pointer           request_ptr;
     typedef std::set<request_ptr>                    set_type;
     typedef std::queue<request_ptr>                  queue_type;
-#ifdef BOOST_CGI_ENABLE_SESSIONS
-    typedef typename traits::session_manager_type    session_manager_type;
-#endif // BOOST_CGI_ENABLE_SESSIONS
+
+    basic_protocol_service()
+      : ios_provider_()
+      , request_set_()
+      , request_queue_()
+    {
+   	std::cerr<< "Constructing" << std::endl; 
+    }
 
     basic_protocol_service(int pool_size_hint = 1)
       : ios_provider_(pool_size_hint)
+      , request_set_()
+      , request_queue_()
     {
+   	std::cerr<< "2.. Constructing" << std::endl; 
     }
 
     basic_protocol_service(boost::asio::io_service& ios)
       : ios_provider_(ios)
+      , request_set_()
+      , request_queue_()
     {
+   	std::cerr<< "3... Constructing" << std::endl; 
     }
 
     ~basic_protocol_service()
@@ -80,7 +89,6 @@
      */
     void stop()
     {
-      //gateway_.stop();
       ios_provider_.stop();
     }
 
@@ -107,7 +115,7 @@
      * The order in which the underlying io_services are returned is determined
      * by what policy the IoServiceProvider uses.
      */
-    ::BOOST_CGI_NAMESPACE::common::io_service& io_service()
+    ::BOOST_CGI_NAMESPACE::common::io_service& get_io_service()
     {
       return ios_provider_.get_io_service();
     }
@@ -126,22 +134,6 @@
       ios_provider_.get_io_service().dispatch(handler);
     }
 
-#ifdef BOOST_CGI_ENABLE_SESSIONS
-    template<typename T>
-    void save(basic_session<T>& sesh) {
-      session_mgr_.save(sesh);
-    }
-
-    template<typename T>
-    void load(basic_session<T>& sesh) {
-      session_mgr_.load(sesh);
-    }
-    
-  private:
-    session_manager_type session_mgr_;
-
-#endif // BOOST_CGI_ENABLE_SESSIONS
-
   private:
     ios_provider_type ios_provider_;
 
Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/common/commit.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/common/commit.hpp	(original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/common/commit.hpp	2010-03-04 18:36:33 EST (Thu, 04 Mar 2010)
@@ -29,8 +29,8 @@
               , boost::system::error_code& ec)
     {
 #ifdef BOOST_CGI_ENABLE_SESSIONS
-      if (!req.session_id_.empty()) {
-        resp<< cookie("$ssid", req.session_id_);
+      if (!req.session.id().empty()) {
+        resp<< cookie("$ssid", req.session.id());
       }
 #endif // BOOST_CGI_ENABLE_SESSIONS
       resp.send(req.client(), ec);
Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/common/parse_options.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/common/parse_options.hpp	(original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/common/parse_options.hpp	2010-03-04 18:36:33 EST (Thu, 04 Mar 2010)
@@ -23,7 +23,13 @@
      , parse_cookie       = parse_cookie_only | parse_env
      , parse_cookies_only = parse_cookie_only
      , parse_cookies      = parse_cookies_only | parse_env
+#ifdef BOOST_CGI_ENABLE_SESSIONS
+     , parse_session_only = 16
+     , parse_session      = parse_session_only | parse_cookies
+     , parse_all          = parse_env | parse_form | parse_cookie | parse_session
+#else
      , parse_all          = parse_env | parse_form | parse_cookie
+#endif // BOOST_CGI_ENABLE_SESSIONS
    };
 
  } // namespace common
Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/common/protocol_traits.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/common/protocol_traits.hpp	(original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/common/protocol_traits.hpp	2010-03-04 18:36:33 EST (Thu, 04 Mar 2010)
@@ -24,6 +24,7 @@
 #include "boost/cgi/fwd/form_parser_fwd.hpp"
 #ifdef BOOST_CGI_ENABLE_SESSIONS
 #  include "boost/cgi/utility/sessions.hpp"
+#  include <boost/uuid/uuid_generators.hpp>
 #endif // BOOST_CGI_ENABLE_SESSIONS
 
 BOOST_CGI_NAMESPACE_BEGIN
@@ -96,6 +97,9 @@
                 std::map<string_type, string_type> 
               >                                      session_type;
       typedef session_manager                        session_manager_type;
+      static const bool auto_start_session = true;
+
+      typedef boost::uuids::random_generator          uuid_generator_type;
 #endif // BOOST_CGI_ENABLE_SESSIONS
       static const common::parse_options parse_opts = common::parse_all;
     };
@@ -145,6 +149,7 @@
                 std::map<string_type, string_type> 
               >                                      session_type;
       typedef session_manager                        session_manager_type;
+      static const bool auto_start_session = true;
 #endif // BOOST_CGI_ENABLE_SESSIONS
 
       static const common::parse_options parse_opts = common::parse_none;
Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/common/request_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/common/request_base.hpp	(original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/common/request_base.hpp	2010-03-04 18:36:33 EST (Thu, 04 Mar 2010)
@@ -28,6 +28,12 @@
 #include "boost/cgi/detail/extract_params.hpp"
 #include "boost/cgi/detail/save_environment.hpp"
 #include "boost/cgi/config.hpp"
+#ifdef BOOST_CGI_ENABLE_SESSIONS
+#  include "boost/cgi/utility/sessions.hpp"
+#  include <boost/uuid/uuid.hpp>
+#  include <boost/uuid/uuid_generators.hpp>
+#  include <boost/uuid/uuid_io.hpp>
+#endif // BOOST_CGI_ENABLE_SESSIONS
 
 BOOST_CGI_NAMESPACE_BEGIN
  namespace common {
@@ -42,7 +48,25 @@
   {
   public:
     typedef common::request_base<Protocol> base_type;
+    typedef Protocol                               protocol_type;
+    typedef protocol_traits<Protocol>              traits;
+    typedef typename traits::buffer_type           buffer_type;
+    typedef typename traits::char_type             char_type;
+    typedef typename traits::client_type           client_type;
+    typedef typename traits::connection_type       connection_type;
+    typedef typename traits::const_buffers_type    const_buffers_type;
+    typedef typename traits::form_parser_type      form_parser_type;
+    typedef typename traits::mutable_buffers_type  mutable_buffers_type;
+    typedef typename traits::protocol_service_type protocol_service_type;
+    typedef typename traits::request_type          request_type;
+    typedef typename traits::string_type           string_type;
+    typedef typename connection_type::pointer      conn_ptr;
+#ifdef BOOST_CGI_ENABLE_SESSIONS
+    typedef typename traits::uuid_generator_type   uuid_generator_type;
+    typedef typename traits::session_manager_type  session_manager_type;
+#endif // BOOST_CGI_ENABLE_SESSIONS
 
+ 
   protected:
     // impl_base is the common base class for all request types'
     // implementation_type and should be inherited by it.
@@ -62,7 +86,7 @@
       typedef typename traits::request_type          request_type;
       typedef typename traits::string_type           string_type;
       typedef typename connection_type::pointer      conn_ptr;
-      
+
       /**
        * If you want to add a new data type to a request you need to:
        *   > Update this file (just below)
@@ -170,7 +194,8 @@
         bool is_command_line
       )
     {
-      if (is_command_line) ++base_environment;
+      if (is_command_line && base_environment != NULL)
+        ++base_environment;
       detail::save_environment(env_vars(impl.vars_), base_environment);
     }
 
@@ -353,6 +378,36 @@
       }  
       return ec;
     }
+
+#ifdef BOOST_CGI_ENABLE_SESSIONS
+  public:
+    /// Get the session manager.
+    session_manager_type& session_manager() { return session_mgr_; }
+    /// Get the session manager.
+    session_manager_type const& session_manager() const { return session_mgr_; }
+
+    /// Get a new UUID as a string, suitable as a session id.
+    string_type make_session_id()
+    {
+      string_type val;
+      try {
+         val = boost::lexical_cast<string_type>(make_uuid());
+      } catch (...) {
+         std::cerr<< "Caught error." << std::endl;
+      }
+      return val;
+    }
+
+    /// Generate a new UUID.
+    boost::uuids::uuid make_uuid() { return generator_(); }
+    
+  private:
+    session_manager_type session_mgr_;
+    uuid_generator_type generator_;
+
+#endif // BOOST_CGI_ENABLE_SESSIONS
+
+
   };
 
  } // namespace common
Modified: sandbox/SOC/2007/cgi/trunk/boost/cgi/utility/sessions.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/boost/cgi/utility/sessions.hpp	(original)
+++ sandbox/SOC/2007/cgi/trunk/boost/cgi/utility/sessions.hpp	2010-03-04 18:36:33 EST (Thu, 04 Mar 2010)
@@ -20,6 +20,28 @@
 #include "boost/cgi/detail/throw_error.hpp"
 ///////////////////////////////////////////////////////////
 
+/// The directory to store sessions in.
+/**
+ * Your web server will need read and write permissions to this directory.
+ * You are responsible for ensuring that no other users are able to access
+ * files in this directory!
+ * 
+ * Session support is currently experimental and relatively dumb.
+ *
+ * A file is saved for every user, containing the session data.
+ * The session data itself defaults to a std::map<string,string>, which
+ * is derived from the ProtocolTraits of the request.
+ *
+ * Look at the `sessions` example to see how to use your own types
+ * for sessions. In general, the idea is that any type that is both
+ * DefaultConstructable and also Serializable (as defined by
+ * Boost.Serialization) can be used as the session type with no runtime
+ * overhead.
+ */
+#ifndef BOOST_CGI_SESSIONS_DIRECTORY
+#  define BOOST_CGI_SESSIONS_DIRECTORY "../sessions/"
+#endif // BOOST_CGI_SESSIONS_DIRECTORY
+
 BOOST_CGI_NAMESPACE_BEGIN
  namespace common {
 
@@ -47,15 +69,19 @@
     : T(t)
     , id_(id)
   {}
-  
+
   string const& id () const { return id_; }
   void id (string const& new_id) { id_ = new_id; }
   
   operator T() { return static_cast<T&>(*this); }
   operator T() const { return static_cast<T const&>(*this); }
 
+  bool const& loaded() const { return loaded_; }
+  void loaded(bool status) { loaded_ = status; }
+
 private:
   string id_;
+  bool loaded_;
 };
 
 class session_manager
@@ -67,7 +93,8 @@
   template<typename T>
   void save(basic_session<T>& sesh)
   {
-    ofstream ofs((sesh.id() + ".arc").c_str());
+    ofstream ofs(
+        (std::string(BOOST_CGI_SESSIONS_DIRECTORY) + sesh.id() + ".arc").c_str());
     if (ofs) {
       boost::archive::text_oarchive archive(ofs);
       archive<< static_cast<typename basic_session<T>::value_type&>(sesh);
@@ -77,10 +104,12 @@
   template<typename T>
   void load(basic_session<T>& sesh)
   {
-    ifstream ifs((sesh.id() + ".arc").c_str());
+    ifstream ifs(
+        (std::string(BOOST_CGI_SESSIONS_DIRECTORY) + sesh.id() + ".arc").c_str());
     if (ifs) {
       boost::archive::text_iarchive archive(ifs);
       archive>> static_cast<typename basic_session<T>::value_type&>(sesh);
+      sesh.loaded(true);
     }
   }
 };
Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/cookies/Jamfile.v2
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/cookies/Jamfile.v2	(original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/cookies/Jamfile.v2	2010-03-04 18:36:33 EST (Thu, 04 Mar 2010)
@@ -10,6 +10,7 @@
   :
      main.cpp /boost/regex/ /boost/cgi/
   :
+     <linkflags>-lctemplate
   ;
 
 
Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/cookies/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/cookies/main.cpp	(original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/cookies/main.cpp	2010-03-04 18:36:33 EST (Thu, 04 Mar 2010)
@@ -20,7 +20,6 @@
 // [1] - http://code.google.com/p/google-ctemplate/
 //
 #include <boost/cgi/cgi.hpp>
-#include <boost/cgi/utility.hpp>
 #include <ctemplate/template.h>
 #include <boost/throw_exception.hpp>
 #include <boost/system/system_error.hpp>
Added: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/sessions/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/sessions/Jamfile.v2	2010-03-04 18:36:33 EST (Thu, 04 Mar 2010)
@@ -0,0 +1,29 @@
+#             Copyright (c) 2009 Darren Garvey
+#
+# Distributed under the Boost Software License, Version 1.0.
+#     (See accompanying file LICENSE_1_0.txt or copy 
+#        at http://www.boost.org/LICENSE_1_0.txt)
+
+project boost/cgi/example/cgi/sesssions ;
+
+exe cgi_sessions
+  :
+    main.cpp
+  :
+    <define>BOOST_CGI_ENABLE_SESSIONS
+    <library>/boost/cgi/
+    <library>/boost/filesystem/
+    <library>/boost/serialization/
+  ;
+
+
+# Our install rule (builds binaries and copies them to <location>)
+install install
+ :
+   cgi_sessions
+ :
+   <location>$(cgi-bin)
+ ;
+
+# Only install example if you use `bjam install' or equivalent
+explicit install ;
Modified: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/sessions/main.cpp
==============================================================================
--- sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/sessions/main.cpp	(original)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/cgi/sessions/main.cpp	2010-03-04 18:36:33 EST (Thu, 04 Mar 2010)
@@ -20,30 +20,56 @@
   
 };
 
+/*<
+ * Now we can override the default session type to use the `context` class.
+ *
+ * To do this we need to create a `Tag`. A `Tag` is a plain struct used as
+ * an identifier. If we specialise the `protocol_traits<>` template for this
+ * tag we can change the behaviour of the library at compile-time.
+ *
+ * In this example we are just going to override the actual `session_type`
+ * and otherwise inherit the properties for CGI.
+>*/
+
+/// The `Tag`
 struct session_enabled_cgi {};
 
-namespace boost { namespace cgi {
+/// Specialise the `protocol_traits` template in the `boost::cgi::common`
+/// namespace.
+namespace boost { namespace cgi { namespace common {
 
 template<>
 struct protocol_traits<session_enabled_cgi>
   : protocol_traits<boost::cgi::tags::cgi>
 {
   typedef basic_session<context> session_type;
+  static const bool auto_start_session = false;
 };
 
-} } // namespace boost::cgi
+} } } // namespace boost::cgi::common
 
 using namespace boost::cgi;
 
+/// Define a request type which uses the traits for our
+/// `session_enabled_cgi` Tag.
 typedef basic_request<session_enabled_cgi> my_request;
 
 int main(int, char**)
 {
+  cerr<< "Started: " << time(NULL) << endl;
   try
   {
+    boost::uuids::basic_random_generator<boost::rand48> generator;
+    cerr<< "Here" << endl;
+    boost::uuids::uuid u = generator();
+    cerr<< "generated" << endl;
+ 
+
     my_request req;
     response resp;
 
+    //req.load(parse_session);
+
     resp<< "one = " << req.session.data["one"]
         << ", two = " << req.session.data["two"]
         << ", ten = " << req.session.data["ten"];
@@ -54,20 +80,17 @@
     req.session.data["ten"] = 10;
 
     // Set the session id, so the data is saved.    
-    req.session_id_ = "1";
+    //req.session_id_ = "1";
 
     resp<< content_type("text/plain") << "\nBlah\n";
     
     commit(req, resp);
 
-    cout<< "Press enter to continue...";
-    //cin.get();
     return 0;
   
   } catch (std::exception& e) {
     cerr<< "Error: " << e.what() << endl;
   }
-  
-  cout<< "Press enter to continue...";
-  cin.get();
-}
\ No newline at end of file
+
+  cout<< "Content-type: text/html\r\n\r\nBoom";
+}
Added: sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/file_browser/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/cgi/trunk/libs/cgi/example/fcgi/file_browser/Jamfile.v2	2010-03-04 18:36:33 EST (Thu, 04 Mar 2010)
@@ -0,0 +1,21 @@
+#             Copyright (c) 2009 Darren Garvey
+#
+# Distributed under the Boost Software License, Version 1.0.
+#     (See accompanying file LICENSE_1_0.txt or copy 
+#        at http://www.boost.org/LICENSE_1_0.txt)
+
+project boost/cgi/example/fcgi/file_browser ;
+
+exe fcgi_file_browser : main.cpp /boost/regex/ ;
+
+# Our install rule (builds binaries and copies them to <location>)
+install install
+ :
+   fcgi_file_browser
+ : 
+   <location>$(fcgi-bin)
+ ;
+
+# Only install example if you use `bjam install' or equivalent
+explicit install ;
+