[Jifty-commit] r1076 - in jifty/branches/jifty-jsan: . lib/Jifty/Request lib/Jifty/Script lib/Jifty/Test/WWW lib/Jifty/Web lib/Jifty/Web/Form lib/Jifty/Web/Form/Field share/web/static/css share/web/templates/__jifty share/web/templates/__jifty/admin/fragments/list t t/Continuations/t t/Mapper/t

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Wed May 17 20:12:01 EDT 2006


Author: trs
Date: Wed May 17 20:11:43 2006
New Revision: 1076

Modified:
   jifty/branches/jifty-jsan/   (props changed)
   jifty/branches/jifty-jsan/AUTHORS
   jifty/branches/jifty-jsan/Makefile.PL
   jifty/branches/jifty-jsan/lib/Jifty/Action.pm
   jifty/branches/jifty-jsan/lib/Jifty/Dispatcher.pm
   jifty/branches/jifty-jsan/lib/Jifty/Plugin.pm
   jifty/branches/jifty-jsan/lib/Jifty/Request.pm
   jifty/branches/jifty-jsan/lib/Jifty/Request/Mapper.pm
   jifty/branches/jifty-jsan/lib/Jifty/Script/Plugin.pm
   jifty/branches/jifty-jsan/lib/Jifty/Test/WWW/Mechanize.pm
   jifty/branches/jifty-jsan/lib/Jifty/Util.pm
   jifty/branches/jifty-jsan/lib/Jifty/Web.pm
   jifty/branches/jifty-jsan/lib/Jifty/Web/Form/Clickable.pm
   jifty/branches/jifty-jsan/lib/Jifty/Web/Form/Field/Checkbox.pm
   jifty/branches/jifty-jsan/lib/Jifty/Web/Form/Field/Password.pm
   jifty/branches/jifty-jsan/lib/Jifty/Web/Form/Field/Select.pm
   jifty/branches/jifty-jsan/lib/Jifty/Web/PageRegion.pm
   jifty/branches/jifty-jsan/share/web/static/css/forms.css
   jifty/branches/jifty-jsan/share/web/templates/__jifty/admin/fragments/list/list
   jifty/branches/jifty-jsan/share/web/templates/__jifty/admin/fragments/list/new_item
   jifty/branches/jifty-jsan/share/web/templates/__jifty/admin/fragments/list/update
   jifty/branches/jifty-jsan/share/web/templates/__jifty/admin/fragments/list/view
   jifty/branches/jifty-jsan/share/web/templates/__jifty/autocomplete.xml
   jifty/branches/jifty-jsan/t/01-version_checks.t
   jifty/branches/jifty-jsan/t/Continuations/t/01-raw-api.t
   jifty/branches/jifty-jsan/t/Mapper/t/01-raw-api.t

