cvs commit: p5ee/App-Context/lib/App Context.pm

[email protected] (Stephen Adkins)
Newsgroups perl.cvs.p5ee
Message-ID <[email protected]>
cvsuser     05/11/07 19:44:42

  Modified:    App-Context/lib/App Context.pm
  Log:
  add _so_get() and {temporary} widgets
  
  Revision  Changes    Path
  1.23      +27 -3     p5ee/App-Context/lib/App/Context.pm
  
  Index: Context.pm
  ===================================================================
  RCS file: /cvs/public/p5ee/App-Context/lib/App/Context.pm,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- Context.pm	27 Sep 2005 16:51:28 -0000	1.22
  +++ Context.pm	8 Nov 2005 03:44:42 -0000	1.23
  @@ -546,6 +546,9 @@
       # This is really handy when you have something like a huge spreadsheet
       # of text entry cells (usually an indexed variable).
   
  +    if (defined $args->{temporary}) {            # may be specified implicitly
  +        $lightweight = 1;
  +    }
       if (defined $args->{lightweight}) {          # may be specified explicitly
           $lightweight = $args->{lightweight};
       }
  @@ -603,8 +606,10 @@
               if ($App::DEBUG && $self->dbg(3));
   
           bless $service, $class;            # bless the service into the class
  -        $session->{cache}{$type}{$name} = $service;       # save in the cache
  -        $service->_init();                # perform additional initializations
  +        if (!$service->{temporary}) {
  +            $session->{cache}{$type}{$name} = $service;   # save in the cache
  +        }
  +        $service->_init();               # perform additional initializations
       }
   
       $self->dbgprint("Context->service() = $service")
  @@ -890,6 +895,25 @@
       return $value;
   }
   
  +# This is a very low-level _so_get() suitable for use within the App-Context
  +# framework.  It requires you to separate $name and $var yourself.
  +
  +sub _so_get {
  +    &App::sub_entry if ($App::trace);
  +    my ($self, $name, $var, $default) = @_;
  +
  +    my $value = $self->{session}{cache}{SessionObject}{$name}{$var};
  +    if (! defined $value) {
  +        $value = $self->{session}{store}{SessionObject}{$name}{$var};
  +        if (! defined $value) {
  +            $value = $self->{conf}{SessionObject}{$name}{$var};
  +        }
  +    }
  +
  +    &App::sub_exit($value) if ($App::trace);
  +    return $value;
  +}
  +
   #############################################################################
   # so_set()
   #############################################################################
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.