[Jifty-commit] jifty branch, master, updated. 1.10518-28-g370869f

Jifty commits jifty-commit at lists.jifty.org
Fri Jun 17 14:09:39 EDT 2011


The branch, master has been updated
       via  370869fede9844a45e4202e7f11fb34ce50900b4 (commit)
      from  292c963bef2e084d17953daf70d15e608266dedc (commit)

Summary of changes:
 lib/Jifty.pm                  |    7 +++++++
 lib/Jifty/Manual/Cookbook.pod |    7 ++-----
 2 files changed, 9 insertions(+), 5 deletions(-)

- Log -----------------------------------------------------------------
commit 370869fede9844a45e4202e7f11fb34ce50900b4
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Fri Jun 17 13:53:54 2011 -0400

    Provide a no_request option to eliminate some script boilerplate

diff --git a/lib/Jifty.pm b/lib/Jifty.pm
index 56c5918..033650e 100644
--- a/lib/Jifty.pm
+++ b/lib/Jifty.pm
@@ -148,6 +148,7 @@ sub new {
     # Setup the defaults
     my %args = (
         no_handle        => 0,
+        no_request       => 0,
         pre_init         => 0,
         logger_component => undef,
         @_
@@ -256,6 +257,12 @@ sub new {
     $app->start
         if not $args{no_handle} and $app->can('start');
 
+    # Setup an empty request and response if we're not in a web environment
+    if ($args{no_request}) {
+        Jifty->web->request(Jifty::Request->new);
+        Jifty->web->response(Jifty::Response->new);
+    }
+
     # For plugins that want all the above initialization, but want to run before
     # we begin serving requests
     Jifty->call_trigger('post_init');
diff --git a/lib/Jifty/Manual/Cookbook.pod b/lib/Jifty/Manual/Cookbook.pod
index fd756ef..84d689a 100644
--- a/lib/Jifty/Manual/Cookbook.pod
+++ b/lib/Jifty/Manual/Cookbook.pod
@@ -434,11 +434,8 @@ Everything should work as expected.
 
     use lib '/path/to/MyApp/lib';
 
-    use Jifty::Everything;
-    BEGIN { Jifty->new; }
-
-    Jifty->web->request(Jifty::Request->new);
-    Jifty->web->response(Jifty::Response->new);
+    use Jifty;
+    BEGIN { Jifty->new(no_request => 1); }
 
     use MyApp::Model::Foo;
     use MyApp::Action::FrobFoo;

-----------------------------------------------------------------------


More information about the Jifty-commit mailing list