Log:
 r12287 at zot (orig r1053):  jesse | 2006-05-13 21:26:31 -0400
  r13574 at hualien:  jesse | 2006-05-13 18:57:35 -0400
  * Clobber the user's HTTP proxy before running tests - Thanks to Matt Trout
 
 r12288 at zot (orig r1054):  seanmil | 2006-05-14 09:27:07 -0400
  r64 at localhost:  sean | 2006-05-14 09:24:10 -0400
  * Fix for inconsistent state_variable handling, move to using
    the request to store all state_variables
 
 r12289 at zot (orig r1055):  jesse | 2006-05-14 16:41:23 -0400
  r13578 at hualien:  jesse | 2006-05-14 16:40:41 -0400
  * The new dispatcher hash magic didn't work right with the BTDT dispatcher
 
 r12333 at zot (orig r1056):  seanmil | 2006-05-14 21:51:20 -0400
  r68 at localhost:  sean | 2006-05-14 21:48:50 -0400
  * Fix autocompletes so that the simple list method that was
    documented now works.
  
  * Document the autocomplete hash reference return value method
    already in the code.
 
 r12334 at zot (orig r1057):  jesse | 2006-05-15 08:28:10 -0400
  r13791 at hualien:  jesse | 2006-05-15 08:26:05 -0400
   The third attachment is for the Password widget which has already
   a render_value method but which returns '-' only, without rendering any HTML.
    The patch modify this behaviour by rendering the instead of returning it.
    - Frederic Blanc
 
 r12335 at zot (orig r1058):  jesse | 2006-05-15 08:28:39 -0400
  r13792 at hualien:  jesse | 2006-05-15 08:26:34 -0400
   The second attachment is a patch for the Checkbox widget as I think
   a checbox checked accordingly the current_value is nicer than the raw value.
  
   - Frederic Blank
  
 
 r12336 at zot (orig r1059):  jesse | 2006-05-15 08:28:56 -0400
  r13793 at hualien:  jesse | 2006-05-15 08:27:04 -0400
   My app uses some columns that refers_to other table, and I find that
   the default rendering of such column is inconsistent between update/create
   modes and the read one:
    the update/create versions use a select field that displays values of
    the name column of the target table (of the name method if exists, the id
    otherwise) whereas the "view" version uses the default render_value method
    of Field.pm, and thus displays the id of the target row (which is not
    the expected result IMHO.)
  
  
    - Frederic Blank  
  
 
 r12337 at zot (orig r1060):  jesse | 2006-05-15 08:40:54 -0400
  r13798 at hualien:  jesse | 2006-05-15 08:40:18 -0400
  * Win32 cleanups from Kenichi Ishigaki
 
 r12338 at zot (orig r1061):  jesse | 2006-05-15 08:48:34 -0400
  r13800 at hualien:  jesse | 2006-05-15 08:48:24 -0400
  * Adding a bit of missing doc
 
 r12339 at zot (orig r1062):  ishigaki | 2006-05-15 09:54:06 -0400
 Add myself to AUTHORS
 r12340 at zot (orig r1063):  jesse | 2006-05-15 09:54:36 -0400
  r13802 at hualien:  jesse | 2006-05-15 09:54:21 -0400
  * Kenichi pointed out a typo
 
 r12343 at zot (orig r1066):  alexmv | 2006-05-15 17:28:23 -0400
  r13019 at zoq-fot-pik:  chmrr | 2006-05-15 17:25:14 -0400
   * Wording fixes
 
 r12344 at zot (orig r1067):  alexmv | 2006-05-15 17:28:32 -0400
  r13020 at zoq-fot-pik:  chmrr | 2006-05-15 17:26:31 -0400
   * Don't use the same escape character for mapping as we use for
  submit query argument joining
 
 r12345 at zot (orig r1068):  alexmv | 2006-05-15 17:28:40 -0400
  r13021 at zoq-fot-pik:  chmrr | 2006-05-15 17:27:16 -0400
   * To pageregion mapping earlier
 
 r12346 at zot (orig r1069):  alexmv | 2006-05-15 17:28:46 -0400
  r13022 at zoq-fot-pik:  chmrr | 2006-05-15 17:27:50 -0400
   * Allow Jifty->web->region($region) to do the right thing; this
  avoids having to do the tedious ->enter, ->render, ->exit
 
 r12347 at zot (orig r1070):  seanmil | 2006-05-15 19:54:05 -0400
  r81 at localhost:  sean | 2006-05-15 19:53:14 -0400
  * Proper fix (hopefully) for state variable handling in Jifty::Web
 
 r12348 at zot (orig r1071):  alexmv | 2006-05-16 13:27:37 -0400
  r13031 at zoq-fot-pik:  chmrr | 2006-05-16 13:27:30 -0400
   * ->render on page regions now calls ->enter, outputs via Jifty->out,
     calls ->exit, and returns an empty string -- this breaks backwards
     compatibility.  The previous functionality is accessible via
     ->as_string
  
   * Revert r1069 -- use the more sensible $region->render for this
  
   * Regions now establish their qualified names and parents at creation
     time, which means they can be referred to before they are rendered
     now.  This was not previously the case because I was imagining
     pathological cases where a region was created in one region, and
     passed to inside another region before being rendered.  However,
     this is impossible, as references cannot pass region boundries.
     This removes the cumbersome restriction that qualified names be
     established only at render-time.
 
 r12349 at zot (orig r1072):  ishigaki | 2006-05-16 15:01:45 -0400
 now jifty requries Jifty::DBI 0.21
 r12350 at zot (orig r1073):  jesse | 2006-05-16 16:59:06 -0400
  r13826 at hualien:  jesse | 2006-05-16 16:58:49 -0400
  * Cleaned up the admin ui css a little bit so it renders a bit more right
 
 r12351 at zot (orig r1074):  alexmv | 2006-05-16 17:46:07 -0400
  r13038 at zoq-fot-pik:  chmrr | 2006-05-16 17:44:35 -0400
   * Mention jifty plugin --name
 
 r12352 at zot (orig r1075):  alexmv | 2006-05-16 17:46:14 -0400
  r13039 at zoq-fot-pik:  chmrr | 2006-05-16 17:45:38 -0400
   * Requests know the top-level request
   * mason_internal_error's "try again" is to top level request
 


Modified: jifty/branches/jifty-jsan/AUTHORS
==============================================================================
--- jifty/branches/jifty-jsan/AUTHORS	(original)
+++ jifty/branches/jifty-jsan/AUTHORS	Wed May 17 20:11:43 2006
@@ -8,3 +8,4 @@
 Eric Wilhelm <ewilhelm at cpan.org>
 Nelson Elhage <nelhage at mit.edu>
 Sean E Millichamp <sean at enertronllc.com>
+Kenichi Ishigaki <ishigaki at tcool.org>

Modified: jifty/branches/jifty-jsan/Makefile.PL
==============================================================================
--- jifty/branches/jifty-jsan/Makefile.PL	(original)
+++ jifty/branches/jifty-jsan/Makefile.PL	Wed May 17 20:11:43 2006
@@ -31,7 +31,7 @@
 requires('HTTP::Server::Simple::Recorder');
 requires('Hash::Merge');
 requires('Hook::LexWrap');
-requires('Jifty::DBI' => '0.16' );            # Jifty::DBI::Collection Jifty::DBI::Handle Jifty::DBI::Record::Cachable Jifty::DBI::SchemaGenerator
+requires('Jifty::DBI' => '0.21' );            # Jifty::DBI::Collection Jifty::DBI::Handle Jifty::DBI::Record::Cachable Jifty::DBI::SchemaGenerator
 requires('Locale::Maketext::Extract' => '0.20');
 requires('Locale::Maketext::Lexicon' => '0.60');
 requires('Log::Log4perl');

Modified: jifty/branches/jifty-jsan/lib/Jifty/Action.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Action.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Action.pm	Wed May 17 20:11:43 2006
@@ -706,7 +706,12 @@
 
 =head2 _autocomplete_argument ARGUMENT
 
-Get back a list of possible completions for C<ARGUMENT>.
+Get back a list of possible completions for C<ARGUMENT>.  The list
+should either be a list of scalar values or a list of hash references.
+Each hash reference must have a key named C<value>.  There can also
+additionally be a key named C<label> which, if present, will be used
+as the user visible label.  If C<label> is not present then the
+contents of C<value> will be used for the label.
 
 If the field has an attribute named B<autocompleter>, call the
 subroutine reference B<autocompleter> points to.

Modified: jifty/branches/jifty-jsan/lib/Jifty/Dispatcher.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Dispatcher.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Dispatcher.pm	Wed May 17 20:11:43 2006
@@ -359,7 +359,7 @@
     my($pkg, $rule) = @_;
     my $op = $rule->[0];
     my $ruleset;
