Re: [Mojolicious] Action is not allowed Template not found

2019-09-12 Thread Stefan Adams
Try an action name other than `tap`.  tap() is a method in Mojo::Base
 which just about every
class in Mojolicious inherits from.

In the Mojolicious::Lite app, you do not have a subroutine action named
`tap` -- you just have a callback.  In the full Mojolicious app, you have a
subroutine action named `tap`.  Specifically, these
 keywords are
hidden from the router.

On Fri, Sep 13, 2019 at 12:39 AM VadimN 
wrote:

> Hi,
>
> Using Websocket technology to periodically send new rows to the page.
>
> Under lite version all works fine.
>
> Server log for getting page, establishing WS connection, sending
> occasional new row to the page:
>
> at http://127.0.0.1:3000
> :44.91645] [4732] [debug] GET "/" (cd726066)
> :44.91768] [4732] [debug] Routing to a callback
> :45.10940] [4732] [debug] Rendering template "index.html.ep" from DATA
> section
> :45.11445] [4732] [debug] Rendering template "menu.html.ep" from DATA
> section
> :45.11736] [4732] [debug] Rendering template "datarows.html.ep" from DATA
> section
> :45.16243] [4732] [debug] 200 OK (0.245983s, 4.065/s)
> :46.35749] [4732] [debug] GET "/tap" (f0cc47e0)
> :46.36461] [4732] [debug] Routing to a callback
> :46.36624] [4732] [debug] 101 Switching Protocols (0.008739s, 114.430/s)
> :46.36646] [4732] [debug] WS for table append opened
> :58.41381] [4732] [debug] Rendering cached template "datarows.html.ep"
> from DATA section
> :58.41454] [4732] [debug] html sent; new id = 231378
>
>
> The problem occurred when switching from Mojolicious::Lite to the full
> version.
>
> Server log looks like this:
>
> at http://127.0.0.1:3000
> :17.64413] [6264] [debug] GET "/" (5b7cd6b9)
> :17.64681] [6264] [debug] Routing to controller
> "MyApp::Controller::FrontEnd" and action "index"
> :17.83067] [6264] [debug] Rendering template "front_end/index.html.ep"
> :17.83547] [6264] [debug] Rendering template "menu.html.ep"
> :17.83944] [6264] [debug] Rendering template "datarows.html.ep"
> :17.88862] [6264] [debug] Rendering template "layouts/default.html.ep"
> :17.89673] [6264] [debug] 200 OK (0.252574s, 3.959/s)
> :19.47888] [6264] [debug] GET "/tap" (2727832e)
> :19.48026] [6264] [debug] Action "tap" is not allowed
> :19.48132] [6264] [debug] Template "front_end/tap.html.ep" not found
> :19.48225] [6264] [debug] Template "not_found.development.html.ep" not
> found
> :19.48310] [6264] [debug] Template "not_found.html.ep" not found
> :19.48413] [6264] [debug] Rendering template "mojo/debug.html.ep"
> :19.53478] [6264] [debug] 404 Not Found (0.055844s, 17.907/s)
>
> In the Lite app theris function call
>
> websocket '/tap' => sub {
> my $c = shift;
>
> #get some data from outside
> #...
>
>
> # as the test showed, this is not necessary for lite app
> #$c->on(message => sub {
> #});
>
> my $id = Mojo::IOLoop->recurring(3 => sub {
>
> #check for the new data
> #...
>
> if (new data found) {
> ...
> my $html = $c->render_to_string('datarows');
> $c->send($html);
> $c->app->log->debug("html sent; new id = $max_id");
> }
> });
>
> $c->on(finish => sub {
> Mojo::IOLoop->remove($id);
> $c->app->log->debug("WS for table append closed");
> });
>
> $c->app->log->debug('WS for table append opened');
> };
>
>
> This is transforms to couple parts in full app code.
> In startup function
>
> $r->websocket('/tap')->to('front_end#tap');
>
> In the FrontEnd controller:
>
> sub tap {
> my $self = shift;
>
> # get some data
> #...
>
> my $id = Mojo::IOLoop->recurring(3 => sub {
>
> # check for data
>
> # if found
> if (...) {
> ...
> #all the same
> };
>
>
> Why was he asking about a nonexistent template?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mojolicious+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mojolicious/d6b383e5-b1d4-4cd2-bf4f-ef2fc0e99e71%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mojolicious/CACyQ%2BFSu5pV03eyDmVtr%2BPFtyVSSJYq%3DyNhMCAur7Dy0jXkX4Q%40mail.gmail.com.


[Mojolicious] Action is not allowed Template not found

2019-09-12 Thread VadimN
Hi,

Using Websocket technology to periodically send new rows to the page.

Under lite version all works fine.

Server log for getting page, establishing WS connection, sending occasional 
new row to the page:

at http://127.0.0.1:3000
:44.91645] [4732] [debug] GET "/" (cd726066)
:44.91768] [4732] [debug] Routing to a callback
:45.10940] [4732] [debug] Rendering template "index.html.ep" from DATA 
section
:45.11445] [4732] [debug] Rendering template "menu.html.ep" from DATA 
section
:45.11736] [4732] [debug] Rendering template "datarows.html.ep" from DATA 
section
:45.16243] [4732] [debug] 200 OK (0.245983s, 4.065/s)
:46.35749] [4732] [debug] GET "/tap" (f0cc47e0)
:46.36461] [4732] [debug] Routing to a callback
:46.36624] [4732] [debug] 101 Switching Protocols (0.008739s, 114.430/s)
:46.36646] [4732] [debug] WS for table append opened
:58.41381] [4732] [debug] Rendering cached template "datarows.html.ep" from 
DATA section
:58.41454] [4732] [debug] html sent; new id = 231378


