On Mon, 5 Dec 2016, sri wrote:

> Make a minimal test case demonstrating the problem.

Problem occurs when I 'use' a module, which 'use's M::L, without declaring 
a namespace.

[root@dsfdsfd functions]# cat test.mount 
#!/usr/bin/perl

use Mojolicious::Lite;

plugin Mount => {'/one' => './one'};
plugin Mount => {'/two' => './two'};

app->start;

[root@dsfdsfd functions]# cat My/ML.pm 
use Mojolicious::Lite;
1;
[root@dsfdsfd functions]# cat one
#!/usr/bin/perl

use My::ML;

get '/' => sub { shift->render(text => 'one') }; 

app->start;
[root@dsfdsfd functions]# cat two
#!/usr/bin/perl

use My::ML;

get '/' => sub { shift->render(text => 'two') }; 

app->start;
[root@dsfdsfd functions]# 
[root@dsfdsfd functions]# perl -I. test.mount 
[Tue Dec  6 11:33:34 2016] [debug] Your secret passphrase needs to be 
changed
String found where operator expected at /etc/e-smith/web/functions/two 
line 5, near "get '/'"
        (Do you need to predeclare get?)
Can't load application from file "/etc/e-smith/web/functions/two": syntax 
error at /etc/e-smith/web/functions/two line 5, near "get '/'"
Compilation failed in require at (eval 81) line 1.
[root@dsfdsfd functions]# 

The reason for not using a namespace is that I want to use 'app' to set 
some defaults. For instance, I want to do these:

app->defaults(layout => 'server_manager');
app->log->level('warn');
push @{app->renderer->paths}, '/etc/e-smith/web/panels/manager/templates';

in My::ML. I tried these, with none of them working:

 Mojolicious::Lite->app
 Mojolicious::Lite:app
 caller->app

Perhaps I should be defining a 'ServerManager' plugin, and setting the 
common defaults inside the register() method there.

Reply via email to