[Jifty-commit] r4755 - in jifty/branches/jquery: . lib/Jifty
lib/Jifty/Action lib/Jifty/Plugin/REST lib/Jifty/Web
share/web/templates/__jifty/webservices
t/TestApp-JiftyJS/share/web/static/js-test
t/TestApp/lib/TestApp t/TestApp/t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Thu Dec 20 13:03:58 EST 2007
Author: gugod
Date: Thu Dec 20 13:03:58 2007
New Revision: 4755
Added:
jifty/branches/jquery/t/TestApp-JiftyJS/share/web/static/js-test/02.action.html (contents, props changed)
Modified:
jifty/branches/jquery/ (props changed)
jifty/branches/jquery/Makefile.PL
jifty/branches/jquery/lib/Jifty/Action/Record.pm
jifty/branches/jquery/lib/Jifty/Collection.pm
jifty/branches/jquery/lib/Jifty/DateTime.pm
jifty/branches/jquery/lib/Jifty/Dispatcher.pm
jifty/branches/jquery/lib/Jifty/Plugin/Monitoring.pm
jifty/branches/jquery/lib/Jifty/Plugin/REST/Dispatcher.pm
jifty/branches/jquery/lib/Jifty/Record.pm
jifty/branches/jquery/lib/Jifty/Result.pm
jifty/branches/jquery/lib/Jifty/Util.pm
jifty/branches/jquery/lib/Jifty/Web/Form.pm
jifty/branches/jquery/share/web/templates/__jifty/webservices/json
jifty/branches/jquery/share/web/templates/__jifty/webservices/yaml
jifty/branches/jquery/t/TestApp-JiftyJS/share/web/static/js-test/index.html
jifty/branches/jquery/t/TestApp/lib/TestApp/Dispatcher.pm
jifty/branches/jquery/t/TestApp/t/02-dispatch.t
Log:
- Merge /prj/mirror/jifty/trunk to /prj/mirror/jifty/branches/jquery
Modified: jifty/branches/jquery/Makefile.PL
==============================================================================
--- jifty/branches/jquery/Makefile.PL (original)
+++ jifty/branches/jquery/Makefile.PL Thu Dec 20 13:03:58 2007
@@ -64,7 +64,7 @@
requires('Object::Declare' => '0.13');
requires('PadWalker');
requires('Params::Validate');
-requires('Scalar::Defer' => '0.10');
+requires('Scalar::Defer' => '0.12');
requires('Shell::Command');
requires('String::Koremutake');
requires('SQL::ReservedWords');
@@ -162,18 +162,14 @@
],
'Memory Leak Plugins' => [
-default => 0,
- recommends('Devel::Events' => '0.02'), # Devel::Events::Handler::ObjectTracker Devel:Events::Generator::Objects
+ recommends('Devel::Events::Objects' => '0.02'), # Devel::Events::Handler::ObjectTracker Devel::Events::Generator::Objects
recommends('Devel::Size'),
recommends('Devel::Gladiator'),
recommends('Proc::ProcessTable'),
],
'OAuth Plugin' => [
-default => 0,
- recommends('Net::OAuth::Request' => '0.04'),
- recommends('Net::OAuth::RequestTokenRequest'),
- recommends('Net::OAuth::AccessTokenRequest'),
- recommends('Net::OAuth::ProtectedResourceRequest'),
-
+ recommends('Net::OAuth::Request' => '0.04'), # Net::OAuth::RequestTokenRequest Net::OAuth::AccessTokenRequest Net::OAuth::ProtectedResourceRequest
recommends('Crypt::OpenSSL::RSA'),
recommends('Digest::HMAC_SHA1'),
],
Modified: jifty/branches/jquery/lib/Jifty/Action/Record.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/Action/Record.pm (original)
+++ jifty/branches/jquery/lib/Jifty/Action/Record.pm Thu Dec 20 13:03:58 2007
@@ -156,8 +156,10 @@
for my $field ( keys %$arguments ) {
if ( my $function = $self->record->can($field) ) {
+ my $weakself = $self;
+ Scalar::Util::weaken $weakself;
$arguments->{$field}->{default_value} = defer {
- my $val = $function->( $self->record );
+ my $val = $function->( $weakself->record );
# If the current value is actually a pointer to
# another object, turn it into an ID
return $val->id if (blessed($val) and $val->isa('Jifty::Record'));
Modified: jifty/branches/jquery/lib/Jifty/Collection.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/Collection.pm (original)
+++ jifty/branches/jquery/lib/Jifty/Collection.pm Thu Dec 20 13:03:58 2007
@@ -144,6 +144,19 @@
return ( current_user => $self->current_user );
}
+=head2 jifty_serialize_format
+
+This returns an array reference of the individual records that make up this
+collection.
+
+=cut
+
+sub jifty_serialize_format {
+ my $records = shift->items_array_ref;
+
+ return [ map { $_->jifty_serialize_format(@_) } @$records ];
+}
+
=head1 SEE ALSO
L<Jifty::DBI::Collection>, L<Jifty::Object>, L<Jifty::Record>
Modified: jifty/branches/jquery/lib/Jifty/DateTime.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/DateTime.pm (original)
+++ jifty/branches/jquery/lib/Jifty/DateTime.pm Thu Dec 20 13:03:58 2007
@@ -268,6 +268,24 @@
return 1;
}
+=head2 jifty_serialize_format
+
+This returns a DateTime (or string) consistent with Jifty's date format.
+
+=cut
+
+sub jifty_serialize_format {
+ my $dt = shift;
+
+ # if it looks like just a date, then return just the date portion
+ return $dt->ymd
+ if lc($dt->time_zone->name) eq 'floating'
+ && $dt->hms('') eq '000000';
+
+ # otherwise let stringification take care of it
+ return $dt;
+}
+
=head1 WHY?
There are other ways to do some of these things and some of the decisions here may seem arbitrary, particularly if you read the code. They are.
Modified: jifty/branches/jquery/lib/Jifty/Dispatcher.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/Dispatcher.pm (original)
+++ jifty/branches/jquery/lib/Jifty/Dispatcher.pm Thu Dec 20 13:03:58 2007
@@ -985,7 +985,9 @@
# Previously compiled (eg. a qr{} -- return it verbatim)
return $cond if ref $cond;
- unless ( $CONDITION_CACHE{$cond} ) {
+ my $cachekey = join('-', (($Dispatcher->{rule} eq 'on') ? 'on' : 'in'),
+ $cond);
+ unless ( $CONDITION_CACHE{$cachekey} ) {
my $compiled = $cond;
@@ -1027,9 +1029,9 @@
if ( !$has_capture ) {
$compiled = "($compiled)";
}
- $CONDITION_CACHE{$cond} = qr{$compiled};
+ $CONDITION_CACHE{$cachekey} = qr{$compiled};
}
- return $CONDITION_CACHE{$cond};
+ return $CONDITION_CACHE{$cachekey};
}
=head2 _compile_glob METAEXPRESSION
Modified: jifty/branches/jquery/lib/Jifty/Plugin/Monitoring.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/Plugin/Monitoring.pm (original)
+++ jifty/branches/jquery/lib/Jifty/Plugin/Monitoring.pm Thu Dec 20 13:03:58 2007
@@ -52,7 +52,7 @@
=cut
-__PACKAGE__->mk_accessors(qw/base_classes monitors now current_monitor/);
+__PACKAGE__->mk_accessors(qw/base_classes monitors now current_monitor lockfile has_lock/);
our @EXPORT = qw/monitor every
minute minutes
@@ -194,6 +194,7 @@
my @path = $args{path} ? @{$args{path}} : (Jifty->app_class("Monitor"));
$self->base_classes(\@path);
$self->monitors({});
+ $self->lockfile($args{lockfile} || "var/monitoring.pid");
local $Jifty::Plugin::Monitoring::self = $self;
Jifty::Module::Pluggable->import(
require => 1,
@@ -273,6 +274,7 @@
sub run_monitors {
my $self = shift;
+ return unless $self->lock;
my $now = Jifty::DateTime->now->truncate( to => "minute" );
$now->set_time_zone("UTC");
$self->now($now);
@@ -298,4 +300,19 @@
$self->current_monitor(undef);
}
+sub lock {
+ my $self = shift;
+ return if -e $self->lockfile;
+ open PID, ">", $self->lockfile;
+ print PID $$;
+ close PID;
+ $self->has_lock(1);
+ return 1;
+}
+
+sub DESTROY {
+ my $self = shift;
+ unlink $self->lockfile if $self->has_lock;
+}
+
1;
Modified: jifty/branches/jquery/lib/Jifty/Plugin/REST/Dispatcher.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/Plugin/REST/Dispatcher.pm (original)
+++ jifty/branches/jquery/lib/Jifty/Plugin/REST/Dispatcher.pm Thu Dec 20 13:03:58 2007
@@ -87,142 +87,6 @@
}
-=head2 stringify LIST
-
-Takes a list of values and forces them into strings. Right now all it does
-is concatenate them to an empty string, but future versions might be more
-magical.
-
-=cut
-
-sub stringify {
- # XXX: allow configuration to specify model fields that are to be
- # expanded
- my @r;
-
- for (@_) {
- if (UNIVERSAL::isa($_, 'Jifty::Record')) {
- push @r, reference_to_data($_);
- }
- elsif (UNIVERSAL::isa($_, 'Jifty::DateTime')) {
- push @r, _datetime_to_data($_);
- }
- elsif (defined $_) {
- push @r, '' . $_; # force stringification
- }
- else {
- push @r, undef;
- }
- }
-
- return wantarray ? @r : $r[-1];
-}
-
-=head2 reference_to_data
-
-provides a saner output format for models than MyApp::Model::Foo=HASH(0x1800568)
-
-=cut
-
-sub reference_to_data {
- my $obj = shift;
- my ($model) = map { s/::/./g; $_ } ref($obj);
- return { jifty_model_reference => 1, id => $obj->id, model => $model };
-}
-
-=head2 object_to_data OBJ
-
-Takes an object and converts the known types into simple data structures.
-
-Current known types:
-
- Jifty::DBI::Collection
- Jifty::DBI::Record
- Jifty::DateTime
-
-=cut
-
-sub object_to_data {
- my $obj = shift;
-
- my %types = (
- 'Jifty::DBI::Collection' => \&_collection_to_data,
- 'Jifty::DBI::Record' => \&_record_to_data,
- 'Jifty::DateTime' => \&_datetime_to_data,
- );
-
- for my $type ( keys %types ) {
- if ( UNIVERSAL::isa( $obj, $type ) ) {
- return $types{$type}->( $obj );
- }
- }
-
- # As the last resort, return the object itself and expect the $accept-specific
- # renderer to format the object as e.g. YAML or JSON data.
- return $obj;
-}
-
-sub _collection_to_data {
- my $records = shift->items_array_ref;
- return [ map { _record_to_data( $_ ) } @$records ];
-}
-
-sub _record_to_data {
- my $record = shift;
- # We could use ->as_hash but this method avoids transforming refers_to
- # columns into JDBI objects
-
- # XXX: maybe just test ->virtual?
- my %data = map {
- $_ => (UNIVERSAL::isa( $record->column( $_ )->refers_to,
- 'Jifty::DBI::Collection' ) ||
- $record->column($_)->container
- ? undef
- : stringify( $record->_value( $_ ) ) )
- } $record->readable_attributes;
- return \%data;
-}
-
-sub _datetime_to_data {
- my $dt = shift;
-
- # if it looks like just a date, then return just the date portion
- return $dt->ymd
- if lc($dt->time_zone->name) eq 'floating'
- && $dt->hms('') eq '000000';
-
- # otherwise let stringification take care of it
- return $dt;
-}
-
-=head2 recurse_object_to_data REF
-
-Takes a reference, and calls C<object_to_data> on it if that is
-meaningful. If it is an arrayref, or recurses on each element. If it
-is a hashref, recurses on each value. Returns the new datastructure.
-
-=cut
-
-sub recurse_object_to_data {
- my $o = shift;
- return $o unless ref $o;
-
- my $updated = object_to_data($o);
- if ($o ne $updated) {
- return $updated;
- } elsif (ref $o eq "ARRAY") {
- my @a = map {recurse_object_to_data($_)} @{$o};
- return \@a;
- } elsif (ref $o eq "HASH") {
- my %h;
- $h{$_} = recurse_object_to_data($o->{$_}) for keys %{$o};
- return \%h;
- } else {
- return $o;
- }
-}
-
-
=head2 list PREFIX items
Takes a URL prefix and a set of items to render. passes them on.
@@ -528,7 +392,8 @@
$col->order_by( column => $column );
list( [ 'model', $model, $column ],
- map { stringify($_->$column()) } @{ $col->items_array_ref || [] } );
+ map { Jifty::Util->stringify($_->$column()) }
+ @{ $col->items_array_ref || [] } );
}
@@ -549,7 +414,8 @@
# Check that the field is actually a column (and not some other method)
abort(404) if not scalar grep { $_->name eq $field } $rec->columns;
- outs( [ 'model', $model, $column, $key, $field ], stringify($rec->$field()) );
+ outs( [ 'model', $model, $column, $key, $field ],
+ Jifty::Util->stringify($rec->$field()) );
}
=head2 show_item $model, $column, $key
@@ -565,7 +431,9 @@
my $rec = $model->new;
$rec->load_by_cols( $column => $key );
$rec->id or abort(404);
- outs( ['model', $model, $column, $key], { map {$_ => stringify($rec->$_())} map {$_->name} $rec->columns});
+ outs( ['model', $model, $column, $key],
+ { map { $_ => Jifty::Util->stringify($rec->$_()) }
+ map {$_->name} $rec->columns});
}
=head2 create_item
@@ -769,24 +637,8 @@
} 'model', ref($rec), 'id', $rec->id);
Jifty->handler->apache->header_out('Location' => $url);
}
-
- my $result = $action->result;
- my $out = {};
- $out->{success} = $result->success;
- $out->{message} = $result->message;
- $out->{error} = $result->error;
- $out->{field_errors} = {$result->field_errors};
- for (keys %{$out->{field_errors}}) {
- delete $out->{field_errors}->{$_} unless $out->{field_errors}->{$_};
- }
- $out->{field_warnings} = {$result->field_warnings};
- for (keys %{$out->{field_warnings}}) {
- delete $out->{field_warnings}->{$_} unless $out->{field_warnings}->{$_};
- }
- $out->{content} = recurse_object_to_data($result->content);
-
- outs(undef, $out);
+ outs(undef, $action->result->as_hash);
last_rule;
}
Modified: jifty/branches/jquery/lib/Jifty/Record.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/Record.pm (original)
+++ jifty/branches/jquery/lib/Jifty/Record.pm Thu Dec 20 13:03:58 2007
@@ -827,4 +827,28 @@
}
}
+=head2 jifty_serialize_format
+
+This is used to create a hash reference of the object's values. Unlike
+Jifty::DBI::Record->as_hash, this won't transform refers_to columns into JDBI
+objects
+
+=cut
+
+sub jifty_serialize_format {
+ my $record = shift;
+ my %data;
+
+ # XXX: maybe just test ->virtual?
+ for ($record->readable_attributes) {
+ next if UNIVERSAL::isa($record->column($_)->refers_to,
+ 'Jifty::DBI::Collection');
+ next if $record->column($_)->container;
+
+ $data{$_} = Jifty::Util->stringify($record->_value($_));
+ }
+
+ return \%data;
+}
+
1;
Modified: jifty/branches/jquery/lib/Jifty/Result.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/Result.pm (original)
+++ jifty/branches/jquery/lib/Jifty/Result.pm Thu Dec 20 13:03:58 2007
@@ -179,4 +179,69 @@
return $self->_content->{$key};
}
+=head2 as_hash
+
+This returns the results as a hash to be given directly to the end user
+(usually via REST or webservices). The difference between
+C<< $result->as_hash >> and C<%$result> is that the latter will expand
+everything as deeply as possible. The former won't inflate C<refers_to>
+columns, among other things.
+
+=cut
+
+sub as_hash {
+ my $self = shift;
+
+ my $out = {
+ success => $self->success,
+ failure => $self->failure,
+ action_class => $self->action_class,
+ message => $self->message,
+ error => $self->error,
+ field_errors => { $self->field_errors },
+ field_warnings => { $self->field_warnings },
+ content => $self->_recurse_object_to_data($self->content),
+ };
+
+ for (keys %{$out->{field_errors}}) {
+ delete $out->{field_errors}->{$_} unless $out->{field_errors}->{$_};
+ }
+ for (keys %{$out->{field_warnings}}) {
+ delete $out->{field_warnings}->{$_} unless $out->{field_warnings}->{$_};
+ }
+
+ return $out;
+}
+
+sub _recurse_object_to_data {
+ my $self = shift;
+ my $o = shift;
+
+ return $o if !ref($o);
+
+ if (ref($o) eq 'ARRAY') {
+ return [ map { $self->_recurse_object_to_data($_) } @$o ];
+ }
+ elsif (ref($o) eq 'HASH') {
+ my %h;
+ $h{$_} = $self->_recurse_object_to_data($o->{$_}) for keys %$o;
+ return \%h;
+ }
+
+ return $self->_object_to_data($o);
+}
+
+sub _object_to_data {
+ my $self = shift;
+ my $o = shift;
+
+ if ($o->can('jifty_serialize_format')) {
+ return $o->jifty_serialize_format($self);
+ }
+
+ # As the last resort, return the object itself and expect the
+ # $accept-specific renderer to format the object as e.g. YAML or JSON data.
+ return $o;
+}
+
1;
Modified: jifty/branches/jquery/lib/Jifty/Util.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/Util.pm (original)
+++ jifty/branches/jquery/lib/Jifty/Util.pm Thu Dec 20 13:03:58 2007
@@ -334,6 +334,47 @@
})->create_str;
}
+=head2 reference_to_data Object
+
+Provides a saner output format for models than
+C<MyApp::Model::Foo=HASH(0x1800568)>.
+
+=cut
+
+sub reference_to_data {
+ my ($self, $obj) = @_;
+ (my $model = ref($obj)) =~ s/::/./g;
+ return { jifty_model_reference => 1, id => $obj->id, model => $model };
+}
+
+=head2 stringify LIST
+
+Takes a list of values and forces them into strings. Right now all it does
+is concatenate them to an empty string, but future versions might be more
+magical.
+
+=cut
+
+sub stringify {
+ my $self = shift;
+
+ my @r;
+
+ for (@_) {
+ if (UNIVERSAL::isa($_, 'Jifty::Record')) {
+ push @r, Jifty::Util->reference_to_data($_);
+ }
+ elsif (defined $_) {
+ push @r, '' . $_; # force stringification
+ }
+ else {
+ push @r, undef;
+ }
+ }
+
+ return wantarray ? @r : $r[-1];
+}
+
=head1 AUTHOR
Various folks at Best Practical Solutions, LLC.
Modified: jifty/branches/jquery/lib/Jifty/Web/Form.pm
==============================================================================
--- jifty/branches/jquery/lib/Jifty/Web/Form.pm (original)
+++ jifty/branches/jquery/lib/Jifty/Web/Form.pm Thu Dec 20 13:03:58 2007
@@ -7,6 +7,8 @@
__PACKAGE__->mk_accessors(qw(actions printed_actions name call is_open disable_autocomplete target submit_to onsubmit));
+use Scalar::Util qw/weaken/;
+
=head1 NAME
Jifty::Web::Form - Tools for rendering and dealing with HTML forms
@@ -149,6 +151,7 @@
my $self = shift;
my $action = shift;
$self->actions->{ $action->moniker } = $action;
+ weaken $self->actions->{ $action->moniker};
return $action;
}
Modified: jifty/branches/jquery/share/web/templates/__jifty/webservices/json
==============================================================================
--- jifty/branches/jquery/share/web/templates/__jifty/webservices/json (original)
+++ jifty/branches/jquery/share/web/templates/__jifty/webservices/json Thu Dec 20 13:03:58 2007
@@ -1,2 +1,13 @@
% $r->content_type("text/x-json");
-<% Jifty::JSON::objToJson({Jifty->web->response->results}) |n%>
+<% Jifty::JSON::objToJson(\%results) |n%>
+
+<%INIT>
+my %results = Jifty->web->response->results;
+for (values %results) {
+ $_ = $_->as_hash;
+
+ # backwards compatibility :(
+ $_->{_content} = delete $_->{content};
+}
+</%INIT>
+
Modified: jifty/branches/jquery/share/web/templates/__jifty/webservices/yaml
==============================================================================
--- jifty/branches/jquery/share/web/templates/__jifty/webservices/yaml (original)
+++ jifty/branches/jquery/share/web/templates/__jifty/webservices/yaml Thu Dec 20 13:03:58 2007
@@ -1,2 +1,13 @@
% $r->content_type("text/x-yaml");
-<% Jifty::YAML::Dump({Jifty->web->response->results}) |n%>
+<% Jifty::YAML::Dump(\%results) |n%>
+
+<%INIT>
+my %results = Jifty->web->response->results;
+for (values %results) {
+ $_ = $_->as_hash;
+
+ # backwards compatibility :(
+ $_->{_content} = delete $_->{content};
+}
+</%INIT>
+
Added: jifty/branches/jquery/t/TestApp-JiftyJS/share/web/static/js-test/02.action.html
==============================================================================
--- (empty file)
+++ jifty/branches/jquery/t/TestApp-JiftyJS/share/web/static/js-test/02.action.html Thu Dec 20 13:03:58 2007
@@ -0,0 +1,82 @@
+<html>
+ <head>
+ <title>jifty.js test for "Action" object.</title>
+ <script type="text/javascript" src="/static/js/jsan/JSAN.js" charset="UTF-8"></script>
+ <script type="text/javascript" src="lib/Test/Builder.js" charset="UTF-8"></script>
+ <script type="text/javascript" src="lib/Test/More.js" charset="UTF-8"></script>
+
+ <script type="text/javascript" src="/static/js/prototype.js" charset="UTF-8"></script>
+ <script type="text/javascript" src="/static/js/cssquery/cssQuery.js" charset="UTF-8"></script>
+ <script type="text/javascript" src="/static/js/cssquery/cssQuery-level2.js" charset="UTF-8"></script>
+ <script type="text/javascript" src="/static/js/cssquery/cssQuery-level3.js" charset="UTF-8"></script>
+ <script type="text/javascript" src="/static/js/cssquery/cssQuery-standard.js" charset="UTF-8"></script>
+ <script type="text/javascript" src="/static/js/behaviour.js" charset="UTF-8"></script>
+ <script type="text/javascript" src="/static/js/scriptaculous/builder.js" charset="UTF-8"></script>
+ <script type="text/javascript" src="/static/js/scriptaculous/effects.js" charset="UTF-8"></script>
+ <script type="text/javascript" src="/static/js/scriptaculous/controls.js" charset="UTF-8"></script>
+
+ <script type="text/javascript" src="/static/js/jifty.js" charset="UTF-8"></script>
+ <script type="text/javascript">
+ </script>
+ </head>
+
+ <body>
+
+ <div>
+ <form enctype="multipart/form-data" action="/__jifty/admin/action/TestApp::JiftyJS::Action::AddTwoNumbers" method="post">
+
+
+ <div class="hidden"><input type="hidden" value="TestApp::JiftyJS::Action::AddTwoNumbers" id="J:A-run-TestApp::JiftyJS::Action::AddTwoNumbers" name="J:A-run-TestApp::JiftyJS::Action::AddTwoNumbers"/></div>
+ <div class="form_field argument-first_number">
+ <span class="preamble text argument-first_number"/>
+ <label for="J:A:F-first_number-run-TestApp::JiftyJS::Action::AddTwoNumbers-S1182827" class="label text argument-first_number">first_number</label>
+ <input type="text" class="widget text argument-first_number jifty_enter_handler_attached" value="" id="J:A:F-first_number-run-TestApp::JiftyJS::Action::AddTwoNumbers-S1182827" name="J:A:F-first_number-run-TestApp::JiftyJS::Action::AddTwoNumbers"/>
+ <span class="hints text argument-first_number"/>
+ <span id="errors-J:A:F-first_number-run-TestApp::JiftyJS::Action::AddTwoNumbers" class="error text argument-first_number" style="display: none;"/>
+ <span id="warnings-J:A:F-first_number-run-TestApp::JiftyJS::Action::AddTwoNumbers" class="warning text argument-first_number" style="display: none;"/>
+ <span id="canonicalization_note-J:A:F-first_number-run-TestApp::JiftyJS::Action::AddTwoNumbers" class="canonicalization_note text argument-first_number" style="display: none;"/>
+ </div>
+
+ <div class="form_field argument-second_number">
+ <span class="preamble text argument-second_number"/>
+ <label for="J:A:F-second_number-run-TestApp::JiftyJS::Action::AddTwoNumbers-S1192827" class="label text argument-second_number">second_number</label>
+ <input type="text" class="widget text argument-second_number jifty_enter_handler_attached" value="" id="J:A:F-second_number-run-TestApp::JiftyJS::Action::AddTwoNumbers-S1192827" name="J:A:F-second_number-run-TestApp::JiftyJS::Action::AddTwoNumbers"/>
+ <span class="hints text argument-second_number"/>
+ <span id="errors-J:A:F-second_number-run-TestApp::JiftyJS::Action::AddTwoNumbers" class="error text argument-second_number" style="display: none;"/>
+ <span id="warnings-J:A:F-second_number-run-TestApp::JiftyJS::Action::AddTwoNumbers" class="warning text argument-second_number" style="display: none;"/>
+ <span id="canonicalization_note-J:A:F-second_number-run-TestApp::JiftyJS::Action::AddTwoNumbers" class="canonicalization_note text argument-second_number" style="display: none;"/>
+ </div>
+
+
+ <div class="submit_button"><input type="submit" class="widget button" id="S1202827" value="Run the action" name=""/>
+ </div>
+
+ <div class="hidden">
+ </div>
+ </form>
+
+ </div>
+
+ <pre id="test"></pre>
+
+ <script type="text/javascript">
+
+JSAN.use('Test.More');
+plan({ tests: 3 });
+
+// Test very simple Action object initialization.
+(function() {
+ var a = new Action("run-TestApp::JiftyJS::Action::AddTwoNumbers");
+ var register = document.getElementById('J:A-run-TestApp::JiftyJS::Action::AddTwoNumbers');
+ var theform = document.getElementsByTagName("form")[0];
+
+ is( a.register, register, "Got a J:A register in dom.");
+ is( a.form, theform, "Got the form of that action");
+ is( a.actionClass, 'TestApp::JiftyJS::Action::AddTwoNumbers', "Got the actionClass");
+})();
+
+ </script>
+
+ </body>
+</html>
+
Modified: jifty/branches/jquery/t/TestApp-JiftyJS/share/web/static/js-test/index.html
==============================================================================
--- jifty/branches/jquery/t/TestApp-JiftyJS/share/web/static/js-test/index.html (original)
+++ jifty/branches/jquery/t/TestApp-JiftyJS/share/web/static/js-test/index.html Thu Dec 20 13:03:58 2007
@@ -1,6 +1,6 @@
<html>
<head>
-<title>Widget.Lightbox - tests index</title>
+<title>jifty js tests</title>
<script type="text/javascript" src="lib/JSAN.js" charset="UTF-8"></script>
<script type="text/javascript" src="lib/Test/Harness.js" charset="UTF-8"></script>
<script type="text/javascript" src="lib/Test/Harness/Browser.js" charset="UTF-8"></script>
@@ -8,7 +8,8 @@
<body>
<script type="text/javascript"><!--
new Test.Harness.Browser().runTests(
- "01.behaviour.html"
+ "01.behaviour.html",
+ "02.action.html"
);
// --></script>
</body>
Modified: jifty/branches/jquery/t/TestApp/lib/TestApp/Dispatcher.pm
==============================================================================
--- jifty/branches/jquery/t/TestApp/lib/TestApp/Dispatcher.pm (original)
+++ jifty/branches/jquery/t/TestApp/lib/TestApp/Dispatcher.pm Thu Dec 20 13:03:58 2007
@@ -1,6 +1,16 @@
package TestApp::Dispatcher;
use Jifty::Dispatcher -base;
+under '/' => run {
+}
+
+on '/' => run {
+ # shouldn't ever run because 02-dispatch.t doesn't request the root
+ # demonstrates bad interaction between under '/' and on '/' and
+ # the condition cache in the dispatcher
+ set phantom => 99;
+}
+
before '/redirect' => run {
Jifty->web->request->add_action(
moniker => 'thing',
@@ -9,8 +19,6 @@
redirect '/index.html';
};
-
-
on '/dispatch/' => run {
dispatch "/dispatch/basic";
};
@@ -19,12 +27,12 @@
dispatch "/dispatch/basic-show";
};
-
my $count = 0;
my $before = 0;
my $after = 0;
my $after_once = 0;
+
on '/dispatch/basic' => run {
set count => $count++;
};
Modified: jifty/branches/jquery/t/TestApp/t/02-dispatch.t
==============================================================================
--- jifty/branches/jquery/t/TestApp/t/02-dispatch.t (original)
+++ jifty/branches/jquery/t/TestApp/t/02-dispatch.t Thu Dec 20 13:03:58 2007
@@ -4,7 +4,7 @@
use lib 't/lib';
use Jifty::SubTest;
-use Jifty::Test tests => 28;
+use Jifty::Test tests => 29;
use Jifty::Test::WWW::Mechanize;
my $server = Jifty::Test->make_server;
@@ -20,6 +20,7 @@
$mech->content_contains("before: 0");
$mech->content_contains("after: 0");
$mech->content_contains("after_once: 0");
+$mech->content_lacks("phantom: 99");
$mech->get_ok("$URL/dispatch/basic-show", "Got /dispatch/basic-show");
$mech->content_contains("Basic test with forced show.");
More information about the Jifty-commit
mailing list