The problem occurred when switching from Mojolicious::Lite to the full 
version.

Server log looks like this:

at http://127.0.0.1:3000
:17.64413] [6264] [debug] GET "/" (5b7cd6b9)
:17.64681] [6264] [debug] Routing to controller 
"MyApp::Controller::FrontEnd" and action "index"
:17.83067] [6264] [debug] Rendering template "front_end/index.html.ep"
:17.83547] [6264] [debug] Rendering template "menu.html.ep"
:17.83944] [6264] [debug] Rendering template "datarows.html.ep"
:17.88862] [6264] [debug] Rendering template "layouts/default.html.ep"
:17.89673] [6264] [debug] 200 OK (0.252574s, 3.959/s)
:19.47888] [6264] [debug] GET "/tap" (2727832e)
:19.48026] [6264] [debug] Action "tap" is not allowed
:19.48132] [6264] [debug] Template "front_end/tap.html.ep" not found
:19.48225] [6264] [debug] Template "not_found.development.html.ep" not found
:19.48310] [6264] [debug] Template "not_found.html.ep" not found
:19.48413] [6264] [debug] Rendering template "mojo/debug.html.ep"
:19.53478] [6264] [debug] 404 Not Found (0.055844s, 17.907/s)

In the Lite app theris function call

websocket '/tap' => sub {
my $c = shift;

#get some data from outside
#...


# as the test showed, this is not necessary for lite app
#$c->on(message => sub {
#});

my $id = Mojo::IOLoop->recurring(3 => sub {

#check for the new data
#...
 
if (new data found) {
...
my $html = $c->render_to_string('datarows');
$c->send($html);
$c->app->log->debug("html sent; new id = $max_id");
}
});

$c->on(finish => sub {
Mojo::IOLoop->remove($id);
$c->app->log->debug("WS for table append closed");
});

$c->app->log->debug('WS for table append opened');
};


This is transforms to couple parts in full app code.
In startup function

$r->websocket('/tap')->to('front_end#tap');

In the FrontEnd controller:

sub tap {
my $self = shift;

# get some data
#...

my $id = Mojo::IOLoop->recurring(3 => sub {

# check for data

# if found
if (...) {
...
#all the same
};


Why was he asking about a nonexistent template?

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mojolicious/d6b383e5-b1d4-4cd2-bf4f-ef2fc0e99e71%40googlegroups.com.