[Jifty-commit] r2651 - in jifty/branches/template-declare: .
lib/Jifty lib/Jifty/Plugin lib/Jifty/Plugin/REST
lib/Jifty/Script lib/Jifty/Web lib/Jifty/Web/Form
plugins/AuthCASOnly/lib/Jifty/Plugin/AuthCASOnly/Model
plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/Model
plugins/Login/lib/Jifty/Plugin/Login/Model plugins/Users
plugins/Users-Identity-File plugins/Users-Identity-File/doc
plugins/Users-Identity-File/lib
plugins/Users-Identity-File/lib/Jifty
plugins/Users-Identity-File/lib/Jifty/Plugin
plugins/Users-Identity-File/lib/Jifty/Plugin/Users
plugins/Users-Identity-File/lib/Jifty/Plugin/Users/Identity
plugins/Users-Identity-File/lib/Jifty/Plugin/Users/Identity/File/Action
plugins/Users-Identity-File/lib/Jifty/Plugin/Users/Identity/File/Model
plugins/Users-Identity-File/share
plugins/Users-Identity-File/share/po
plugins/Users-Identity-File/share/web
plugins/Users-Identity-File/share/web/static
plugins/Users-Identity-File/share/web/templates
plugins/Users-Identity-File/t plugins/Users/doc
plugins/Users/lib plugins/Users/lib/Jifty
plugins/Users/lib/Jifty/Plugin plugins/Users/lib/Jifty/Plugin/Users
plugins/Users/lib/Jifty/Plugin/Users/Action
plugins/Users/lib/Jifty/Plugin/Users/Model
plugins/Users/share plugins/Users/share/po
plugins/Users/share/web plugins/Users/share/web/static
plugins/Users/share/web/templates plugins/Users/t
share/web/static/js share/web/templates/__jifty
t/TestApp-Plugin-REST/t t/TestApp/t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sat Jan 27 03:53:00 EST 2007
Author: trs
Date: Sat Jan 27 03:52:58 2007
New Revision: 2651
Added:
jifty/branches/template-declare/plugins/Users/
jifty/branches/template-declare/plugins/Users-Identity-File/
jifty/branches/template-declare/plugins/Users-Identity-File/Makefile.PL
jifty/branches/template-declare/plugins/Users-Identity-File/doc/
jifty/branches/template-declare/plugins/Users-Identity-File/lib/
jifty/branches/template-declare/plugins/Users-Identity-File/lib/Jifty/
jifty/branches/template-declare/plugins/Users-Identity-File/lib/Jifty/Plugin/
jifty/branches/template-declare/plugins/Users-Identity-File/lib/Jifty/Plugin/Users/
jifty/branches/template-declare/plugins/Users-Identity-File/lib/Jifty/Plugin/Users/Identity/
jifty/branches/template-declare/plugins/Users-Identity-File/lib/Jifty/Plugin/Users/Identity/File/
jifty/branches/template-declare/plugins/Users-Identity-File/lib/Jifty/Plugin/Users/Identity/File.pm
jifty/branches/template-declare/plugins/Users-Identity-File/lib/Jifty/Plugin/Users/Identity/File/Action/
jifty/branches/template-declare/plugins/Users-Identity-File/lib/Jifty/Plugin/Users/Identity/File/Action/Login.pm
jifty/branches/template-declare/plugins/Users-Identity-File/lib/Jifty/Plugin/Users/Identity/File/Dispatcher.pm
jifty/branches/template-declare/plugins/Users-Identity-File/lib/Jifty/Plugin/Users/Identity/File/Model/
jifty/branches/template-declare/plugins/Users-Identity-File/share/
jifty/branches/template-declare/plugins/Users-Identity-File/share/po/
jifty/branches/template-declare/plugins/Users-Identity-File/share/web/
jifty/branches/template-declare/plugins/Users-Identity-File/share/web/static/
jifty/branches/template-declare/plugins/Users-Identity-File/share/web/templates/
jifty/branches/template-declare/plugins/Users-Identity-File/share/web/templates/login
jifty/branches/template-declare/plugins/Users-Identity-File/t/
jifty/branches/template-declare/plugins/Users/Makefile.PL
jifty/branches/template-declare/plugins/Users/doc/
jifty/branches/template-declare/plugins/Users/lib/
jifty/branches/template-declare/plugins/Users/lib/Jifty/
jifty/branches/template-declare/plugins/Users/lib/Jifty/Plugin/
jifty/branches/template-declare/plugins/Users/lib/Jifty/Plugin/Users/
jifty/branches/template-declare/plugins/Users/lib/Jifty/Plugin/Users.pm
jifty/branches/template-declare/plugins/Users/lib/Jifty/Plugin/Users/Action/
jifty/branches/template-declare/plugins/Users/lib/Jifty/Plugin/Users/CurrentUser.pm
jifty/branches/template-declare/plugins/Users/lib/Jifty/Plugin/Users/Dispatcher.pm
jifty/branches/template-declare/plugins/Users/lib/Jifty/Plugin/Users/Model/
jifty/branches/template-declare/plugins/Users/lib/Jifty/Plugin/Users/Model/User.pm
jifty/branches/template-declare/plugins/Users/share/
jifty/branches/template-declare/plugins/Users/share/po/
jifty/branches/template-declare/plugins/Users/share/web/
jifty/branches/template-declare/plugins/Users/share/web/static/
jifty/branches/template-declare/plugins/Users/share/web/templates/
jifty/branches/template-declare/plugins/Users/t/
Modified:
jifty/branches/template-declare/ (props changed)
jifty/branches/template-declare/lib/Jifty/Handler.pm
jifty/branches/template-declare/lib/Jifty/I18N.pm
jifty/branches/template-declare/lib/Jifty/Plugin/REST.pm
jifty/branches/template-declare/lib/Jifty/Plugin/REST/Dispatcher.pm
jifty/branches/template-declare/lib/Jifty/RightsFrom.pm
jifty/branches/template-declare/lib/Jifty/Script/Schema.pm
jifty/branches/template-declare/lib/Jifty/Web.pm
jifty/branches/template-declare/lib/Jifty/Web/Form/Clickable.pm
jifty/branches/template-declare/lib/Jifty/Web/Form/Field.pm
jifty/branches/template-declare/lib/Jifty/Web/PageRegion.pm
jifty/branches/template-declare/plugins/AuthCASOnly/lib/Jifty/Plugin/AuthCASOnly/Model/CASUser.pm
jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/Model/LDAPUser.pm
jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Model/User.pm
jifty/branches/template-declare/share/web/static/js/calendar.js
jifty/branches/template-declare/share/web/templates/__jifty/validator.xml
jifty/branches/template-declare/t/TestApp-Plugin-REST/t/02-basic-use.t
jifty/branches/template-declare/t/TestApp/t/13-page-regions.t
Log:
Mergedown from trunk
r19112 at zot (orig r2608): yves | 2007-01-26 09:51:08 -0500
Modernization of model declarations for compatibility with new Object::Declare based Jifty::DBI
r19113 at zot (orig r2609): yves | 2007-01-26 09:54:11 -0500
* Modernization of model declarations for compatibility with new Object::Declare based Jifty::DBI
r19115 at zot (orig r2611): yves | 2007-01-26 10:47:46 -0500
* first shot (and not workable) for plugins 2.0 auth plugins
r19119 at zot (orig r2612): trs | 2007-01-26 19:03:00 -0500
r19117 at zot: tom | 2007-01-26 15:52:46 -0500
Implementation for PUT and DELETE on model items
r19121 at zot (orig r2613): trs | 2007-01-26 19:07:54 -0500
r19120 at zot: tom | 2007-01-26 19:07:44 -0500
Also add the column and key the request is on in case the action expects that instead of the ID
r19124 at zot (orig r2615): alexmv | 2007-01-26 20:11:07 -0500
r15945 at zoq-fot-pik: chmrr | 2007-01-17 16:55:46 -0500
* They're scriptaculous effects, not prototype
r19125 at zot (orig r2616): alexmv | 2007-01-26 20:11:28 -0500
r16707 at zoq-fot-pik: chmrr | 2007-01-26 20:10:40 -0500
* Canonicalize/validate after typing and blurring, too
r19126 at zot (orig r2617): alexmv | 2007-01-26 20:11:31 -0500
r16708 at zoq-fot-pik: chmrr | 2007-01-26 20:10:54 -0500
* Warnings avoidance
r19134 at zot (orig r2625): audreyt | 2007-01-26 23:06:21 -0500
* max_length fix in 12-param-schema.t
r19138 at zot (orig r2627): trs | 2007-01-26 23:09:43 -0500
r19117 at zot: tom | 2007-01-26 15:52:46 -0500
Implementation for PUT and DELETE on model items
r19139 at zot (orig r2628): trs | 2007-01-26 23:09:48 -0500
r19120 at zot: tom | 2007-01-26 19:07:44 -0500
Also add the column and key the request is on in case the action expects that instead of the ID
r19140 at zot (orig r2629): trs | 2007-01-26 23:09:54 -0500
r19122 at zot: tom | 2007-01-26 23:08:07 -0500
Since most REST actions won't be run from HTML forms, default values never getted passed in. Make sure they get set for arguments which have not been explicitly passed as blank.
r19144 at zot (orig r2633): audreyt | 2007-01-27 00:03:00 -0500
* unTODO passing tests in TestApp::Plugin::REST
r19145 at zot (orig r2634): audreyt | 2007-01-27 00:03:21 -0500
* Mark "length" as deprecated APIP in J::Web::Form::Field
r19146 at zot (orig r2635): audreyt | 2007-01-27 00:04:21 -0500
* Jifty::Script::Schema: s/until/till/g
r19148 at zot (orig r2637): audreyt | 2007-01-27 00:14:32 -0500
* Jifty::RightsFrom - Fix POD errors - we need to use Jifty::DBI::Schema
and we don't need to use the package refers_to. (J::DBI::Schema can
->require it for us)
r19149 at zot (orig r2638): audreyt | 2007-01-27 00:26:06 -0500
* Fix trivial test typo in TestApp 13-page-regions.t
r19151 at zot (orig r2640): audreyt | 2007-01-27 01:48:24 -0500
* Clickable - Stylistic cleanup to _map to avoid $_ and in-situ hash key editing
r19152 at zot (orig r2641): audreyt | 2007-01-27 01:51:40 -0500
* Jifty::Web - Add private accessor for _state_variables to
avoid typo-prone ->{'state_variables'}.
r19153 at zot (orig r2642): audreyt | 2007-01-27 01:58:42 -0500
* PageRegion should be initialized with all state variables from its
upper level request, not only the ones that concerns itself.
This fixes t/TestApp/t/13-page-regions.t.
r19154 at zot (orig r2643): audreyt | 2007-01-27 02:22:06 -0500
* Support for dynamic language handles for Jifty::I18N,
so each request can trigger a different _() language.
r19155 at zot (orig r2644): audreyt | 2007-01-27 03:08:10 -0500
* 13-page-regions.t: Fix another mistest typo
r19156 at zot (orig r2645): audreyt | 2007-01-27 03:12:26 -0500
* Jifty::I18N - Avoid naked eval{} that clobbers $@.
r19157 at zot (orig r2646): jesse | 2007-01-27 03:18:05 -0500
r21503 at hualien: jesse | 2007-01-27 12:12:09 +0800
* We were still using deprecated 'length' api when constructing form fields
r19158 at zot (orig r2647): jesse | 2007-01-27 03:18:51 -0500
r19159 at zot (orig r2648): jesse | 2007-01-27 03:19:19 -0500
r21528 at hualien: jesse | 2007-01-27 16:09:34 +0800
* merge bug
r19160 at zot (orig r2649): audreyt | 2007-01-27 03:31:10 -0500
* Jifty::I18N: Provide a default fallback lexicon class for "en"
so Locale::Maketext won't clobber our $@ stack.
r19163 at zot (orig r2650): trs | 2007-01-27 03:44:42 -0500
r19162 at zot: tom | 2007-01-27 03:44:14 -0500
* Silence warning
* Add a small bit of doc
Modified: jifty/branches/template-declare/lib/Jifty/Handler.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Handler.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Handler.pm Sat Jan 27 03:52:58 2007
@@ -216,6 +216,8 @@
Jifty::I18N->refresh;
}
+ Jifty::I18N->get_language_handle;
+
$self->cgi( $args{cgi} );
$self->apache( HTML::Mason::FakeApache->new( cgi => $self->cgi ) );
Modified: jifty/branches/template-declare/lib/Jifty/I18N.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/I18N.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/I18N.pm Sat Jan 27 03:52:58 2007
@@ -30,6 +30,7 @@
=cut
+my $DynamicLH;
sub new {
my $class = shift;
@@ -42,6 +43,7 @@
);
foreach my $plugin (Jifty->plugins) {
+ local $@;
my $dir = eval { module_dir(ref($plugin)); };
next unless $dir;
push @import, 'Gettext';
@@ -56,13 +58,14 @@
}
);
- $self->init;
-
# Allow hard-coded languages in the config file
my $lang = Jifty->config->framework('L10N')->{'Lang'};
$lang = [defined $lang ? $lang : ()] unless ref($lang) eq 'ARRAY';
- my $lh = $class->get_handle(@$lang);
+ my $lh = $class->get_handle(@$lang);
+ $DynamicLH = \$lh unless @$lang;
+ $self->init;
+
my $loc_method = sub {
# Retain compatibility with people using "-e _" etc.
return \*_ unless @_;
@@ -92,6 +95,17 @@
return $self;
}
+=head2 get_language_handle
+
+Get the lanauge language for this request.
+
+=cut
+
+sub get_language_handle {
+ my $self = shift;
+ $$DynamicLH = $self->get_handle() if $DynamicLH;
+}
+
=head2 refresh
Used by L<Jifty::Handler> in DevelMode to reload F<.po> files whenever they
@@ -148,6 +162,7 @@
} else {
my $encoding = Encode::Guess->guess($string);
if(!ref($encoding)) {
+ local $@;
eval {
# Try utf8
$string = Encode::decode_utf8($string, 1);
@@ -177,6 +192,8 @@
sub maybe_decode_utf8 {
my $class = shift;
my $string = shift;
+
+ local $@;
eval {
$string = Encode::decode_utf8($string);
};
@@ -184,4 +201,8 @@
return $string;
}
+package Jifty::I18N::en;
+use base 'Locale::Maketext';
+our %Lexicon = ( _fallback => 1 );
+
1;
Modified: jifty/branches/template-declare/lib/Jifty/Plugin/REST.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Plugin/REST.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Plugin/REST.pm Sat Jan 27 03:52:58 2007
@@ -21,7 +21,9 @@
framework:
Plugins:
- REST: {}
-
+
+See the URL /=/help in your Jifty app for more information about
+how to access the RESTian resources.
=cut
1;
Modified: jifty/branches/template-declare/lib/Jifty/Plugin/REST/Dispatcher.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Plugin/REST/Dispatcher.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Plugin/REST/Dispatcher.pm Sat Jan 27 03:52:58 2007
@@ -58,16 +58,13 @@
on GET /=/model/<model>/<column>/<key> show item
on GET /=/model/<model>/<column>/<key>/<field> show item field
-on PUT /=/model/<model>/<column>/<key> replace item -- UNIMPLEMENTED!
-on DELETE /=/model/<model>/<column>/<key> delete item -- UNIMPLEMENTED!
+on PUT /=/model/<model>/<column>/<key> replace item
+on DELETE /=/model/<model>/<column>/<key> delete item
on GET /=/action list actions
on GET /=/action/<action> list action params
on POST /=/action/<action> run action
-Note that the PUT and DELETE methods on models are essentially available through
-Update<Model> and Delete<Model> actions.
-
Resources are available in a variety of formats:
@@ -164,7 +161,10 @@
$apache->send_http_header;
# Special case showing particular actions to show an HTML form
- if ( $prefix->[0] eq 'action' and scalar @$prefix == 2 ) {
+ if ( defined $prefix
+ and $prefix->[0] eq 'action'
+ and scalar @$prefix == 2 )
+ {
show_action_form($1);
}
else {
@@ -423,22 +423,66 @@
=head2 replace_item
-UNIMPLEMENTED
+Implemented by redispatching to a CreateModel or UpdateModel action
=cut
-sub replace_item {
- die "hey replace item";
-}
+sub replace_item { _dispatch_to_action('Update') }
=head2 delete_item
-UNIMPLEMENTED
+Implemented by redispatching to a DeleteModel action.
=cut
-sub delete_item {
- die "hey delete item";
+sub delete_item { _dispatch_to_action('Delete') }
+
+sub _dispatch_to_action {
+ my $prefix = shift;
+ my ($model, $class, $column, $key) = (model($1), $1, $2, $3);
+ my $rec = $model->new;
+ $rec->load_by_cols( $column => $key );
+
+ if ( not $rec->id ) {
+ abort(404) if $prefix eq 'Delete';
+ $prefix = 'Create' if $prefix eq 'Update';
+ }
+
+ $class =~ s/^[\w\.]+\.//;
+
+ $ENV{REQUEST_METHOD} = 'POST';
+ Jifty->web->request->argument( $column => $key );
+ Jifty->web->request->argument( 'id' => $rec->id )
+ if defined $rec->id;
+
+ # CGI.pm doesn't handle form encoded data in PUT requests (in fact,
+ # it doesn't really handle PUT requests properly at all), so we have
+ # to read the request body ourselves and have CGI.pm parse it
+ if ( $ENV{'CONTENT_TYPE'} =~ m|^application/x-www-form-urlencoded$|
+ or $ENV{'CONTENT_TYPE'} =~ m|^multipart/form-data$| )
+ {
+ my $cgi = Jifty->handler->cgi;
+ my $length = defined $ENV{'CONTENT_LENGTH'} ? $ENV{'CONTENT_LENGTH'} : 0;
+ my $data;
+
+ $cgi->read_from_client( \$data, $length, 0 )
+ if $length > 0;
+
+ if ( defined $data ) {
+ my @params = $cgi->all_parameters;
+ $cgi->parse_params( $data );
+ push @params, $cgi->all_parameters;
+
+ my %seen;
+ my @uniq = map { $seen{$_}++ == 0 ? $_ : () } @params;
+
+ # Add only the newly parsed arguments to the Jifty::Request
+ Jifty->web->request->argument( $_ => $cgi->param( $_ ) )
+ for @uniq;
+ }
+ }
+
+ dispatch '/=/action/' . action( $prefix . $class );
}
=head2 list_actions
@@ -540,14 +584,21 @@
sub run_action {
my ($action_name) = action($1) or abort(404);
Jifty::Util->require($action_name) or abort(404);
- my $action = $action_name->new or abort(404);
+
+ my $args = Jifty->web->request->arguments;
+ delete $args->{''};
+
+ my $action = $action_name->new( arguments => $args ) or abort(404);
Jifty->api->is_allowed( $action_name ) or abort(403);
- my $args = Jifty->web->request->arguments;
- delete $args->{''};
+ my $params = $action->arguments;
+ for my $key ( keys %$params ) {
+ next if not exists $params->{ $key }{'default_value'};
+ next if $action->has_argument( $key );
+ $action->argument_value( $key => $params->{ $key }{'default_value'} );
+ }
- $action->argument_values({ %$args });
$action->validate;
local $@;
Modified: jifty/branches/template-declare/lib/Jifty/RightsFrom.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/RightsFrom.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/RightsFrom.pm Sat Jan 27 03:52:58 2007
@@ -8,8 +8,7 @@
=head1 SYNOPSIS
package Application::Model::Thing;
- use Application::Model::Person;
-
+ use Jifty::DBI::Schema;
use Application::Record schema {
column owner => refers_to Application::Model::Person;
}
Modified: jifty/branches/template-declare/lib/Jifty/Script/Schema.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Script/Schema.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Script/Schema.pm Sat Jan 27 03:52:58 2007
@@ -396,11 +396,11 @@
next if $column->virtual;
# If they're old, drop them
- if ( defined $column->until
- and $appv >= $column->until
- and $dbv < $column->until )
+ if ($column->can('till') and defined $column->till
+ and $appv >= $column->till
+ and $dbv < $column->till )
{
- push @{ $UPGRADES{ $column->until } },
+ push @{ $UPGRADES{ $column->till } },
"ALTER TABLE "
. $model->table
. " DROP COLUMN "
Modified: jifty/branches/template-declare/lib/Jifty/Web.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Web.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Web.pm Sat Jan 27 03:52:58 2007
@@ -22,7 +22,7 @@
use vars qw/$SERIAL @JS_INCLUDES/;
__PACKAGE__->mk_accessors(
- qw(next_page force_redirect request response session temporary_current_user _current_user)
+ qw(next_page force_redirect request response session temporary_current_user _current_user _state_variables)
);
__PACKAGE__->mk_classdata($_)
@@ -81,6 +81,7 @@
my $class = shift;
my $self = bless {region_stack => []}, $class;
$self->session(Jifty::Web::Session->new());
+ $self->clear_state_variables;
return ($self);
}
@@ -566,7 +567,7 @@
and $self->next_page
and ( ( $self->next_page ne $self->request->path )
or $self->request->state_variables
- or $self->{'state_variables'} )
+ or $self->state_variables )
)
{
return (1);
@@ -605,15 +606,15 @@
if ( (grep { not $_->action_class->isa('Jifty::Action::Redirect') }
values %{ { $self->response->results } })
or $self->request->state_variables
- or $self->{'state_variables'}
+ or $self->state_variables
or $self->request->continuation
or grep { $_->active and not $_->class->isa('Jifty::Action::Redirect') } @actions )
{
my $request = Jifty::Request->new();
$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'} };
+ $request->add_state_variable( key => $_, value => $self->_state_variables->{$_} )
+ for keys %{ $self->_state_variables };
for (@actions) {
my $new_action = $request->add_action(
moniker => $_->moniker,
@@ -1169,9 +1170,9 @@
my $value = shift;
if (!defined($value)) {
- delete $self->{'state_variables'}->{$name};
+ delete $self->_state_variables->{$name};
} else {
- $self->{'state_variables'}->{$name} = $value;
+ $self->_state_variables->{$name} = $value;
}
}
@@ -1188,11 +1189,7 @@
sub state_variables {
my $self = shift;
- my %vars;
- $vars{$_} = $self->{'state_variables'}->{$_}
- for keys %{ $self->{'state_variables'} };
-
- return %vars;
+ return %{ $self->_state_variables };
}
=head3 clear_state_variables
@@ -1204,7 +1201,7 @@
sub clear_state_variables {
my $self = shift;
- $self->{'state_variables'} = {};
+ $self->_state_variables({});
}
=head2 REGIONS
Modified: jifty/branches/template-declare/lib/Jifty/Web/Form/Clickable.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Web/Form/Clickable.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Web/Form/Clickable.pm Sat Jan 27 03:52:58 2007
@@ -313,13 +313,15 @@
# Query-map any complex structures
sub _map {
- my %args = @_;
- for (keys %args) {
- my ($key, $value) = Jifty::Request::Mapper->query_parameters($_ => $args{$_});
- delete $args{$_};
- $args{$key} = $value;
+ my %old_args = @_;
+ my %new_args;
+
+ while (my ($key, $val) = each %old_args) {
+ my ($new_key, $new_val) = Jifty::Request::Mapper->query_parameters($key => $val);
+ $new_args{$new_key} = $new_val;
}
- return %args;
+
+ return %new_args;
}
=head2 parameters
Modified: jifty/branches/template-declare/lib/Jifty/Web/Form/Field.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Web/Form/Field.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Web/Form/Field.pm Sat Jan 27 03:52:58 2007
@@ -489,7 +489,7 @@
$field .= qq! id="@{[ $self->element_id ]}"!;
$field .= qq! value="@{[Jifty->web->escape($self->current_value)]}"! if defined $self->current_value;
$field .= $self->_widget_class;
- $field .= qq! size="@{[ $self->max_length() ]}" maxlength="@{[ $self->length() ]}"! if ($self->max_length());
+ $field .= qq! size="@{[ $self->max_length() ]}" maxlength="@{[ $self->max_length() ]}"! if ($self->max_length());
$field .= qq! autocomplete="off"! if defined $self->disable_autocomplete;
$field .= " " .$self->other_widget_properties;
$field .= qq! />\n!;
@@ -712,7 +712,15 @@
}
+=for private
+
+=head2 length
+
# Deprecated API
+
+
+=cut
+
sub length {
my $self = shift;
Carp::carp("->length is deprecated; use ->max_length instead");
Modified: jifty/branches/template-declare/lib/Jifty/Web/PageRegion.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Web/PageRegion.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Web/PageRegion.pm Sat Jan 27 03:52:58 2007
@@ -190,17 +190,19 @@
push @{Jifty->web->{'region_stack'}}, $self;
# Merge in the settings passed in via state variables
- for (Jifty->web->request->state_variables) {
- my $key = $_->key;
- my $value = $_->value || '';
- if ($key =~ /^region-(.*?)\.(.*)/ and $1 eq $self->qualified_name and $value ne $self->default_argument($2)) {
+ for my $var (Jifty->web->request->state_variables) {
+ my $key = $var->key;
+ my $value = $var->value || '';
+
+ if ($key =~ /^region-(.*?)\.(.*)/ and $1 eq $self->qualified_name and $value ne $self->default_argument($2)) {
$self->argument($2 => $value);
- Jifty->web->set_variable("region-$1.$2" => $value);
}
- if ($key =~ /^region-(.*?)$/ and $1 eq $self->qualified_name and $value ne $self->default_path) {
+ if ($key =~ /^region-(.*)$/ and $1 eq $self->qualified_name and $value ne $self->default_path) {
$self->path($value);
- Jifty->web->set_variable("region-$1" => $value);
}
+
+ # We should always inherit the state variables from the uplevel request.
+ Jifty->web->set_variable($key => $value);
}
}
Modified: jifty/branches/template-declare/plugins/AuthCASOnly/lib/Jifty/Plugin/AuthCASOnly/Model/CASUser.pm
==============================================================================
--- jifty/branches/template-declare/plugins/AuthCASOnly/lib/Jifty/Plugin/AuthCASOnly/Model/CASUser.pm (original)
+++ jifty/branches/template-declare/plugins/AuthCASOnly/lib/Jifty/Plugin/AuthCASOnly/Model/CASUser.pm Sat Jan 27 03:52:58 2007
@@ -1,7 +1,9 @@
-package Jifty::Plugin::AuthCASOnly::Model::CASUser::Schema;
+package Jifty::Plugin::AuthCASOnly::Model::CASUser;
+use base qw/Jifty::Record/;
use Jifty::DBI::Schema;
use Scalar::Defer;
+use Jifty::Record schema {
column
name => type is 'text',
label is 'Name',
@@ -13,11 +15,9 @@
is immutable,
default is defer { DateTime->now },
filters are 'Jifty::DBI::Filter::DateTime';
+};
-package Jifty::Plugin::AuthCASOnly::Model::CASUser;
-use base qw/Jifty::Record/;
-
sub create {
my $self = shift;
my %args = (@_);
Modified: jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/Model/LDAPUser.pm
==============================================================================
--- jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/Model/LDAPUser.pm (original)
+++ jifty/branches/template-declare/plugins/AuthLDAPOnly/lib/Jifty/Plugin/AuthLDAPOnly/Model/LDAPUser.pm Sat Jan 27 03:52:58 2007
@@ -1,7 +1,10 @@
-package Jifty::Plugin::AuthLDAPOnly::Model::LDAPUser::Schema;
+package Jifty::Plugin::AuthLDAPOnly::Model::LDAPUser;
+use base qw/Jifty::Record/;
use Jifty::DBI::Schema;
use Scalar::Defer;
+use Jifty::Record schema {
+
column
name => type is 'text',
label is 'Name',
@@ -14,9 +17,8 @@
default is defer { DateTime->now },
filters are 'Jifty::DBI::Filter::DateTime';
+};
-package Jifty::Plugin::AuthLDAPOnly::Model::LDAPUser;
-use base qw/Jifty::Record/;
sub create {
my $self = shift;
Modified: jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Model/User.pm
==============================================================================
--- jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Model/User.pm (original)
+++ jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Model/User.pm Sat Jan 27 03:52:58 2007
@@ -1,6 +1,8 @@
-package Jifty::Plugin::Login::Model::User::Schema;
+package Jifty::Plugin::Login::Model::User;
+use base qw/Jifty::Record Jifty::Plugin::Login/;
use Jifty::DBI::Schema;
+use Jifty::Record schema {
column
name => type is 'text',
label is 'Name',
@@ -27,9 +29,8 @@
column
auth_token => type is 'text',
render_as 'Unrendered';
+};
-package Jifty::Plugin::Login::Model::User;
-use base qw/Jifty::Record Jifty::Plugin::Login/;
sub create {
my $self = shift;
Added: jifty/branches/template-declare/plugins/Users-Identity-File/Makefile.PL
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/Users-Identity-File/Makefile.PL Sat Jan 27 03:52:58 2007
@@ -0,0 +1,8 @@
+use inc::Module::Install;
+name('Jifty-Plugin-Users-Identity-File');
+version('0.01');
+requires('Jifty' => '0.70117');
+
+install_share;
+
+WriteAll;
Added: jifty/branches/template-declare/plugins/Users-Identity-File/lib/Jifty/Plugin/Users/Identity/File.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/Users-Identity-File/lib/Jifty/Plugin/Users/Identity/File.pm Sat Jan 27 03:52:58 2007
@@ -0,0 +1,13 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::Users::Identity::File;
+use base qw/Jifty::Plugin Jifty::Plugin::Users/;
+
+# Your plugin goes here. If takes any configuration or arguments, you
+# probably want to override L<Jifty::Plugin/init>.
+
+# ?? TODO
+# in init load file name
+
+1;
Added: jifty/branches/template-declare/plugins/Users-Identity-File/lib/Jifty/Plugin/Users/Identity/File/Action/Login.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/Users-Identity-File/lib/Jifty/Plugin/Users/Identity/File/Action/Login.pm Sat Jan 27 03:52:58 2007
@@ -0,0 +1,90 @@
+use warnings;
+use strict;
+
+=head1 NAME
+
+Jifty::Plugin::Users::Identity::File::Action::Login
+
+=cut
+
+package Jifty::Plugin::Users::Identity::File::Action::Login;
+use base qw/Jifty::Action Jifty::Plugin::Users Jifty::Plugin::Users::Identity::File/;
+
+
+=head2 arguments
+
+Return the ticket form field
+
+=cut
+
+sub arguments {
+ return (
+ {
+ login => {
+ label => 'login',
+ mandatory => 1,
+ ajax_validates => 1,
+ },
+ password => {
+ label => 'password',
+ mandatory => 1,
+ },
+
+ }
+ );
+
+}
+
+=head2 validate_ticket ST
+
+for ajax_validates
+Makes sure that the ticket submitted is legal.
+
+
+=cut
+
+sub validate_login {
+ my $self = shift;
+ my $login = shift;
+
+ unless ( $login && $login !~ /^[A-Za-z0-9-]+$/ ) {
+ return $self->validation_error(
+ ticket => _("That doesn't look like a valid ticket.") );
+ }
+
+
+ return $self->validation_ok('login');
+}
+
+
+=head2 take_action
+
+Actually check the user's password. If it's right, log them in.
+Otherwise, throw an error.
+
+
+=cut
+
+sub take_action {
+ my $self = shift;
+ my $login = $self->argument_value('login');
+ my $password = $self->argument_value('password');
+
+ my $LoginUser = $self->UserClass();
+ my $CurrentUser = $self->CurrentUserClass();
+ my $u = $LoginUser->new( current_user => $CurrentUser->superuser );
+
+ $u->load_by_cols( display_name => $login, realm => 'file' );
+ my $id = $u->id;
+ if (!$id) {
+ ($id) = $u->create(display_name => $login, realm => 'file' );
+ }
+ Jifty->log->debug("Login user id: $id");
+
+ # Actually do the signin thing.
+ Jifty->web->current_user( $CurrentUser->new( id => $u->id ) );
+
+ return 1;
+}
+
+1;
Added: jifty/branches/template-declare/plugins/Users-Identity-File/lib/Jifty/Plugin/Users/Identity/File/Dispatcher.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/Users-Identity-File/lib/Jifty/Plugin/Users/Identity/File/Dispatcher.pm Sat Jan 27 03:52:58 2007
@@ -0,0 +1,21 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::Users::Identity::File::Dispatcher;
+use Jifty::Dispatcher -base;
+
+# Put any plugin-specific dispatcher rules here.
+
+# Login
+on 'login' => run {
+ set 'action' =>
+ Jifty->web->new_action(
+ class => 'Login', #File login
+ moniker => 'fileloginbox'
+ );
+ set 'next' => Jifty->web->request->continuation
+ || Jifty::Continuation->new(
+ request => Jifty::Request->new( path => "/" ) );
+};
+
+1;
Added: jifty/branches/template-declare/plugins/Users-Identity-File/share/web/templates/login
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/Users-Identity-File/share/web/templates/login Sat Jan 27 03:52:58 2007
@@ -0,0 +1,20 @@
+<%args>
+$action => undef
+$next => undef
+</%args>
+<&|/_elements/wrapper, title => 'Login' &>
+
+% if (not Jifty->web->current_user->id) {
+<h2><% _('Login') %></h2>
+<% Jifty->web->form->start(call => $next, name => "fileloginbox") %>
+<% $action->form_field('login') %>
+<% $action->form_field('password') %>
+<div class="submit_button">
+<% Jifty->web->return(label => _('Login'), to => '/', submit => $action) %>
+</div>
+<% Jifty->web->form->end %>
+% }
+% else {
+<% _("You're already logged in.") %>
+% }
+</&>
Added: jifty/branches/template-declare/plugins/Users/Makefile.PL
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/Users/Makefile.PL Sat Jan 27 03:52:58 2007
@@ -0,0 +1,8 @@
+use inc::Module::Install;
+name('Jifty-Plugin-Users');
+version('0.01');
+requires('Jifty' => '0.70117');
+
+install_share;
+
+WriteAll;
Added: jifty/branches/template-declare/plugins/Users/lib/Jifty/Plugin/Users.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/Users/lib/Jifty/Plugin/Users.pm Sat Jan 27 03:52:58 2007
@@ -0,0 +1,52 @@
+use strict;
+use warnings;
+
+=head1 NAME
+
+Jifty::Plugin::Users;
+
+=cut
+
+package Jifty::Plugin::Users;
+use base qw/Jifty::Plugin/;
+
+=head1 SYNOPSIS
+
+EXPERIMENTAL DON'T USE IT
+EXPERIMENTAL DON'T USE IT
+EXPERIMENTAL DON'T USE IT
+
+ in etc/config.yml
+ Plugins:
+ - Users: {}
+ - Users-Identity-File:
+ store: no
+
+=cut
+
+# Your plugin goes here. If takes any configuration or arguments, you
+# probably want to override L<Jifty::Plugin/init>.
+
+{
+ my ($CurrentUserClass, $UserClass);
+
+ sub init {
+ my $self = shift;
+ my %args = @_;
+ my $appname = Jifty->config->framework('ApplicationClass');
+ $UserClass = $args{UserClass}
+ || Jifty->app_class('Model','Users');
+ $CurrentUserClass = Jifty->app_class('CurrentUser')
+ }
+
+ sub CurrentUserClass {
+ return $CurrentUserClass;
+ }
+
+ sub UserClass {
+ return $UserClass;
+ }
+}
+
+
+1;
Added: jifty/branches/template-declare/plugins/Users/lib/Jifty/Plugin/Users/CurrentUser.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/Users/lib/Jifty/Plugin/Users/CurrentUser.pm Sat Jan 27 03:52:58 2007
@@ -0,0 +1,39 @@
+use warnings;
+use strict;
+
+
+package Jifty::Plugin::Users::CurrentUser;
+
+use base qw/Jifty::CurrentUser Jifty::Plugin::Users/;
+
+=head2 new PARAMHASH
+
+Instantiate a new current user object, loading the user by paramhash:
+
+ my $item = Jifty::Plugin::Login::Model::Item->new( Jifty::Plugin::Login::CurrentUser->new(email => 'user at site'));
+
+if you give the param
+ _bootstrap => 1
+
+your object will be marked as a bootstrap user. You can use that to do an endrun around acls.
+
+=cut
+
+
+
+sub _init {
+ my $self = shift;
+ my %args = (@_);
+ my $LoginUserClass = $self->UserClass;
+
+ if (delete $args{'_bootstrap'} ) {
+ $self->is_bootstrap_user(1);
+ } elsif (keys %args) {
+ $self->user_object($LoginUserClass->new(current_user => $self));
+ $self->user_object->load_by_cols(%args);
+ }
+ $self->SUPER::_init(%args);
+}
+
+
+1;
Added: jifty/branches/template-declare/plugins/Users/lib/Jifty/Plugin/Users/Dispatcher.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/Users/lib/Jifty/Plugin/Users/Dispatcher.pm Sat Jan 27 03:52:58 2007
@@ -0,0 +1,9 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::Users::Dispatcher;
+use Jifty::Dispatcher -base;
+
+# Put any plugin-specific dispatcher rules here.
+
+1;
Added: jifty/branches/template-declare/plugins/Users/lib/Jifty/Plugin/Users/Model/User.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/plugins/Users/lib/Jifty/Plugin/Users/Model/User.pm Sat Jan 27 03:52:58 2007
@@ -0,0 +1,141 @@
+package Jifty::Plugin::Users::Model::User;
+use base qw/Jifty::Record Jifty::Plugin::Users/;
+use Jifty::DBI::Schema;
+
+use Jifty::Record schema {
+column
+ display_name => type is 'text',
+ label is 'Name',
+ is mandatory;
+
+column
+ realm => type is 'text',
+ label is 'Identity Plugin',
+ is mandatory;
+
+column
+ created_date => type is 'date';
+
+column
+ updated_date => type is 'date';
+
+column
+ created_by => type is 'text';
+
+column
+ updated_by => type is 'text';
+
+column
+ last_login => type is 'date';
+
+## ???
+column
+ auth_token => type is 'text',
+ render_as 'Unrendered';
+};
+
+
+sub create {
+ my $self = shift;
+ my %args = (@_);
+ my (@ret) = $self->SUPER::create(%args);
+ # set created_date and created_by
+ return (@ret);
+}
+
+=head2 password_is STRING
+
+Returns true if and only if the current user's password matches STRING
+
+=cut
+
+#sub password_is {
+# my $self = shift;
+# my $string = shift;
+# return 1 if ( $self->_value('password') eq $string );
+# return 0;
+#}
+
+=head2 password
+
+Never display a password
+
+=cut
+
+sub password {
+ return undef;
+
+}
+
+=head2 current_user_can
+
+Allows the current user to see all their own attributes and
+everyone else to see their username.
+
+Allows the current user to update any of their own attributes
+except whether or not their email has been confirmed.
+
+Passes everything else off to the superclass.
+
+=cut
+
+sub current_user_can {
+ my $self = shift;
+ my $right = shift;
+ my %args = (@_);
+ # This line breaks admin mode. I like admin mode.
+ # Carp::confess if ( $right eq 'read' and not $args{'column'} );
+ if ( $right eq 'read'
+ and $self->id == $self->current_user->id )
+ {
+ return 1;
+ }
+ elsif ( $right eq 'read' and $args{'column'} eq 'display_name' ) {
+ return (1);
+
+ }
+ elsif ( $right eq 'update'
+ and $self->id == $self->current_user->id
+# and $args{'column'} ne 'email_confirmed'
+ )
+ {
+ return (1);
+ }
+
+ return $self->SUPER::current_user_can( $right, %args );
+}
+
+=head2 auth_token
+
+Returns the user's unique authentication token. If the user
+doesn't have one, sets one and returns it.
+
+=cut
+
+sub auth_token {
+ my $self = shift;
+ return undef
+ unless ( $self->current_user_can( read => column => 'auth_token' ) );
+ my $value = $self->_value('auth_token');
+ unless ($value) {
+ my $digest = Digest::MD5->new();
+ $digest->add( rand(100) );
+ $self->__set( column => 'auth_token', value => $digest->b64digest );
+ }
+ return $self->_value('auth_token');
+
+}
+
+=head2 record_class
+
+Identifies the correct record class for introspection
+
+=cut
+
+sub record_class {
+ my $self = shift;
+ return $self->UserClass;
+
+}
+
+1;
Modified: jifty/branches/template-declare/share/web/static/js/calendar.js
==============================================================================
--- jifty/branches/template-declare/share/web/static/js/calendar.js (original)
+++ jifty/branches/template-declare/share/web/static/js/calendar.js Sat Jan 27 03:52:58 2007
@@ -87,7 +87,6 @@
input.value = year + "-" + month + "-" + day;
Jifty.Calendar.hideOpenCalendar();
- Form.Element.validate( input ); // We can't trigger an onBlur, so canonicalize/validate manually
},
openCalendar: "",
@@ -104,8 +103,9 @@
var input = $( inputId );
- /* Reenable canonicalization */
+ /* Reenable canonicalization, and do it */
Form.Element.enableValidation(input);
+ Form.Element.validate(input);
Jifty.Calendar.openCalendar = "";
}
Modified: jifty/branches/template-declare/share/web/templates/__jifty/validator.xml
==============================================================================
--- jifty/branches/template-declare/share/web/templates/__jifty/validator.xml (original)
+++ jifty/branches/template-declare/share/web/templates/__jifty/validator.xml Sat Jan 27 03:52:58 2007
@@ -39,7 +39,7 @@
$writer->endTag();
$writer->startTag( "canonicalizeaction", id => $action->register_name );
for my $arg ( $action->argument_names ) {
- if ($ra->arguments->{$arg} eq $action->argument_value($arg) ) {
+ if (($ra->arguments->{$arg} || "") eq ($action->argument_value($arg) || "")) {
# if the value doesn't change, it can be ignored.
# canonicalizers can change other parts of the action, so we want to send all changes
$writer->emptyTag( "ignored", name => $action->form_field_name($arg) );
Modified: jifty/branches/template-declare/t/TestApp-Plugin-REST/t/02-basic-use.t
==============================================================================
--- jifty/branches/template-declare/t/TestApp-Plugin-REST/t/02-basic-use.t (original)
+++ jifty/branches/template-declare/t/TestApp-Plugin-REST/t/02-basic-use.t Sat Jan 27 03:52:58 2007
@@ -134,19 +134,10 @@
$mech->get_ok('/=/action/DoSomething.yml');
is($mech->status, 200);
-TODO: {
- local $TODO = "Waiting for YAML parameter lists for action";
- my %args;
-
- # Eval so this doesn't blow up if get_content doesn't return a hashref
- eval {
- %args = %{get_content()};
- };
-
- ok($args{email}, "Action has an email parameter");
- is($args{email}{label}, 'Email', 'email has the correct label');
- is($args{email}{default}, 'email at example.com', 'email has the correct default');
-}
+my %args = %{get_content()};
+ok($args{email}, "Action has an email parameter");
+is($args{email}{label}, 'Email', 'email has the correct label');
+is($args{email}{default_value}, 'example at email.com', 'email has the correct default');
# on POST '/=/action/*' => \&run_action;
Modified: jifty/branches/template-declare/t/TestApp/t/13-page-regions.t
==============================================================================
--- jifty/branches/template-declare/t/TestApp/t/13-page-regions.t (original)
+++ jifty/branches/template-declare/t/TestApp/t/13-page-regions.t Sat Jan 27 03:52:58 2007
@@ -24,7 +24,7 @@
for my $i (1 .. 5) {
ok($mech->find_link(text => "Short $i"), "Found link: Short $i");
$mech->follow_link_ok(text => "Short $i");
- $mech->content_contains(text => "Long $i");
+ $mech->content_contains("Long $i");
}
$mech->content_contains("Long $_")
@@ -33,7 +33,7 @@
ok($mech->find_link(text => "Long 1"), "Found link Long 1");
$mech->follow_link_ok(text => "Long 1");
-$mech->content_contains(text => "Short 1");
+$mech->content_contains("Short 1");
for my $i (2 .. 5) {
$mech->content_contains("Long $i");
$mech->content_lacks("Short $i");
More information about the Jifty-commit
mailing list