-    if ( ($op eq "before" or $op eq "after") and ref $rule->[1] and $rule->[1]{plugin} ) {
+    if ( ($op eq "before" or $op eq "after") and ref $rule->[1] and ref $rule->[1] eq 'HASH' and $rule->[1]{plugin} ) {
         $ruleset = 'RULES_DEFERRED';
     } elsif ( $op eq 'before' ) {
         $ruleset = 'RULES_SETUP';
@@ -1036,7 +1036,7 @@
         # Save the request away, and redirect to an error page
         Jifty->web->response->error($err);
         my $c = Jifty::Continuation->new(
-            request  => Jifty->web->request,
+            request  => Jifty->web->request->top_request,
             response => Jifty->web->response,
             parent   => Jifty->web->request->continuation,
         );

Modified: jifty/branches/jifty-jsan/lib/Jifty/Plugin.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Plugin.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Plugin.pm	Wed May 17 20:11:43 2006
@@ -11,7 +11,9 @@
 
 Plugins are like mini-apps.  They come in packages with share
 directories which provide static and template files; they provide
-actions; they have dispatcher rules.
+actions; they have dispatcher rules.  To create the skeleton of a new
+plugin, you can use the command:
+    jifty plugin --name SomePlugin
 
 To use a plugin in your Jifty application, find the C<Plugins:> line
 in the C<config.yml> file:

Modified: jifty/branches/jifty-jsan/lib/Jifty/Request.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Request.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Request.pm	Wed May 17 20:11:43 2006
@@ -4,7 +4,7 @@
 package Jifty::Request;
 
 use base qw/Jifty::Object Class::Accessor::Fast Clone/;
-__PACKAGE__->mk_accessors(qw(is_subrequest arguments just_validating path _continuation));
+__PACKAGE__->mk_accessors(qw(_top_request arguments just_validating path _continuation));
 
 use Jifty::JSON;
 use Jifty::YAML;
@@ -712,6 +712,37 @@
         delete $self->arguments->{$_};
         $self->argument($key => $value);
     }
+    for ($self->state_variables) {
+        my ($key, $value) = Jifty::Request::Mapper->map(destination => $_->key, source => $_->value, %args);
+        next unless $key ne $_;
+        $self->remove_state_variable($_->key);
+        $self->add_state_variable(key => $key, value => $value);
+    }
+}
+
+=head2 is_subrequest
+
+Returns true if this request is a subrequest.
+
+=cut
+
+sub is_subrequest {
+    my $self = shift;
+    return $self->_top_request ? 1 : undef;
+}
+
+=head2 top_request
+
+Returns the top-level request for this request; if this is a
+subrequest, this is the user-created request that the handler got
+originally.  Otherwise, returns itself;
+
+=cut
+
+sub top_request {
+    my $self = shift;
+    $self->_top_request(@_) if @_;
+    return $self->_top_request || $self;
 }
 
 package Jifty::Request::Action;

Modified: jifty/branches/jifty-jsan/lib/Jifty/Request/Mapper.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Request/Mapper.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Request/Mapper.pm	Wed May 17 20:11:43 2006
@@ -82,7 +82,7 @@
 
                 my $type = ($_ =~ /result/) ? "R" : "A";
 
