[Jifty-commit] jifty branch, setupwizard-refactor, updated. 0d3f6a68b0d2422558075e4d2a66a881d3b10c50
Jifty commits
jifty-commit at lists.jifty.org
Fri Jun 18 00:40:03 EDT 2010
The branch, setupwizard-refactor has been updated
via 0d3f6a68b0d2422558075e4d2a66a881d3b10c50 (commit)
from 053516f4d9ebd3761c581017ed3bcb1efa2ad141 (commit)
Summary of changes:
lib/Jifty.pm | 14 ++++++++++++--
lib/Jifty/CurrentUser.pm | 28 ++++++++++++++++++++++++++++
lib/Jifty/Web.pm | 2 ++
3 files changed, 42 insertions(+), 2 deletions(-)
- Log -----------------------------------------------------------------
commit 0d3f6a68b0d2422558075e4d2a66a881d3b10c50
Author: Thomas Sibley <trs at bestpractical.com>
Date: Fri Jun 18 00:37:08 2010 -0400
Split SetupMode from Jifty->admin_mode
And then use a bootstrap user for SetupMode rather than the superuser in
case the superuser depends on the database.
diff --git a/lib/Jifty.pm b/lib/Jifty.pm
index 477ac74..79f8b60 100644
--- a/lib/Jifty.pm
+++ b/lib/Jifty.pm
@@ -560,8 +560,18 @@ of C<< Jifty->config->framework('AdminMode') >>.
=cut
sub admin_mode {
- return Jifty->config->framework('AdminMode')
- || Jifty->config->framework('SetupMode');
+ return Jifty->config->framework('AdminMode');
+}
+
+=head2 setup_mode
+
+Returns true if the application is in setup mode. This should be used instead
+of C<< Jifty->config->framework('SetupMode') >>.
+
+=cut
+
+sub setup_mode {
+ return Jifty->config->framework('SetupMode');
}
=head1 SEE ALSO
diff --git a/lib/Jifty/CurrentUser.pm b/lib/Jifty/CurrentUser.pm
index c6b9707..4083e49 100644
--- a/lib/Jifty/CurrentUser.pm
+++ b/lib/Jifty/CurrentUser.pm
@@ -90,6 +90,12 @@ sub _init {
A convenience constructor that returns a new CurrentUser object that's
marked as a superuser. Can be called either as a class or object method.
+If you override this method in your app, keep in mind that it may be called if
+AdminMode is on during schema creation when the database doesn't exist yet.
+This will cause a lot of warnings, may not do what you want, and if you're
+running Postgres may cause the schema creation to fail. That said, overriding
+this method is often very useful when implementing ACLs.
+
=cut
sub superuser {
@@ -104,6 +110,28 @@ sub superuser {
return $self;
}
+=head2 bootstrap_user
+
+A convenience constructor that returns a new CurrentUser object which is
+marked as a bootstrap user. Can be called either as a class or object method.
+
+You probably shouldn't ever override this method, as the bootstrap user should
+be as independent as possible.
+
+=cut
+
+sub bootstrap_user {
+ my $class = shift;
+ $class = ref( $class ) if ref $class;
+
+ # Create the current user object
+ my $self = $class->new();
+
+ # Make it bootstrap and send it out
+ $self->is_bootstrap_user(1);
+ return $self;
+}
+
=head2 user_object
This gets or sets your application's user object for the current
diff --git a/lib/Jifty/Web.pm b/lib/Jifty/Web.pm
index d254225..39b3d10 100644
--- a/lib/Jifty/Web.pm
+++ b/lib/Jifty/Web.pm
@@ -240,6 +240,8 @@ sub current_user {
$object = Jifty->app_class({require => 0}, "CurrentUser")->new( id => $id );
} elsif ( Jifty->admin_mode ) {
$object = Jifty->app_class({require => 0}, "CurrentUser")->superuser;
+ } elsif ( Jifty->setup_mode ) {
+ $object = Jifty->app_class({require => 0}, "CurrentUser")->bootstrap_user;
} else {
$object = Jifty->app_class({require => 0}, "CurrentUser")->new;
}
-----------------------------------------------------------------------
More information about the Jifty-commit
mailing list