make plugin work without session
Closed this issue · 0 comments
mtths commented
currently, if sessions are disabled, the exception in Lexicon.pm line 64 gets rethrown [0]
please accept the patch below to make sessions optional
[0] Couldn't render template "core - Must specify session engine in settings prior to using 'session' keyword at /usr/local/share/perl/5.14.2/Dancer/Plugin/Lexicon.pm line 64.
" at /usr/local/share/perl/5.14.2/Dancer/Template/Abstract.pm line 89.
--- Dancer-Plugin-Lexicon-0.05-orig/lib/Dancer/Plugin/Lexicon.pm 2012-08-06 15:15:34.000000000 +0200
+++ Dancer-Plugin-Lexicon-0.05/lib/Dancer/Plugin/Lexicon.pm 2014-03-27 10:36:59.000000000 +0100
@@ -45,8 +45,10 @@
my $settings = _setup_i18n();
my $session_name = $settings->{session_name} || 'lang';
+ my $sessions_available = engine('session') ? 1 : 0;
+
my $lang = param( $settings->{param_name} || "lang" )
- || eval { session $session_name};
+ || ($sessions_available ? session($session_name) : undef);
my @langs;
if ($lang) {
@@ -61,7 +63,9 @@
$lang = _set_language(@langs)->language_tag;
- eval { session $session_name => $lang };
+ if ($sessions_available) {
+ session $session_name => $lang ;
+ }
};
#===================================