-                $return{"J:M-$key"} = join("|", $type, $moniker, $name);
+                $return{"J:M-$key"} = join("`", $type, $moniker, $name);
             }
         } else {
             $return{$key} = $parameters{$key};
@@ -141,7 +141,7 @@
 
     my $destination = $1;
 
-    my @bits = split( /\|/, $args{source} );
+    my @bits = split( /\`/, $args{source} );
     if ( $bits[0] ) {
         if ( $bits[0] eq "A" and @bits == 3 ) {
             return ( $destination => undef ) unless $args{request}->action( $bits[1] );

Modified: jifty/branches/jifty-jsan/lib/Jifty/Script/Plugin.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Script/Plugin.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Script/Plugin.pm	Wed May 17 20:11:43 2006
@@ -38,8 +38,8 @@
 
 =head2 run
 
-Create a directory for the application, a skeleton directory
-structure, and a C<Makefile.PL> for you application.
+Create a directory for the plugin, a skeleton directory structure, and
+a C<Makefile.PL> for your plugin.
 
 =cut
 
@@ -48,7 +48,7 @@
 
     $self->prefix( $self->{name} ||''); 
 
-    unless ($self->prefix =~ /\w+/ ) { die "You need to give your new Jifty app a --name"."\n";}
+    unless ($self->prefix =~ /\w+/ ) { die "You need to give your new Jifty plugin a --name"."\n";}
     $self->prefix( $self->prefix );
 
     # Turn my-plugin-name into My::Plugin::Name.
@@ -124,7 +124,7 @@
     @dirs = (@dirs, $self->_directories); 
 
     foreach my $dir (@dirs) {
-        $dir =~ s/__APP__/$self->lib_dir/e;
+        $dir =~ s/__LIB__/$self->lib_dir/e;
         print("Creating directory $dir\n");
         mkdir( $self->prefix."/$dir") or die "Can't create ". $self->prefix."/$dir: $!";
     }
@@ -138,8 +138,8 @@
         share/web
         share/web/templates
         share/web/static
-        lib/__APP__/Model
-        lib/__APP__/Action
+        lib/__LIB__/Model
+        lib/__LIB__/Action
         t
     );
 }

Modified: jifty/branches/jifty-jsan/lib/Jifty/Test/WWW/Mechanize.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Test/WWW/Mechanize.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Test/WWW/Mechanize.pm	Wed May 17 20:11:43 2006
@@ -4,6 +4,8 @@
 package Jifty::Test::WWW::Mechanize;
 use base qw/Test::WWW::Mechanize/;
 
+$ENV{'http_proxy'} = ''; # Otherwise Test::WWW::Mechanize tries to go through your HTTP proxy
+
 use Test::HTML::Lint; # exports html_ok
 use HTTP::Cookies;
 use XML::XPath;

Modified: jifty/branches/jifty-jsan/lib/Jifty/Util.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Util.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Util.pm	Wed May 17 20:11:43 2006
@@ -19,6 +19,7 @@
 use UNIVERSAL::require;
 use ExtUtils::MakeMaker ();
 use Cwd ();
+use Config;
 
 # Trivial memoization to ward off evil Cwd calls.
 use vars qw/%ABSOLUTE_PATH $JIFTY_ROOT $SHARE_ROOT $APP_ROOT/;
@@ -114,9 +115,16 @@
         while (@root) {
             my $try = File::Spec->catdir( @root, "bin", "jifty" );
             if (    -e $try
-                and (-x $try or MM->maybe_command($try))
-                and $try ne "/usr/bin/jifty"
-                and $try ne "/usr/local/bin/jifty" )
+                # XXX: Just a quick hack
+                # MSWin32's 'maybe_command' sees only file extension.
+                # Maybe we should check 'jifty.bat' instead on Win32,
+                # if it is (or would be) provided.
+                # Also, /usr/bin or /usr/local/bin should be taken from
+                # %Config{bin} or %Config{scriptdir} or something like that
+                # for portablility.
+                and (-x $try or MM->maybe_command($try) or $^O eq 'MSWin32')
+                and $try ne File::Spec->catdir($Config{bin}, "jifty")
+                and $try ne File::Spec->catdir($Config{scriptdir}, "jifty") )
             {
                 return $APP_ROOT = File::Spec->catdir(@root);
             }
@@ -126,7 +134,7 @@
     warn "Can't guess application root from current path ("
         . Cwd::cwd()
         . ") or bin path ($FindBin::Bin)\n";
-    return undef;
+    return ''; # returning undef causes tons of 'uninitialized...' warnings.
 }
 
 =head2 default_app_name
@@ -175,6 +183,13 @@
     my $self = shift;
     my $class = shift;
 
+    # Quick hack to silence warnings.
+    # Maybe some dependencies were lost.
+    unless ($class) {
+        Jifty->log->error(sprintf("no class was given at %s line %d\n", (caller)[1,2]));
+        return 0;
+    }
+
     my $path =  join('/', split(/::/,$class)).".pm";
     return 1 if $INC{$path};
 

Modified: jifty/branches/jifty-jsan/lib/Jifty/Web.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Web.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Web.pm	Wed May 17 20:11:43 2006
@@ -466,7 +466,8 @@
 
     if ($self->next_page
         and ( ( $self->next_page ne $self->request->path )
-            or $self->request->state_variables )
+            or $self->request->state_variables
+            or $self->{'state_variables'} )
         )
     {
         return (1);
@@ -493,12 +494,15 @@
 
     if (   $self->response->results
         or $self->request->state_variables
+        or $self->{'state_variables'}
         or @unrun )
     {
         my $request = Jifty::Request->new();
         $request->path($page);
         $request->add_state_variable( key => $_->key, value => $_->value )
           for $self->request->state_variables;
+        $request->add_state_variable( key => $_, value => $self->{'state_variables'}->{$_} )
+          for keys %{ $self->{'state_variables'} };
         for (@unrun) {
             $request->add_action(
                 moniker   => $_->moniker,
@@ -910,32 +914,23 @@
     return $self->{'regions'}{$name};
 }
 
-=head3 region PARAMHASH, 
+=head3 region PARAMHASH
 
-Creates and renders a L<Jifty::Web::PageRegion>; the C<PARAMHASH> is
-passed directly to its L<Jifty::Web::PageRegion/new> method.  The
-region is then L<Jifty::Web::PageRegion/enter>ed, then
-L<Jifty::Web::PageRegion/render>ed, and finally
-L<Jifty::Web::PageRegion/exit>ed.
+The provided PARAMHASH is used to create and render a
+L<Jifty::Web::PageRegion>; the C<PARAMHASH> is passed directly to its
+L<Jifty::Web::PageRegion/new> method, and then
+L<Jifty::Web::PageRegion/render> is called.
 
 =cut
 
 sub region {
     my $self = shift;
 
-    # Add ourselves to the region stack
-    my $region = Jifty::Web::PageRegion->new(@_) or return;
-
-    # Enter the region
-    $region->enter;
+    # Create a region
+    my $region = Jifty::Web::PageRegion->new(@_) or return; 
 
     # Render it
-    $self->out( $region->render );
-
-    # Exit it when we're done
-    $region->exit;
-    
-    "";
+    $region->render;
 }
 
 =head3 current_region
@@ -952,16 +947,18 @@
         : undef;
 }
 
-=head3 qualified_region
+=head3 qualified_region [REGION]
 
 Returns the fully qualified name of the current
-L<Jifty::Web::PageRegion>, or the empty string if there is none..
+L<Jifty::Web::PageRegion>, or the empty string if there is none.  If
+C<REGION> is supplied, gives the qualified name of C<REGION> were it
+placed in the current region.
 
 =cut
 
 sub qualified_region {
     my $self = shift;
-    return join( "-", map { $_->name } @{ $self->{'region_stack'} || [] } );
+    return join( "-", map { $_->name } @{ $self->{'region_stack'} || [] }, @_ );
 }
 
 =head3 serve_fragments
@@ -1001,7 +998,7 @@
 
         # Stuff the rendered region into the XML
         $writer->startTag( "fragment", id => Jifty->web->current_region->qualified_name );
-        $writer->cdata( Jifty->web->current_region->render );
+        $writer->cdata( Jifty->web->current_region->as_string );
         $writer->endTag();
 
         Jifty->web->current_region->exit while Jifty->web->current_region;

Modified: jifty/branches/jifty-jsan/lib/Jifty/Web/Form/Clickable.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Web/Form/Clickable.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Web/Form/Clickable.pm	Wed May 17 20:11:43 2006
@@ -262,12 +262,13 @@
     my $self = shift;
     my ( $region, $fragment ) = @_;
 
-    my $defaults = Jifty->web->get_region($region);
+    my $name = ref $region ? $region->qualified_name : $region;
+    my $defaults = Jifty->web->get_region($name);
 
     if ( $defaults and $fragment eq $defaults->default_path ) {
-        $self->state_variable( "region-$region" => undef, $fragment );
+        $self->state_variable( "region-$name" => undef, $fragment );
     } else {
-        $self->state_variable( "region-$region" => $fragment );
+        $self->state_variable( "region-$name" => $fragment );
     }
 }
 
@@ -282,12 +283,13 @@
     my $self = shift;
     my ( $region, $argument, $value ) = @_;
 
-    my $defaults = Jifty->web->get_region($region);
+    my $name = ref $region ? $region->qualified_name : $region;
+    my $defaults = Jifty->web->get_region($name);
 
     if ( $defaults and $value eq $defaults->default_argument($argument) ) {
-        $self->state_variable( "region-$region.$argument" => undef, $value );
+        $self->state_variable( "region-$name.$argument" => undef, $value );
     } else {
-        $self->state_variable( "region-$region.$argument" => $value );
+        $self->state_variable( Jifty::Request::Mapper->query_parameters( "region-$name.$argument" => $value ) );
     }
 
 }
@@ -464,7 +466,7 @@
         next unless $value;
         my @hooks = ref $value eq "ARRAY" ? @{$value} : ($value);
         for my $hook (@hooks) {
-            $hook->{region} ||= Jifty->web->qualified_region;
+            $hook->{region} ||= $hook->{refresh} || Jifty->web->qualified_region;
             $hook->{args}   ||= {};
 
             $self->region_fragment( $hook->{region}, $hook->{replace_with} )

Modified: jifty/branches/jifty-jsan/lib/Jifty/Web/Form/Field/Checkbox.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Web/Form/Field/Checkbox.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Web/Form/Field/Checkbox.pm	Wed May 17 20:11:43 2006
@@ -41,6 +41,27 @@
     '';
 }
 
+=head2 render_value
+
+Renders value as a checkbox widget.
+
+=cut
+
+sub render_value {
+    my $self  = shift;
+    my $field .= qq!<input type="checkbox"!;
+    $field .= qq! name="@{[ $self->input_name ]}"!;
+    $field .= qq! id="@{[ $self->element_id ]}"!;
+    $field .= qq! value="@{[$self->value ||1]}"!;
+    $field .= $self->_widget_class;
+    $field .= qq! checked="checked"! if ($self->checked or $self->current_value);
+    $field .= qq! disabled readonly!;
+    $field .= qq! />\n!;
+
+    Jifty->web->out($field);
+    return '';
+}
+
 =head2 javascript_preempt
 
 By default, javascript (such as onclick handlers) should not actually

Modified: jifty/branches/jifty-jsan/lib/Jifty/Web/Form/Field/Password.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Web/Form/Field/Password.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Web/Form/Field/Password.pm	Wed May 17 20:11:43 2006
@@ -40,7 +40,8 @@
 
 
 sub render_value {
-    return '-';
+    Jifty->web->out('-');
+    return '';
 }
 
 =head2 classes

Modified: jifty/branches/jifty-jsan/lib/Jifty/Web/Form/Field/Select.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Web/Form/Field/Select.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Web/Form/Field/Select.pm	Wed May 17 20:11:43 2006
@@ -33,4 +33,29 @@
     '';
 }
 
+
+=head2 render_value
+
+Rather than rendering the "key" side of our value for this field, render
+what would actually display to the user in the select-box
+
+=cut
+
+
+sub render_value {
+    my $self  = shift;
+    my $field = '<span';
+    $field .= qq! class="@{[ $self->classes ]}"> !;
+    my $value = $self->current_value;
+    if(defined $value) {
+        my @value = grep { $_->{value} eq $value }
+                        @{ $self->action->available_values($self->name) };
+        $value = $value[0]->{display} if scalar @value;
+    }
+    $field .= HTML::Entities::encode_entities(_($value)) if defined $value;
+    $field .= qq!</span>\n!;
+    Jifty->web->out($field);
+    return '';
+}
+
 1;

Modified: jifty/branches/jifty-jsan/lib/Jifty/Web/PageRegion.pm
==============================================================================
--- jifty/branches/jifty-jsan/lib/Jifty/Web/PageRegion.pm	(original)
+++ jifty/branches/jifty-jsan/lib/Jifty/Web/PageRegion.pm	Wed May 17 20:11:43 2006
@@ -81,12 +81,18 @@
     }
 
     $self->name($args{name});
+    $self->qualified_name(Jifty->web->qualified_region($self));
     $self->default_path($args{path});
     $self->default_arguments($args{defaults});
     $self->arguments({});
-    $self->parent($args{parent});
+    $self->parent($args{parent} || Jifty->web->current_region);
     $self->region_wrapper(not $args{_bootstrap} and $args{region_wrapper});
 
+    # Keep track of the fully qualified name (which should be unique)
+    $self->log->warn("Repeated region: " . $self->qualified_name)
+        if Jifty->web->get_region( $self->qualified_name );
+    Jifty->web->{'regions'}{ $self->qualified_name } = $self;
+
     return $self;
 }
 
@@ -180,17 +186,8 @@
 sub enter {
     my $self = shift;
 
-    $self->log->warn("Region occurred in more than once place: ".$self->qualified_name)
-      if (defined $self->parent and $self->parent != Jifty->web->current_region);
-
-    $self->parent(Jifty->web->current_region);
+    # Add ourselves to the region stack
     push @{Jifty->web->{'region_stack'}}, $self;
-    $self->qualified_name(Jifty->web->qualified_region);
-
-    # Keep track of the fully qualified name (which should be unique)
-    $self->log->warn("Repeated region: " . $self->qualified_name)
-        if Jifty->web->get_region( $self->qualified_name ) and Jifty->web->get_region( $self->qualified_name ) ne $self;
-    Jifty->web->{'regions'}{ $self->qualified_name } = $self;
 
     # Merge in the settings passed in via state variables
     for (Jifty->web->request->state_variables) {
@@ -223,42 +220,33 @@
     }
 }
 
-=head2 render
+=head2 as_string
 
-Returns a string of the fragment and associated javascript.
+Deals with the bulk of the effort to show a page region.  Returns a
+string of the fragment and associated javascript (if any).
 
 =cut
 
-sub render {
+sub as_string {
     my $self = shift;
 
+    if (Jifty->web->current_region ne $self) {
+        # XXX TODO: Possibly we should just call ->enter
+        warn "Attempt to call as_string on a region which is not the current region";
+        return "";
+    }
+    
     my %arguments = %{ $self->arguments };
 
     # undef arguments cause warnings. We hatesses the warnings, we do.
     defined $arguments{$_} or delete $arguments{$_} for keys %arguments;
     my $result = "";
 
-    # Map out the arguments
-    for ( keys %arguments ) {
-        my ( $key, $value ) = Jifty::Request::Mapper->map(
-            destination => $_,
-            source      => $arguments{$_}
-        );
-        next unless $key ne $_;
-        delete $arguments{$_};
-        $arguments{$key} = $value;
-    }
-
-    # We need to tell the browser this is a region and
-    # what its default arguments are as well as the path of the "fragment".
-
-    # We do this by passing in a snippet of javascript which encodes this
-    # information.
-
-# Alex is sad about: Anything which is replaced _must_ start life as a fragment.
-# We don't have a good answer for this yet.
-
-# We only render the region wrapper if we're asked to (which is true by default)
+    # We need to tell the browser this is a region and what its
+    # default arguments are as well as the path of the "fragment".  We
+    # do this by passing in a snippet of javascript which encodes this
+    # information.  We only render this region wrapper if we're asked
+    # to (which is true by default)
     if ( $self->region_wrapper ) {
         $result .= qq|<script type="text/javascript">\n|
             . qq|new Region('| . $self->qualified_name . qq|',|
@@ -279,17 +267,15 @@
     my $subrequest = Jifty::Request->new;
     $subrequest->from_webform(%arguments);
     $subrequest->path( $self->path );
+    $subrequest->top_request( Jifty->web->request->top_request );
 
     # Remove all of the actions
     $subrequest->clear_actions;
-    $subrequest->is_subrequest(1);
     local Jifty->web->{request} = $subrequest;
 
-    # While we're inside this region, # have Mason to tack its response
+    # While we're inside this region, have Mason to tack its response
     # onto a variable and not send headers when it does so
-
-    # XXX TODO: this internals diving is icky
-
+    #XXX TODO: There's gotta be a better way to localize it
     my $region_content = '';
     Jifty->handler->mason->interp->out_method( \$region_content );
 
@@ -298,12 +284,27 @@
     $result .= $region_content;
     $result .= qq|</div>| if ( $self->region_wrapper );
 
-    #XXX TODO: There's gotta be a better way to localize it
     Jifty->handler->mason->interp->out_method( \&Jifty::View::Mason::Handler::out_method );
 
     return $result;
 }
 
+=head2 render
+
+Calls L</enter>, outputs the results of L</as_string>, and then calls
+L</exit>.  Returns an empty string.
+
+=cut
+
+sub render {
+    my $self = shift;
+
+    $self->enter;
+    Jifty->web->out($self->as_string);
+    $self->exit;
+    "";
+}
+
 =head2 get_element [RULES]
 
 Returns a CSS2 selector which selects only elements under this region

Modified: jifty/branches/jifty-jsan/share/web/static/css/forms.css
==============================================================================
--- jifty/branches/jifty-jsan/share/web/static/css/forms.css	(original)
+++ jifty/branches/jifty-jsan/share/web/static/css/forms.css	Wed May 17 20:11:43 2006
@@ -119,6 +119,12 @@
 }
 
 
+/* So the admin ui is one row per line */
+
+.jifty_admin.item.inline {
+     clear: both;
+ }
+
 div.subline {
     display: inline;
     float: left;  

Modified: jifty/branches/jifty-jsan/share/web/templates/__jifty/admin/fragments/list/list
==============================================================================
--- jifty/branches/jifty-jsan/share/web/templates/__jifty/admin/fragments/list/list	(original)
+++ jifty/branches/jifty-jsan/share/web/templates/__jifty/admin/fragments/list/list	Wed May 17 20:11:43 2006
@@ -19,7 +19,7 @@
 % if ($collection->pager->last_page > 1) {
     <span class="page-count">Page <% $page %> of <% $collection->pager->last_page %></span>   
 % }
-<dl class="list">
+<div class="list">
 <%perl>
 while ( my $item = $collection->next ) {
     Jifty->web->region(
@@ -30,7 +30,7 @@
 }
 
 </%perl>
-</dl>
+</div>
 
 <div class="paging">
 % if ($collection->pager->previous_page) {

Modified: jifty/branches/jifty-jsan/share/web/templates/__jifty/admin/fragments/list/new_item
==============================================================================
--- jifty/branches/jifty-jsan/share/web/templates/__jifty/admin/fragments/list/new_item	(original)
+++ jifty/branches/jifty-jsan/share/web/templates/__jifty/admin/fragments/list/new_item	Wed May 17 20:11:43 2006
@@ -6,7 +6,7 @@
 my $record_class =  Jifty->config->framework('ApplicationClass')."::Model::".$object_type;
  my $create = Jifty->web->new_action(class => 'Create'.$object_type);
 </%init>
-<div class="create item inline">
+<div class="jifty_admin create item inline">
 % foreach my $argument ($create->argument_names) {
         <%$create->form_field($argument)%>
 %}

Modified: jifty/branches/jifty-jsan/share/web/templates/__jifty/admin/fragments/list/update
==============================================================================
--- jifty/branches/jifty-jsan/share/web/templates/__jifty/admin/fragments/list/update	(original)
+++ jifty/branches/jifty-jsan/share/web/templates/__jifty/admin/fragments/list/update	Wed May 17 20:11:43 2006
@@ -12,7 +12,7 @@
     record  => $record
 );
 </%init>
-<div class="update record inline <%$object_type%>">
+<div class="jifty_admin update item inline <%$object_type%>">
 % foreach my $argument ($update->argument_names) {
 <%$update->form_field($argument)%>
 %}

Modified: jifty/branches/jifty-jsan/share/web/templates/__jifty/admin/fragments/list/view
==============================================================================
--- jifty/branches/jifty-jsan/share/web/templates/__jifty/admin/fragments/list/view	(original)
+++ jifty/branches/jifty-jsan/share/web/templates/__jifty/admin/fragments/list/view	Wed May 17 20:11:43 2006
@@ -12,7 +12,7 @@
     record  => $record
 );
 </%init>
-<div class="read item inline">
+<div class="jifty_admin read item inline">
 % foreach my $argument ($update->argument_names) {
 <%$update->form_field($argument, render_mode => 'read')%>
 % }
@@ -28,6 +28,4 @@
 
         )
 %>
-
-
 </div>

Modified: jifty/branches/jifty-jsan/share/web/templates/__jifty/autocomplete.xml
==============================================================================
--- jifty/branches/jifty-jsan/share/web/templates/__jifty/autocomplete.xml	(original)
+++ jifty/branches/jifty-jsan/share/web/templates/__jifty/autocomplete.xml	Wed May 17 20:11:43 2006
@@ -9,7 +9,9 @@
 <body>
 <ul>
 % foreach my $item ( @options) {
-%    if (exists $item->{label}) {
+%    if (!ref($item)) {
+<li><% $item %></li>
+%    } elsif (exists $item->{label}) {
 <li><span class="informal"><% $item->{label} %></span><span style="visibility: hidden"><% $item->{value} %></span></li>
 %    } else {
 <li><% $item->{value} %></li>

Modified: jifty/branches/jifty-jsan/t/01-version_checks.t
==============================================================================
--- jifty/branches/jifty-jsan/t/01-version_checks.t	(original)
+++ jifty/branches/jifty-jsan/t/01-version_checks.t	Wed May 17 20:11:43 2006
@@ -16,6 +16,7 @@
 # just look for Jifty.pm
 my $dir = $INC{'Jifty.pm'};
 $dir =~ s/Jifty\.pm$//;
+$dir = quotemeta $dir;  # as MSWin32 has backslashes in the path
 my @files = grep({$_ =~ m/^$dir/} map({$INC{$_}} grep(/^Jifty\//, keys(%INC))));
 ok(scalar(@files));
 

Modified: jifty/branches/jifty-jsan/t/Continuations/t/01-raw-api.t
==============================================================================
--- jifty/branches/jifty-jsan/t/Continuations/t/01-raw-api.t	(original)
+++ jifty/branches/jifty-jsan/t/Continuations/t/01-raw-api.t	Wed May 17 20:11:43 2006
@@ -41,25 +41,25 @@
 ok($mech->continuation, "With a continuation set");
 
 # Create a continuation using with return values
-$mech->get("$URL/index.html?J:CREATE=1;J:M-foo=A|bar;J:PATH=/index-help.html");
+$mech->get("$URL/index.html?J:CREATE=1;J:M-foo=A`bar;J:PATH=/index-help.html");
 like($mech->uri, qr/index-help.html/, "Got to new page");
 $mech->content_like(qr/help about the index/i, "Correct content on new page");
 ok($mech->continuation, "With a continuation set");
 my $first = $mech->continuation->id;
 
 # Hit same URL again
-$mech->get("$URL/index.html?J:CREATE=1;J:M-foo=A|bar;J:PATH=/index-help.html");
+$mech->get("$URL/index.html?J:CREATE=1;J:M-foo=A`bar;J:PATH=/index-help.html");
 ok($mech->continuation, "Also sets a continuation");
 isnt($first, $mech->continuation->id, "Different continuation this time");
 
 # Create continuation from submit with an action
-$mech->get("$URL/index.html?J:CREATE=1;J:M-foo=A|bar;J:PATH=/index-help.html;J:A-grail=GetGrail");
+$mech->get("$URL/index.html?J:CREATE=1;J:M-foo=A`bar;J:PATH=/index-help.html;J:A-grail=GetGrail");
 $mech->content_unlike(qr/got the grail/i, "Action didn't run");
 ok($mech->continuation->request->action("grail"), "Continuation has the action stored");
 my $pending = $mech->continuation->id;
 
 # Create continuation from submit with action that doesn't validate
-$mech->get("$URL/index.html?J:CREATE=1;J:M-foo=A|bar;J:PATH=/index-help.html;J:A-cross=CrossBridge");
+$mech->get("$URL/index.html?J:CREATE=1;J:M-foo=A`bar;J:PATH=/index-help.html;J:A-cross=CrossBridge");
 $mech->content_unlike(qr/crossed the bridge/i, "action didn't run");
 ok($mech->continuation->response->result("cross")->failure, "Action's result was failure");
 
@@ -99,7 +99,7 @@
 
 #### Nesting
 # Inside one of the existing conts, create a new cont
-$mech->get("$URL/index-help.html?J:C=$first;J:CREATE=1;J:M-troz=A|zort;J:PATH=/help-help.html");
+$mech->get("$URL/index-help.html?J:C=$first;J:CREATE=1;J:M-troz=A`zort;J:PATH=/help-help.html");
 like($mech->uri, qr/help-help.html/, "Got to new page");
 $mech->content_like(qr/help about help/i, "Correct content on new page");
 ok($mech->continuation, "With a continuation set");
@@ -118,7 +118,7 @@
 
 #### Nested returns
 # Inside one of the existing conts, create a new cont with a CALL at the same time
-$mech->get("$URL/index-help.html?J:CALL=$first;J:CREATE=1;J:M|troz=A-zort;J:PATH=/help-help.html");
+$mech->get("$URL/index-help.html?J:CALL=$first;J:CREATE=1;J:M`troz=A-zort;J:PATH=/help-help.html");
 like($mech->uri, qr/help-help.html/, "Got to new page");
 $mech->content_like(qr/help about help/i, "Correct content on new page");
 ok($mech->continuation, "With a continuation set");

Modified: jifty/branches/jifty-jsan/t/Mapper/t/01-raw-api.t
==============================================================================
--- jifty/branches/jifty-jsan/t/Mapper/t/01-raw-api.t	(original)
+++ jifty/branches/jifty-jsan/t/Mapper/t/01-raw-api.t	Wed May 17 20:11:43 2006
@@ -39,52 +39,52 @@
 
 
 #### Flat arguments
-$mech->get("$URL/index.html?J:M-foo=A|bar");
+$mech->get("$URL/index.html?J:M-foo=A`bar");
 $mech->content_like(qr/foo: ~/, "Passing no parameter sets to undef");
 $mech->content_lacks(qr/J:M-foo/, "Doesn't have mapping parameter");
 
-$mech->get("$URL/index.html?J:M-foo=A|bar;bar=baz");
+$mech->get("$URL/index.html?J:M-foo=A`bar;bar=baz");
 $mech->content_like(qr/foo: baz/, "Passing parameter sets to value");
 $mech->content_lacks(qr/J:M-foo/, "Doesn't have mapping parameter");
 
-$mech->get("$URL/index.html?J:M-foo=A|bar;bar=baz;bar=troz");
+$mech->get("$URL/index.html?J:M-foo=A`bar;bar=baz;bar=troz");
 $mech->content_like(qr/bar: &#38;1\s*\n\s+- baz\n\s+- troz/, "Multiple parameters are list");
 $mech->content_like(qr/foo: \*1/, "Multiple parameters are to same reference");
 $mech->content_lacks(qr/J:M-foo/, "Doesn't have mapping parameter");
 
 
 #### Action results
-$mech->get("$URL/index.html?J:M-foo=R|grail|bar");
+$mech->get("$URL/index.html?J:M-foo=R`grail`bar");
 $mech->content_like(qr/foo: ~/, "Action doesn't exist, sets to undef");
 $mech->content_lacks(qr/J:M-foo/, "Doesn't have mapping parameter");
 
-$mech->get("$URL/index.html?J:M-foo=R|grail|bar;J:A-grail=GetGrail");
+$mech->get("$URL/index.html?J:M-foo=R`grail`bar;J:A-grail=GetGrail");
 $mech->content_like(qr/foo: ~/, "Content name doesn't exist, sets to undef");
 $mech->content_lacks(qr/J:M-foo/, "Doesn't have mapping parameter");
 
-$mech->get("$URL/index.html?J:M-foo=R|grail|castle;J:A-grail=GetGrail");
+$mech->get("$URL/index.html?J:M-foo=R`grail`castle;J:A-grail=GetGrail");
 $mech->content_like(qr/foo: Aaaaaargh/, "Content name exists, sets to value");
 $mech->content_lacks(qr/J:M-foo/, "Doesn't have mapping parameter");
 
 
 #### Action arguments
-$mech->get("$URL/index.html?J:M-foo=A|bridge|bar");
+$mech->get("$URL/index.html?J:M-foo=A`bridge`bar");
 $mech->content_like(qr/foo: ~/, "Action doesn't exist, sets to undef");
 $mech->content_lacks(qr/J:M-foo/, "Doesn't have mapping parameter");
 
-$mech->get("$URL/index.html?J:M-foo=A|bridge|bar;J:A-bridge=CrossBridge");
+$mech->get("$URL/index.html?J:M-foo=A`bridge`bar;J:A-bridge=CrossBridge");
 $mech->content_like(qr/foo: ~/, "Argument name doesn't exist, sets to undef");
 $mech->content_lacks(qr/J:M-foo/, "Doesn't have mapping parameter");
 
-$mech->get("$URL/index.html?J:M-foo=A|bridge|quest;J:A-bridge=CrossBridge");
+$mech->get("$URL/index.html?J:M-foo=A`bridge`quest;J:A-bridge=CrossBridge");
 $mech->content_like(qr/foo: ~/, "Argument is valid but missing, sets to undef");
 $mech->content_lacks(qr/J:M-foo/, "Doesn't have mapping parameter");
 
-$mech->get("$URL/index.html?J:M-foo=A|bridge|name;J:A-bridge=CrossBridge");
+$mech->get("$URL/index.html?J:M-foo=A`bridge`name;J:A-bridge=CrossBridge");
 $mech->content_like(qr/foo: ~/, "Argument is valid with default_value but missing, sets to undef");
 $mech->content_lacks(qr/J:M-foo/, "Doesn't have mapping parameter");
 
-$mech->get("$URL/index.html?J:M-foo=A|bridge|quest;J:A-bridge=CrossBridge;J:A:F-quest-bridge=grail");
+$mech->get("$URL/index.html?J:M-foo=A`bridge`quest;J:A-bridge=CrossBridge;J:A:F-quest-bridge=grail");
 $mech->content_like(qr/foo: grail/, "Argument is valid, sets to submitted value");
 $mech->content_lacks(qr/J:M-foo/, "Doesn't have mapping parameter");
 


More information about the Jifty-commit mailing list