[Jifty-commit] r4656 - in jifty/trunk: lib/Jifty
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sat Dec 8 18:20:39 EST 2007
Author: jesse
Date: Sat Dec 8 18:20:38 2007
New Revision: 4656
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Config.pm
jifty/trunk/lib/Jifty/Dispatcher.pm
jifty/trunk/lib/Jifty/Handler.pm
Log:
r72830 at pinglin: jesse | 2007-12-08 18:20:30 -0500
* Make view handler classes configurable.
Modified: jifty/trunk/lib/Jifty/Config.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Config.pm (original)
+++ jifty/trunk/lib/Jifty/Config.pm Sat Dec 8 18:20:38 2007
@@ -255,19 +255,20 @@
if (@_) {
$app_name = shift;
}
-
+
# Is it already in the stash?
- elsif ($self->stash->{framework}->{ApplicationName}) {
- $app_name = $self->stash->{framework}->{ApplicationName};
- }
-
+ elsif ( $self->stash->{framework}->{ApplicationName} ) {
+ $app_name = $self->stash->{framework}->{ApplicationName};
+ }
+
# Finally, just guess from the application root
else {
- $app_name = Jifty::Util->default_app_name;
+ $app_name = Jifty::Util->default_app_name;
}
# Setup the application class name based on the application name
- my $app_class = $self->stash->{framework}->{ApplicationClass} ||$app_name;
+ my $app_class = $self->stash->{framework}->{ApplicationClass}
+ || $app_name;
$app_class =~ s/-/::/g;
my $db_name = lc $app_name;
$db_name =~ s/-/_/g;
@@ -276,48 +277,55 @@
# Build up the guessed configuration
my $guess = {
framework => {
- AdminMode => 1,
- DevelMode => 1,
+ AdminMode => 1,
+ DevelMode => 1,
SkipAccessControl => 0,
- ApplicationClass => $app_class,
- TemplateClass => $app_class."::View",
- ApplicationName => $app_name,
- ApplicationUUID => $app_uuid,
- LogLevel => 'INFO',
- PubSub => {
- Enable => undef,
+ ApplicationClass => $app_class,
+ TemplateClass => $app_class . "::View",
+ ApplicationName => $app_name,
+ ApplicationUUID => $app_uuid,
+ LogLevel => 'INFO',
+ PubSub => {
+ Enable => undef,
Backend => 'Memcached',
},
- Database => {
- AutoUpgrade => 1,
- Database => $db_name,
- Driver => "SQLite",
- Host => "localhost",
- Password => "",
- User => "",
- Version => "0.0.1",
+ Database => {
+ AutoUpgrade => 1,
+ Database => $db_name,
+ Driver => "SQLite",
+ Host => "localhost",
+ Password => "",
+ User => "",
+ Version => "0.0.1",
RecordBaseClass => 'Jifty::DBI::Record::Cachable',
- CheckSchema => '1'
+ CheckSchema => '1'
},
Mailer => 'Sendmail',
MailerArgs => [],
- L10N => {
- PoDir => "share/po",
+ L10N => { PoDir => "share/po", },
+
+ View => {
+ FallbackHandler => 'Jifty::View::Mason::Handler',
+ Handlers => [
+ 'Jifty::View::Static::Handler',
+ 'Jifty::View::Declare::Handler',
+ 'Jifty::View::Mason::Handler'
+ ]
},
- Web => {
- Port => '8888',
- BaseURL => 'http://localhost',
- DataDir => "var/mason",
- StaticRoot => "share/web/static",
- TemplateRoot => "share/web/templates",
+ Web => {
+ Port => '8888',
+ BaseURL => 'http://localhost',
+ DataDir => "var/mason",
+ StaticRoot => "share/web/static",
+ TemplateRoot => "share/web/templates",
ServeStaticFiles => 1,
- MasonConfig => {
- autoflush => 0,
- error_mode => 'fatal',
- error_format => 'text',
+ MasonConfig => {
+ autoflush => 0,
+ error_mode => 'fatal',
+ error_format => 'text',
default_escape_flags => 'h',
},
- Globals => [],
+ Globals => [],
},
},
};
Modified: jifty/trunk/lib/Jifty/Dispatcher.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Dispatcher.pm (original)
+++ jifty/trunk/lib/Jifty/Dispatcher.pm Sat Dec 8 18:20:38 2007
@@ -1183,23 +1183,21 @@
my $self = shift;
my $template = shift;
my $showed = 0;
-# local $@;
eval {
foreach my $handler ( Jifty->handler->view_handlers ) {
- if ( Jifty->handler->view($handler)->template_exists($template) ) {
+ my $handler_class = Jifty->handler->view($handler);
+ if ( $handler_class->template_exists($template) ) {
+ $handler_class->show($template);
$showed = 1;
- Jifty->handler->view($handler)->show($template);
last;
}
}
if ( not $showed and my $fallback_handler = Jifty->handler->fallback_view_handler ) {
$fallback_handler->show($template);
}
-
};
my $err = $@;
-
# Handle parse errors
$self->log->fatal("view class error: $err") if $err;
if ( $err and not eval { $err->isa('HTML::Mason::Exception::Abort') } ) {
@@ -1221,7 +1219,6 @@
} elsif ($err) {
die $err;
}
-
}
Modified: jifty/trunk/lib/Jifty/Handler.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Handler.pm (original)
+++ jifty/trunk/lib/Jifty/Handler.pm Sat Dec 8 18:20:38 2007
@@ -92,23 +92,41 @@
Returns a list of modules implementing view for your Jifty application.
-XXX TODO: this should take pluggable views
+You can override this by specifying:
+
+ framework:
+ View:
+ Handlers:
+ - Jifty::View::Something::Handler
+ - Jifty::View::SomethingElse::Handler
-=cut
+=cut
-sub view_handlers { qw(Jifty::View::Static::Handler Jifty::View::Declare::Handler Jifty::View::Mason::Handler)}
+sub view_handlers {
+ @{Jifty->config->framework('View')->{'Handlers'}}
+}
=head2 fallback_view_handler
Returns the object for our "last-resort" view handler. By default, this is the L<HTML::Mason> handler.
+You can override this by specifying:
+
+ framework:
+ View:
+ FallbackHandler: Jifty::View::Something::Handler
+
=cut
-sub fallback_view_handler { my $self = shift; return $self->view('Jifty::View::Mason::Handler') }
+sub fallback_view_handler {
+ my $self = shift;
+ return $self->view(Jifty->config->framework('View')->{'FallbackHandler'});
+
+}
=head2 setup_view_handlers
More information about the Jifty-commit
mailing list