[Jifty-commit] r2862 - in jifty/branches/template-declare: .
lib/Jifty lib/Jifty/Plugin lib/Jifty/Plugin/Authentication
lib/Jifty/Plugin/Authentication/Password
lib/Jifty/Plugin/Authentication/Password/Model
lib/Jifty/Plugin/User lib/Jifty/Plugin/User/Model
t/TestApp-Plugin-PasswordAuth t/TestApp-Plugin-PasswordAuth/bin
t/TestApp-Plugin-PasswordAuth/doc t/TestApp-Plugin-PasswordAuth/etc
t/TestApp-Plugin-PasswordAuth/lib
t/TestApp-Plugin-PasswordAuth/lib/TestApp
t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin
t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/PasswordAuth
t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/PasswordAuth/Action
t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/PasswordAuth/Model
t/TestApp-Plugin-PasswordAuth/log
t/TestApp-Plugin-PasswordAuth/share
t/TestApp-Plugin-PasswordAuth/share/po
t/TestApp-Plugin-PasswordAuth/share/web
t/TestApp-Plugin-PasswordAuth/share/web/static
t/TestApp-Plugin-PasswordAuth/share/web/templates
t/TestApp-Plugin-PasswordAuth/t t/TestApp-Plugin-PasswordAuth/var
t/TestApp-Plugin-PasswordAuth/var/mason
t/TestApp-Plugin-PasswordAuth/var/mason/obj
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Tue Feb 27 22:43:00 EST 2007
Author: jesse
Date: Tue Feb 27 22:42:59 2007
New Revision: 2862
Added:
jifty/branches/template-declare/lib/Jifty/Plugin/Authentication/
jifty/branches/template-declare/lib/Jifty/Plugin/Authentication/Password/
jifty/branches/template-declare/lib/Jifty/Plugin/Authentication/Password.pm
jifty/branches/template-declare/lib/Jifty/Plugin/Authentication/Password/Model/
jifty/branches/template-declare/lib/Jifty/Plugin/Authentication/Password/Model/User.pm
jifty/branches/template-declare/lib/Jifty/Plugin/User/
jifty/branches/template-declare/lib/Jifty/Plugin/User.pm
jifty/branches/template-declare/lib/Jifty/Plugin/User/Model/
jifty/branches/template-declare/lib/Jifty/Plugin/User/Model/User.pm
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/Makefile.PL
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/bin/
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/bin/jifty (contents, props changed)
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/doc/
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/etc/
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/etc/config.yml
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/lib/
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/lib/TestApp/
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/PasswordAuth/
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/PasswordAuth/Action/
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/PasswordAuth/Model/
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/PasswordAuth/Model/User.pm
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/log/
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/share/
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/share/po/
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/share/web/
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/share/web/static/
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/share/web/templates/
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/t/
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/t/00-model-User.t
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/t/mailbox
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/var/
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/var/mason/
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/var/mason/cache/
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/var/mason/obj/
jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/var/mason/obj/.__obj_create_marker
Modified:
jifty/branches/template-declare/ (props changed)
jifty/branches/template-declare/lib/Jifty/Plugin.pm
jifty/branches/template-declare/lib/Jifty/Plugin/ClassLoader.pm
jifty/branches/template-declare/lib/Jifty/TestServer.pm
Log:
r48591 at pinglin: jesse | 2007-02-27 22:41:10 -0500
* very first cut of being able to mix plugin model classes into your own model class
Modified: jifty/branches/template-declare/lib/Jifty/Plugin.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Plugin.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Plugin.pm Tue Feb 27 22:42:59 2007
@@ -118,7 +118,7 @@
sub template_root {
my $self = shift;
- $self->_calculate_share();
+ $self->{share} || $self->_calculate_share();
return unless $self->{share};
return $self->{share}."/web/templates";
}
@@ -145,6 +145,7 @@
sub static_root {
my $self = shift;
+ $self->{share} || $self->_calculate_share();
return unless $self->{share};
return $self->{share}."/web/static";
}
Added: jifty/branches/template-declare/lib/Jifty/Plugin/Authentication/Password.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/lib/Jifty/Plugin/Authentication/Password.pm Tue Feb 27 22:42:59 2007
@@ -0,0 +1,10 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::Authentication::Password;
+use base qw/Jifty::Plugin/;
+
+# Your plugin goes here. If takes any configuration or arguments, you
+# probably want to override L<Jifty::Plugin/init>.
+
+1;
Added: jifty/branches/template-declare/lib/Jifty/Plugin/Authentication/Password/Model/User.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/lib/Jifty/Plugin/Authentication/Password/Model/User.pm Tue Feb 27 22:42:59 2007
@@ -0,0 +1,15 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::Authentication::Password::Model::User;
+use Jifty::DBI::Schema;
+use base 'Jifty::DBI::Record::Plugin';
+use Jifty::Plugin::Authentication::Password::Record schema {
+ column password => type is 'text', render as 'Password', is unreadable;
+};
+
+
+# Your model-specific methods go here.
+
+1;
+
Modified: jifty/branches/template-declare/lib/Jifty/Plugin/ClassLoader.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Plugin/ClassLoader.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Plugin/ClassLoader.pm Tue Feb 27 22:42:59 2007
@@ -32,7 +32,12 @@
sub new {
my $class = shift;
- my $self = bless {@_}, $class;
+ my %args = (@_);
+ my @exist = grep {ref $_ eq $class and $_->{base} eq $args{base}} @INC;
+ return $exist[0] if @exist;
+
+
+ my $self = bless {%args}, $class;
push @INC, $self;
return $self;
@@ -204,4 +209,29 @@
}
}
+=head2 DESTROY
+
+When the ClassLoader gets garbage-collected, its entry in @INC needs
+to be removed.
+
+=cut
+
+# The entries in @INC end up having SvTYPE == SVt_RV, but SvRV(sv) ==
+# 0x0 and !SvROK(sv) (!?) This may be something that perl should cope
+# with more cleanly.
+#
+# We call this explictly in an END block in Jifty.pm, because
+# otherwise the DESTROY block gets called *after* there's already a
+# bogus entry in @INC
+
+# This bug manifests itself as warnings that look like this:
+
+# Use of uninitialized value in require at /tmp/7730 line 9 during global destruction.
+
+
+sub DESTROY {
+ my $self = shift;
+ @INC = grep {!$self} @INC;
+}
+
1;
Added: jifty/branches/template-declare/lib/Jifty/Plugin/User.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/lib/Jifty/Plugin/User.pm Tue Feb 27 22:42:59 2007
@@ -0,0 +1,10 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::User;
+use base qw/Jifty::Plugin/;
+
+# Your plugin goes here. If takes any configuration or arguments, you
+# probably want to override L<Jifty::Plugin/init>.
+
+1;
Added: jifty/branches/template-declare/lib/Jifty/Plugin/User/Model/User.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/lib/Jifty/Plugin/User/Model/User.pm Tue Feb 27 22:42:59 2007
@@ -0,0 +1,17 @@
+use strict;
+use warnings;
+
+package Jifty::Plugin::User::Model::User;
+use Jifty::DBI::Schema;
+
+use base 'Jifty::DBI::Record::Plugin';
+use Jifty::Plugin::User::Record schema {
+ column name => type is 'text', label is 'How should I display your name?';
+ column username => type is 'text';
+};
+
+
+# Your model-specific methods go here.
+
+1;
+
Modified: jifty/branches/template-declare/lib/Jifty/TestServer.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/TestServer.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/TestServer.pm Tue Feb 27 22:42:59 2007
@@ -53,9 +53,20 @@
$SIG{USR1} = sub { };
sleep 15;
$self->{started} = 1;
+ Jifty->handle->dbh->{'InactiveDestroy'} = 1;
$Tester->ok(1, $text);
# XXX: pull from jifty::config maybe
return "http://localhost:".$self->port;
+ } else {
+ Jifty->handle->dbh->{'InactiveDestroy'} = 1;
+ # See DBI.pm:
+ #
+ # This attribute is specifically designed for use in Unix applications
+ # that "fork" child processes. Either the parent or the child process,
+ # but not both, should set C<InactiveDestroy> true on all their shared handles.
+ # (Note that some databases, including Oracle, don't support passing a
+ # database connection across a fork.)
+ #
}
require POSIX;
Added: jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/Makefile.PL
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/Makefile.PL Tue Feb 27 22:42:59 2007
@@ -0,0 +1,7 @@
+use inc::Module::Install;
+
+name 'TestApp::Plugin::PasswordAuth';
+version '0.01';
+requires 'Jifty' => '0.70117';
+
+WriteAll;
Added: jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/bin/jifty
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/bin/jifty Tue Feb 27 22:42:59 2007
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+use File::Basename qw(dirname);
+use UNIVERSAL::require;
+
+BEGIN {
+ Jifty::Util->require or die $UNIVERSAL::require::ERROR;
+ my $root = Jifty::Util->app_root;
+ unshift @INC, "$root/lib" if ($root);
+}
+
+use Jifty::Script;
+local $SIG{INT} = sub { warn "Stopped\n"; exit; };
+Jifty::Script->dispatch();
Added: jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/etc/config.yml
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/etc/config.yml Tue Feb 27 22:42:59 2007
@@ -0,0 +1,58 @@
+---
+framework:
+ AdminMode: 1
+ ApplicationClass: TestApp::Plugin::PasswordAuth
+ ApplicationName: TestApp-Plugin-PasswordAuth
+ ApplicationUUID: E6B4180A-C68F-11DB-893B-FEFB1AECF28B
+ Database:
+ CheckSchema: 1
+ Database: testapp_plugin_passwordauth
+ Driver: SQLite
+ Host: localhost
+ Password: ''
+ RecordBaseClass: Jifty::DBI::Record::Cachable
+ User: ''
+ Version: 0.0.1
+ DevelMode: 1
+ L10N:
+ PoDir: share/po
+ LogLevel: INFO
+ Mailer: Sendmail
+ MailerArgs: []
+
+ Plugins:
+ - User: {}
+ - Authentication::Password: {}
+ -
+ REST: {}
+
+ -
+ Halo: {}
+
+ -
+ OnlineDocs: {}
+
+ -
+ CompressedCSSandJS: {}
+
+ -
+ AdminUI: {}
+
+ PubSub:
+ Backend: Memcached
+ Enable: ~
+ TemplateClass: TestApp::Plugin::PasswordAuth::View
+ Web:
+ BaseURL: http://localhost
+ DataDir: var/mason
+ Globals: []
+
+ MasonConfig:
+ autoflush: 0
+ default_escape_flags: h
+ error_format: text
+ error_mode: fatal
+ Port: 8888
+ ServeStaticFiles: 1
+ StaticRoot: share/web/static
+ TemplateRoot: share/web/templates
Added: jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/PasswordAuth/Model/User.pm
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/lib/TestApp/Plugin/PasswordAuth/Model/User.pm Tue Feb 27 22:42:59 2007
@@ -0,0 +1,19 @@
+use strict;
+use warnings;
+
+package TestApp::Plugin::PasswordAuth::Model::User;
+use Jifty::DBI::Schema;
+
+# Mixins
+
+use TestApp::Plugin::PasswordAuth::Record schema {
+
+};
+
+use Jifty::Plugin::User::Model::User;
+use Jifty::Plugin::Authentication::Password::Model::User;
+
+# Your model-specific methods go here.
+
+1;
+
Added: jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/t/00-model-User.t
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/t/00-model-User.t Tue Feb 27 22:42:59 2007
@@ -0,0 +1,34 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+A basic test harness for the User model.
+
+=cut
+
+use Jifty::Test tests => 10;
+
+# Make sure we can load the model
+use_ok('TestApp::Plugin::PasswordAuth::Model::User');
+
+# Grab a system user
+my $system_user = TestApp::Plugin::PasswordAuth::CurrentUser->superuser;
+ok($system_user, "Found a system user");
+
+# Try testing a create
+my $o = TestApp::Plugin::PasswordAuth::Model::User->new(current_user => $system_user);
+my ($id) = $o->create( name => 'jesse',
+ username => 'jrv',
+ password => 'secret');
+ok($id, "User create returned success");
+ok($o->id, "New User has valid id set");
+is($o->id, $id, "Create returned the right id");
+
+can_ok($o, 'name');
+
+is($o->name, 'jesse');
+ok(!$o->password, "Can't get the password");
+can_ok($o,'set_password');
+is($o->__value('password'), 'secret');
Added: jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/t/mailbox
==============================================================================
Added: jifty/branches/template-declare/t/TestApp-Plugin-PasswordAuth/var/mason/obj/.__obj_create_marker
==============================================================================
More information about the Jifty-commit
mailing list