Re: [Mojolicious] JSON::XS for json responses

2014-12-29 Thread Dan Book
FYI (now that I am on this group) I uploaded Mojo::JSON::MaybeXS a while back also based on sri's earlier post, which will use the fallback behavior of JSON::MaybeXS and default to Cpanel::JSON::XS. On a related note Cpanel::JSON::XS has recently fixed the handling of upgraded numbers and inf/n

Re: [Mojolicious] trouble with scraping dynamically loaded page...

2015-02-11 Thread Dan Book
You are doing a synchronous get() so the entire page is loaded by the time that call returns. The # part of a URL ("fragment") is only read by the javascript, so whatever is supposed to check that will not get executed by Mojo::UserAgent. You need a javascript engine. On Wed, Feb 11, 2015 at 3:11

Re: [Mojolicious] trouble with scraping dynamically loaded page...

2015-02-11 Thread Dan Book
Alternatively, you can look at the page's javascript or the requests in your debug console and figure out what it's requesting and you might be able to do that yourself. On Wed, Feb 11, 2015 at 4:41 PM, Dan Book wrote: > You are doing a synchronous get() so the entire page is loade

Re: [Mojolicious] using IOLoop in controller for web sockets

2015-02-11 Thread Dan Book
- References to the app from the controller will only be available when the controller is instantiated by the app, i.e. to run an action. - The IOLoop setup should be done in the app's startup routine. The collectData stuff should also probably be done in the app module. You can add methods to your

Re: [Mojolicious] Accessing response cookies by name?

2015-03-10 Thread Dan Book
https://metacpan.org/pod/Mojo::Message#cookie On Tue, Mar 10, 2015 at 4:41 PM, Charlie Brady < charlieb-m...@budge.apana.org.au> wrote: > > I'm using Test::Mojo to verify cookie handling in some existing code. I > don't see an elegant way to verify that cookies with the right value are > being se

Re: [Mojolicious] JSON::XS for json responses

2015-03-11 Thread Dan Book
Actually _decode_value from Mojo::JSON should also be overridden by the monkey patching. Are you sure you have used the modules correctly? On Wed, Mar 11, 2015 at 10:06 AM, Dan Book wrote: > I submitted a PR for this issue. https://github.com/kraih/mojo/pull/758 > Thanks! > > On

Re: [Mojolicious] JSON::XS for json responses

2015-03-12 Thread Dan Book
I submitted a PR for this issue. https://github.com/kraih/mojo/pull/758 Thanks! On Wed, Mar 11, 2015 at 8:59 AM, njzt wrote: > >> Not sure why it hasn't been announced here, but there's Mojo::JSON_XS >> already. >> >> https://metacpan.org/pod/Mojo::JSON_XS >> >> -- >> sebastian >> > > I use

Re: [Mojolicious] Re: Mojo::IOLoop::Delay

2015-03-13 Thread Dan Book
You should consider cultural differences yourself. You are posting in forums moderated by people who are allowed to moderate how they choose. If you found a critical bug, that is an appropriate use of a github issue. Changing comments, being offensive, and asking questions that should go on a maili

Re: [Mojolicious] Re: Mojo::IOLoop::Delay

2015-03-13 Thread Dan Book
Because a circular reference is when a reference to an object is stored in itself. When they are stored outside the object it is impossible for that to happen by definition. On Sat, Mar 14, 2015 at 12:55 AM, s...@alexbyk.com wrote: > "by storing the callbacks outside of the delay object, we avo

Re: [Mojolicious] Hypnotoad forks and nginx reverse proxy

2015-03-19 Thread Dan Book
The idea is that hypnotoad will manage its workers, so yes, you cannot rely on which worker will handle a given connection. Each worker should run their own IOLoop and thus their own timers. If you describe the issue more precisely maybe we can help further. On Thu, Mar 19, 2015 at 3:46 AM, Bakano

Re: [Mojolicious] Re: Problem with Mojo::Pg

2015-03-24 Thread Dan Book
That is not correct. The callback from $delay->begin is intended to be invoked when the non-blocking activity is ready, after the control has returned to the event loop. On Tue, Mar 24, 2015 at 9:57 AM, Daniel Mantovani wrote: > In Mojo::IOLoop either $delay->begin or $delay->end must be invoked

Re: [Mojolicious] Re: Why does Mojo::Server::Daemon debugging print to STDERR?

2015-04-03 Thread Dan Book
Also note this will affect all app log output, including errors. On Fri, Apr 3, 2015 at 7:55 PM, Dan Book wrote: > $app->log->handle(\*STDOUT); (untested) > > On Fri, Apr 3, 2015 at 6:04 PM, Nathan Waddell > wrote: > >> After some research, it looks like this is be

Re: [Mojolicious] Re: Why does Mojo::Server::Daemon debugging print to STDERR?

2015-04-03 Thread Dan Book
$app->log->handle(\*STDOUT); (untested) On Fri, Apr 3, 2015 at 6:04 PM, Nathan Waddell wrote: > After some research, it looks like this is because Mojo::Log defaults to > STDERR: > > has handle => sub { > > # STDERR > return \*STDERR unless my $path = shift->path; > > # File > croak qq{C

Re: [Mojolicious] How to disable insecure protocols and ciphers?

2015-04-05 Thread Dan Book
Hello, If you are using the latest version of IO::Socket::SSL it should use the appropriate protocols and ciphers. Try updating that module. -Dan On Sun, Apr 5, 2015 at 9:33 AM, James Bearden wrote: > Hello, > > I am using the standard version of Mojolicious that comes with Ubuntu > 14.04 (4.63)

[Mojolicious] Breaking changes when upgrading to 6.0

2015-04-07 Thread Dan Book
Hello, I have put together a document on the wiki to record breaking changes in a readable manner for those looking to upgrade to the newest version of Mojolicious. Feel free to add to the page if I have missed anything important. https://github.com/kraih/mojo/wiki/Upgrading -Dan -- You rec

Re: [Mojolicious] How to determine a good value for graceful_timeout

2015-04-09 Thread Dan Book
You are correct that hypnotoad is not well designed for such long running requests. Browsers usually are not going to wait more than a few minutes for a request to complete. If you have background processes that you don't intend to return to the browser, perhaps something like Minion is a better so

Re: [Mojolicious] How to have a non-blocking 'any' route, which proxies multiple method requests?

2015-04-11 Thread Dan Book
Perhaps this way: my $tx = $ua->build_tx($method => ... normal get/post/etc args ...); $ua->start($tx => sub { ... }); On Fri, Apr 10, 2015 at 4:01 PM, Charlie Brady < charlieb-m...@budge.apana.org.au> wrote: > > https://github.com/kraih/mojo/wiki/Blocking-vs-non-blocking-101 > > I see I can do

Re: [Mojolicious] How to upload files on server using Mojo::UserAgent::Transactor?

2015-04-21 Thread Dan Book
This won't actually run the transaction, you need to start it with a UserAgent object: my $ua = Mojo::UserAgent; $tx = $ua->start($tx); Or just use the UserAgent post() method which will build and start the transaction for you. On Tue, Apr 21, 2015 at 2:41 AM, Pavel Serikov wrote: > Greetings,

Re: [Mojolicious] Running a blocking recurring call that exits & renders correctly

2015-04-21 Thread Dan Book
The finish event of the controller is not really appropriate here. It will not fire until the transaction is finished, which doesn't happen until you render a response. So once a success happens you want to call something that will render a response from there. You probably want to use the delay he

Re: [Mojolicious] Running a blocking recurring call that exits & renders correctly

2015-04-21 Thread Dan Book
Loop->delay(sub { say > 'BOOM!' });for my $i (1 .. 10) { > my $end = $delay->begin; > Mojo::IOLoop->timer($i => sub { > say 10 - $i; > $end->(); > });} > $delay->wait; > > > > > On Tuesday, 21 April 2015 21:41:48 UTC+

Re: [Mojolicious] Running a blocking recurring call that exits & renders correctly

2015-04-22 Thread Dan Book
')); > } > ); > > > > On Tuesday, 21 April 2015 22:17:35 UTC+1, hammondos wrote: >> >> Ok cool, thanks for pointing me in the right direction >> >> On Tuesday, 21 April 2015 22:10:36 UTC+1, Dan Book wrote: >>> >>> Sort of. You want

Re: [Mojolicious] Running a blocking recurring call that exits & renders correctly

2015-04-22 Thread Dan Book
Also, to stop the recurring timer, save the returned id (you can store it in the delay as well) and then remove it from the loop after a success (for example in the next step). On Wed, Apr 22, 2015 at 10:14 AM, Dan Book wrote: > You need to save the return value of $delay->begin, that ret

Re: [Mojolicious] Running a blocking recurring call that exits & renders correctly

2015-04-22 Thread Dan Book
$end->(); > } > } > ); > }, > sub { > my $delay = shift; > Mojo::IOLoop->remove($r_id); > $self->render(json => $delay->data('rows')); > } > ); > > > &g

Re: [Mojolicious] D'not work $self->req->body_params->param

2015-04-22 Thread Dan Book
Multi-parameter support has been removed from Mojo::Parameters (see https://github.com/kraih/mojo/wiki/Upgrading#multi-name-parameter-retrieval ) You can retrieve them individually: my $name = $self->req->param('name'); Or you can use the hash functionality with a hash slice: my ($name, $email, $

Re: [Mojolicious] [Security] Mojolicious 6.10 (user/group assignment)

2015-04-27 Thread Dan Book
The usability issue with the previous implementation was that the secondary groups of the specified user were not set regardless of the user or group set. Additionally, setting only a user would leave the groups that root has, which would be considered a serious security issue, as a lot of things o

Re: [Mojolicious] Config options for standalone M::L application running under prefork?

2015-04-27 Thread Dan Book
What do you mean by "in-line"? I'm not sure I follow the question. The prefork command takes command-line options: https://metacpan.org/pod/Mojolicious::Command::prefork Otherwise if you just need hypnotoad to stay in the foreground (and you don't need hot-deployment) you can use hypnotoad -f. O

Re: [Mojolicious] Upgrade from 4.22 to 6.11

2015-05-28 Thread Dan Book
See https://github.com/kraih/mojo/wiki/Upgrading On Thu, May 28, 2015 at 7:38 AM, Andrew wrote: > > Hurrah! > > I'm a n00b - but had this exact problem the other week, =). > > I popped onto the London Perl Mongers group, and managed to solve the > problem, with a bit of help from them. > [Under

Re: [Mojolicious] Is there any way to access all request parameters in Mojolicious::Lite ?

2015-05-28 Thread Dan Book
That Wiki page is outdated, you now access param names by: my $params = $self->req->params->names; (returns an arrayref) >From Mojolicious or Mojolicious::Lite works the same. On Thu, May 28, 2015 at 7:45 PM, Pavel Serikov wrote: > Hello everyone, > > Is it possible to get all POST params im Mo

Re: [Mojolicious] Is there any way to access all request parameters in Mojolicious::Lite ?

2015-05-28 Thread Dan Book
> > E.g. i'm sending such hash: > > my %hash = ( > city => "Rostov-on-Don", > model => {file => "stick.stl"}, > image => {file => "test.jpg"}, > promo => "TEST", > ); > > And *$self-

Re: [Mojolicious] Mojo::UserAgent doesn't work?

2015-06-27 Thread Dan Book
To follow redirects, set https://metacpan.org/pod/Mojo::UserAgent#max_redirects On Sat, Jun 27, 2015 at 6:15 PM, Stefan Adams wrote: > > On Sat, Jun 27, 2015 at 5:10 AM, Pavel Serikov > wrote: > >> Yeah, it's working :) >> >> But *warn Dumper >> ($ua->get('http://geocode-maps.yandex.ru/1.x/?geo

Re: [Mojolicious] what is Mojo::IOLoop->is_running waiting for?

2015-06-30 Thread Dan Book
is_running isn't what takes 20 seconds, Mojo::IOLoop->start blocks until the event loop is stopped/has nothing more to do. So it waits for your requests to complete. Delays are an easier option to synchronize non-blocking requests, see https://metacpan.org/pod/Mojolicious::Guides::Cookbook#Concurre

Re: [Mojolicious] Mojo::UserAgent log and timeouts

2015-07-15 Thread Dan Book
Your URL parameters are not being url encoded as required. Use a Mojo::URL instead: my $url = Mojo::URL->new('http://klishe.ru/wp-json/posts')->query('filter[post_status]' => 'publish', ...); On Wed, Jul 15, 2015 at 7:35 AM, Pavel Serikov wrote: > Hi guys, > > Here is a description of new pro

Re: [Mojolicious] Mojo::mysql parsing uri

2015-07-16 Thread Dan Book
I think setting them with the methods is a better idea in general. On Thu, Jul 16, 2015 at 11:54 AM, Richard Sugg wrote: > I ran into an issue where the database user has a # character, and > Mojo::mysql doesn't parse the uri like I expected. If I set the dsn, > username, and password separately

Re: [Mojolicious] Automatically extend user session expiration when active websocket connection only

2015-07-20 Thread Dan Book
You could reset the session cookie from the javascript. However the simplest way is probably to have the javascript make an AJAX request separate from the websocket, to renew the session. On Mon, Jul 20, 2015 at 11:15 AM, Александр Грошев < aleksander.grosc...@gmail.com> wrote: > How I can extend

Re: [Mojolicious] Interactive Perl debugging with hypnotoad and/or morbo

2015-08-14 Thread Dan Book
They are just regular perl scripts, you can run for example: perl -d $(which morbo) ... other options ... On Fri, Aug 14, 2015 at 12:43 PM, wrote: > Is it possible to invoke the interactive Perl debugger with hypnotoad or > morbo like you can with Apache? Any pointers? > http://mojolicio.us/per

Re: [Mojolicious] PSGI and utf8 encoding

2015-08-29 Thread Dan Book
UTF-8 encoded files should not have a BOM, that is normal. I don't know about mod_perl and plack's handling of encoding, but could you use a proxy to Hypnotoad instead of going through mod_perl and PSGI? It would be a cleaner solution. On Sat, Aug 29, 2015 at 5:20 PM, DryDuck wrote: > Hi > > I h

Re: [Mojolicious] Mojolicious::Lite doesn't serve static files from '/public' directory automatically

2015-10-21 Thread Dan Book
Works OK here: $ mkdir public $ echo bar > public/foo $ perl -MMojolicious::Lite -E'get "/foo"; app->start' get /foo bar On Wed, Oct 21, 2015 at 6:46 PM, Pavel Serikov wrote: > You suggest generation of full app, I need a lite app. > > Did generation this way: > > $ mojo generate lite_app > >

Re: [Mojolicious] How to test CRUD app using Test::Mojo ?

2015-11-18 Thread Dan Book
After each *_ok method call you can access the most recent response as $t->tx->res (if $t is your Test::Mojo object) On Wed, Nov 18, 2015 at 4:41 PM, Pavel Serikov wrote: > How to capture output of one route and then use it in test for another > route? > > E.g. this algorithm of test: > > 1) got

Re: [Mojolicious] can access url params because of a '#' in url

2015-11-28 Thread Dan Book
That is the fragment, which you can access as $c->req->url->fragment. If you want to parse it like query parameters you could do something like my $params = Mojo::Parameters->new($c->req->url->fragment); On Sat, Nov 28, 2015 at 4:08 PM, Jason D wrote: > I'm trying to connect to a site using this

Re: [Mojolicious] can access url params because of a '#' in url

2015-11-28 Thread Dan Book
But also this may not work at all because the fragment is normally not passed to the backend, and is only used for javascript. On Sat, Nov 28, 2015 at 4:13 PM, Dan Book wrote: > That is the fragment, which you can access as $c->req->url->fragment. If > you want to parse it like q

Re: [Mojolicious] "Can't connect: Servname not supported for ai_socktype" I am getting this error while passing Mojo::Parameters object into Mojo::UserAgent 'get' method.

2015-12-10 Thread Dan Book
You should be passing a URL, not the parameters. The parameters can be attached to the URL with $url->query in Mojo::URL. On Thu, Dec 10, 2015 at 7:03 AM, wrote: > > I am getting this error > > [ > { > "msg" => { > "message" => "Can't connect: Servname not supported for ai_socktype"

Re: [Mojolicious] Mojo in default mode not work.

2016-01-11 Thread Dan Book
>From what I can tell, the generated app is supposed to work when run from the same directory. To make it installable you need FindBin as you have noticed, this is mentioned in the Cookbook: https://metacpan.org/pod/Mojolicious::Guides::Cookbook#Making-your-application-installable On Mon, Jan 11,

Re: [Mojolicious] non blocking restful api to sockets

2016-01-19 Thread Dan Book
Using a non-blocking API would be ideal but the other option is to run the blocking call in a forked process using something like https://metacpan.org/pod/Mojo::IOLoop::ForkCall . Either way the delay helper is helpful for this: https://metacpan.org/pod/Mojolicious::Guides::Cookbook#Synchronizing-e

Re: [Mojolicious] How to use Mojo::IOLoop timer at helpers?

2016-01-22 Thread Dan Book
When you moved the helper, you moved your render outside of the callback, so it's called immediately rather than when the actions are done. Also, you cannot return values from the delay back to where the helper was called, because the helper returns immediately, the delay happens later. You can mak

Re: [Mojolicious] How to use Mojo::IOLoop timer at helpers?

2016-01-22 Thread Dan Book
Small note, in a Mojolicious::Lite app you are not operating in the controller class, so the controller would not be referred to as $self, by matter of convention (usually $c). On Fri, Jan 22, 2016 at 9:29 AM, Dan Book wrote: > When you moved the helper, you moved your render outside of

Re: [Mojolicious] Suggest forking Mojo plugin

2016-05-21 Thread Dan Book
ForkCall runs a perl function, and you get the return value back. ReadWriteFork runs a perl function or external binary, and you can write to STDIN and get STDOUT/STDERR events. Thus they are useful for slightly different use cases, choose the one that is simplest for your needs. On Sat, May 21, 2

Re: [Mojolicious] How to know that a POST is truly successful

2016-06-01 Thread Dan Book
The test is identifying that the post successfully occurred and the second test verifies it got a 200 OK response. If there is some other way you are indicating failure, you'll need to check that as well. You can access the response object after the post_ok call via $t->tx->res. On Wed, Jun 1, 201

Re: [Mojolicious] Minion Worker & DBI

2016-06-16 Thread Dan Book
Your $dbh is only returned from the helper and not stored anywhere, so it disconnects as soon as it goes out of scope. Try declaring `my $dbh` in the global scope or using the `state` feature (roughly equivalent). A Mojo::SQLite object would be preferable to store over the dbh itself. See an exampl

Re: [Mojolicious] Re: Minion Worker & DBI

2016-06-16 Thread Dan Book
This would be handled by storing a Mojo::SQLite object instead of the dbh, or a DBIx::Connector object as you mentioned before. On Thu, Jun 16, 2016 at 11:09 AM, Joel Berger wrote: > Minion tasks are performed in forks to protect the integrity of the worker > process. Once the task is forked (or

Re: [Mojolicious] Mojolicious as a non-HTTP server

2016-07-04 Thread Dan Book
Sure, Mojo::IOLoop::Server can be used for any TCP based protocol. You'll have to implement a lot yourself of course. On Mon, Jul 4, 2016 at 8:45 PM, Brian Shaw wrote: > Is is possible to use Mojolicious for protocols other than HTTP(S)? I'd > like to create a full end to end mail server, The

Re: [Mojolicious] Re: Mojolicious as a non-HTTP server

2016-07-09 Thread Dan Book
To do this you need to start the service as root (or more generically, a user with the appropriate privileges) to bind to the port. If it has workers they can run under an unprivileged user after binding and being forked, as https://metacpan.org/pod/Mojolicious::Plugin::SetUserGroup helps you do fo

Re: [Mojolicious] Re: Mojolicious as a non-HTTP server

2016-07-10 Thread Dan Book
SetUserGroup is a plugin for a mojolicious application running a prefork or hypnotoad server, it sets the user/group on the next tick of the ioloop. On Sun, Jul 10, 2016 at 3:27 PM, Brian Shaw wrote: > It took me a bit to get it to startup under root, I had been trying > initially to use sudo bu

Re: [Mojolicious] Can't locate object method "" via package "Mojo::UserAgent::Transactor"

2016-07-15 Thread Dan Book
There is no 'body' generator, only 'form' or 'json'. https://metacpan.org/pod/Mojo::UserAgent::Transactor#GENERATORS Since you said $newjson is a hashref, you probably wanted the json generator. On Fri, Jul 15, 2016 at 12:54 PM, Todd wrote: > Just upgraded Mojolicious to latest via cpanm > Mojo

Re: [Mojolicious] Can't locate object method "" via package "Mojo::UserAgent::Transactor"

2016-07-15 Thread Dan Book
d unfortunate, > because I'm using that to proxy a request to an elasticsearch server and > the js code (searchkit.js) does exactly that and switching to "form"or > "json" confuses the ES server. > > Back to the drawing board... > > On Friday, July 15, 2016 at

Re: [Mojolicious] Re: Feature request - Mojo::DOM, have a line number for each element?

2016-07-22 Thread Dan Book
You could try something like this... $dom->find('*')->map(sub { state $i = 0; $_->{_myapp_counter} = $i++ }); It would add an attribute to every tag but that may or may not be a problem for your application. Alternatively you could go through $dom->find('*') in order and test $_->tag or other me

Re: [Mojolicious] Re: Deployment: launch hypnotoad on boot

2016-08-04 Thread Dan Book
Systemd has an option for this, see Restart= here https://www.freedesktop.org/software/systemd/man/systemd.service.html On Thu, Aug 4, 2016 at 7:42 PM, Stefan Adams wrote: > I've noticed that sometimes my hypnotoad just dies, no warning. Is there > a supported directive for systemd to allow sys

Re: [Mojolicious] Re: Deployment: launch hypnotoad on boot

2016-08-04 Thread Dan Book
g the team wants to implement in core. On Thu, Aug 4, 2016 at 8:51 PM, Stefan Adams wrote: > > On Thu, Aug 4, 2016 at 7:41 PM, Dan Book wrote: > >> Systemd has an option for this, see Restart= here >> https://www.freedesktop.org/software/systemd/man/systemd.service.html >>

Re: [Mojolicious] SSL when behind a proxy

2016-08-10 Thread Dan Book
Unfortunately the presence of SSL is only really indicated by the X-Forwarded-Proto header which is set to https. This tells Mojo::Message::Request that the request was proxied from https (if the hypnotoad proxy setting or MOJO_REVERSE_PROXY is enabled), but doesn't say anything about the ws protoc

Re: [Mojolicious] SSL when behind a proxy

2016-08-10 Thread Dan Book
nd the proxy flag solves the problem > for http, just not ws. Thanks! Theoretically, is that something that Mojo > could address? If it can do it for http, can it theoretically do it for ws? > > On Aug 10, 2016 11:22 AM, "Dan Book" wrote: > >> Unfortunately the presenc

Re: [Mojolicious] What is the hash key 'cb' in: $r->to->(cb=>sub{...})

2016-08-12 Thread Dan Book
https://metacpan.org/pod/Mojolicious::Guides::Routing#Route-to-callback On Fri, Aug 12, 2016 at 3:08 PM, Randall Sindlinger wrote: > Hi, > > I'm working on code that I inherited, and I've hit something that is > opaque to me. > > What does this code snip in setup() intend to do, specifically reg

Re: [Mojolicious] Handling different types of JSON requests

2016-09-24 Thread Dan Book
JSON gives you the option to send more straightforward and possibly nested hashes and arrays. JSON body is a relatively common method of making API requests so there's no reason to avoid it really. The only benefit of multipart/form-data is that it's sent natively by HTML forms so doesn't require j

Re: [Mojolicious] Re: Efficient way to work with SQLite in Mojolicious::Lite

2016-10-05 Thread Dan Book
The https://metacpan.org/pod/Mojo::SQLite and https://metacpan.org/pod/Mojo::Pg frameworks are built on DBI and are the usual way to connect to these databases from Mojolicious. Those distributions also come with a blog example in https://metacpan.org/source/DBOOK/Mojo-SQLite-1.000/examples/blog an

Re: [Mojolicious] Namespace Question

2016-11-22 Thread Dan Book
If you want to put them on CPAN, you will at least need a dummy (empty) module with a version number to make them installable. Once you decide on that module name (something that Mojo core is not likely to want in the future), you can put the templates inside that namespace. Another problem however

Re: [Mojolicious] Problem with utf8 chars in test messages (compatibility between Test::Mojo and Test::More::UTF8 modules)

2016-12-12 Thread Dan Book
This module changes the I/O layers of STDOUT and STDERR to encode to UTF-8, so it will double encode when using test libraries like Test::Mojo. You should not use them together. On Mon, Dec 12, 2016 at 9:18 AM, Daniel Mantovani wrote: > When testing Mojo apps, many times you need to use both Tes

Re: [Mojolicious] Re: getting the names/values of all parameters

2017-01-23 Thread Dan Book
The wiki page https://github.com/kraih/mojo/wiki/Upgrading keeps a list of breaking API changes since 5.0. On Mon, Jan 23, 2017 at 4:29 PM, Joseph Landman < land...@scalableinformatics.com> wrote: > Answering my own question for posterity. The following code works as a > replacement: > > helper

Re: [Mojolicious] Supplying context to UserAgent completion callback

2017-02-28 Thread Dan Book
By including $data in the callback, you are closing over it, thus preserving its value. However if $data is a reference, the data it references could change. If you copy the specific context information you need into lexically-scoped scalars beforehand, and close over those copies instead, you can

Re: [Mojolicious] Re: Supplying context to UserAgent completion callback

2017-02-28 Thread Dan Book
No, that would be a blocking request. The non-blocking format creates and sends the request, and stores the passed coderef to be called once the response is received. Additionally, making a shallow copy of the reference doesn't achieve anything, I meant (if it is a reference) you would need to copy

Re: [Mojolicious] How do I set up multiple concurrent HTTP requests and wait for all to finish

2017-03-27 Thread Dan Book
When running non-blocking requests, the user agent object must be stored somewhere in a larger scope so that it is not destroyed before the request completes. See also https://metacpan.org/pod/Mojolicious::Guides::FAQ#What-does-%22Premature-connection-close%22-mean ? On Tue, Mar 28, 2017 at 1:20 A

Re: [Mojolicious] How do I set up multiple concurrent HTTP requests and wait for all to finish

2017-03-28 Thread Dan Book
Yes, as documented at https://metacpan.org/pod/Mojo::IOLoop::Delay#wait, the ->wait method does nothing if the event loop is currently running. You do not want it to do anything in this case, it is a bad idea to run the event loop during its own event callback. So it is by design that any non-block

Re: [Mojolicious] retrieving post params to_hash()

2017-04-04 Thread Dan Book
I don't remember where it's documented, but you can use $c->req->body_params->to_hash. Instead of ->body_params you can use ->query_params for URL parameters, or ->params for both combined; each of these gives you a Mojo::Parameters object with a to_hash method. On Tue, Apr 4, 2017 at 7:46 PM, iaw

Re: [Mojolicious] $c->req->query_params('x') value only?

2017-04-05 Thread Dan Book
Use the param method of Mojo::Parameters (returned by query_params) as shown here: https://metacpan.org/pod/Mojolicious::Controller#param On Wed, Apr 5, 2017 at 6:00 PM, iaw4 wrote: > > does M have a builtin shortcut function for the most frequent use of > params, > > my $x=$c->req->query_params

Re: [Mojolicious] Inheriting "live" attribute values of parent class with Mojo::Base

2017-04-06 Thread Dan Book
There is not really any automatic way to do this in Mojo::Base, it's a very simple module. But you could do something like this. has 'token' => sub { my $self = shift; exists $self->{Tiger} ? $self->Tiger->token : $self->token }; This would only affect the default of course, and would not update

Re: [Mojolicious] upload file contents?

2017-04-07 Thread Dan Book
It says that the uploads are returned as Mojo::Upload objects. These objects have an 'asset' attribute which returns the Mojo::Asset::File or Mojo::Asset::Memory, both of which have a 'slurp' method you can use to read the contents into memory, and other methods. It's usually a bad idea to access t

Re: [Mojolicious] Your secret passphrase needs to be changed

2017-04-17 Thread Dan Book
Any default would be insecure in some way. It must be set by the user to some secret to avoid being guessable. On Mon, Apr 17, 2017 at 2:21 PM, iaw4 wrote: > > suggestion? > > would it make sense to set the passphrase to "moniker" encoded with the > machine-id as the default, rather than stating

Re: [Mojolicious] Your secret passphrase needs to be changed

2017-04-17 Thread Dan Book
-welch.info/ > Exec Editor, Critical Finance Review, http://www.critical-finance- > review.org/ > Editor and Publisher, FAMe, http://www.fame-jagazine.com/ > > On Mon, Apr 17, 2017 at 1:31 PM, Dan Book wrote: > >> Any default would be insecure in some way. It must be set b

Re: [Mojolicious] Your secret passphrase needs to be changed

2017-04-17 Thread Dan Book
application from multiple servers even. So it is up to the user how to set secrets. On Mon, Apr 17, 2017 at 3:07 PM, iaw4 wrote: > > > On Monday, April 17, 2017 at 1:46:22 PM UTC-5, Dan Book wrote: >> >> You also need to make sure the secret does not change, as that will >

Re: [Mojolicious] Hypnotoad and gone SQL

2017-05-04 Thread Dan Book
More specifically, you should not store a DBI handle in your app or use it across forks. You should always store a DBIx::Connector or Mojo::Pg or similar connection pool object instead, and then retrieve a connection from it in the smallest scope needed. On Thu, May 4, 2017 at 7:10 AM, Justin Hawk

Re: [Mojolicious] Mojo::Pg example Blog, but non-blocking

2017-05-05 Thread Dan Book
It cannot return to the same method, if that's what you're asking. Any action you wish to take using the results must be within that callback, or called by that callback; so perhaps pass a callback to your model for it to call from its callback, if that makes sense. https://metacpan.org/pod/Mojolic

Re: [Mojolicious] zip file download link

2017-05-14 Thread Dan Book
See this section: https://metacpan.org/pod/Mojolicious::Guides::Rendering#Serving-static-files On Sun, May 14, 2017 at 4:02 AM, wrote: > Hi, > > I have a zipped file in a directory (not 'public') and I want to do a link > with which the user can download the file. > > Can please someone explain

Re: [Mojolicious] Hypnotoad and namespaces

2017-05-30 Thread Dan Book
This is a bad idea, if you want to call external functions then they should be in a common module that can be used from where you call them. On Tue, May 30, 2017 at 7:29 AM, Yuriy Zhilovets wrote: > Hi everybody! > > How to handle different namespaces under Hypnotoad ? > > I have this small serv

Re: [Mojolicious] Will "req->uploads(), detour()" work in future releases?

2017-06-13 Thread Dan Book
They are not deprecated at this time, but we can't see the future. On Tue, Jun 13, 2017 at 2:23 PM, Ivan Babiychuk wrote: > *Hello.* > > *Problem:* > My colleagues say me not to use these functions: > $self->req->uploads('file'); > $r->detour(); > > *Question:* > Will these two functions work in

Re: [Mojolicious] Will "req->uploads(), detour()" work in future releases?

2017-06-13 Thread Dan Book
However, the ->uploads method does not take an argument, and the ->detour method does. On Tue, Jun 13, 2017 at 2:25 PM, Dan Book wrote: > They are not deprecated at this time, but we can't see the future. > > On Tue, Jun 13, 2017 at 2:23 PM, Ivan Babiychuk > wrote: >

Re: [Mojolicious] Mojo::Pg and bytea don't seem to work

2017-06-16 Thread Dan Book
The recently added bind type support should help, see the last example here: https://metacpan.org/pod/Mojo::Pg::Database#query On Fri, Jun 16, 2017 at 4:24 PM, Alejandro Imass wrote: > On Fri, Jun 16, 2017 at 4:00 PM, Alejandro Imass > wrote: > > Hi, > > > > Bytea values are coming back as empt

Re: [Mojolicious] Shutting down Morbo

2017-06-25 Thread Dan Book
Hypnotoad and the prefork server it's based on launch 4 workers by default. If you don't need the concurrency then you can simply use the plain 'daemon' command. It will not watch for filesystem changes but it will be much less complex to run than morbo. Run like: `./myapp.pl daemon -l 'http://*:80

Re: [Mojolicious] Re: Mojo Sessions and IIS 8.5

2017-07-18 Thread Dan Book
Session cookies are only created if you access the session via the "session" method in Mojolicious::Controller. It's important that you've set your app secrets if you do use them. On Tue, Jul 18, 2017 at 7:16 PM, Brandon Woodson wrote: > So to further help anyone interested in helping me solve t

Re: [Mojolicious] Mojo under docker

2017-08-02 Thread Dan Book
I'm not sure what you mean. The command line *is* hypnotoad, and it has an -f option for foreground: https://metacpan.org/pod/distribution/Mojolicious/script/hypnotoad (all it really does is set the HYPNOTOAD_FOREGROUND env var) Note that when running hypnotoad in foreground mode it cannot do hot

Re: [Mojolicious] log4perl MDC and non-blocking backend webservices

2017-08-31 Thread Dan Book
A hook is not a suitable place to put request-specific data, because of the async pattern you discovered. Requests may partially dispatch and then another request may be handled by the event loop while waiting for another part of the request. Some of the request may be initiated from outside the di

Re: [Mojolicious] Is IO::Socket::IP absolutely necessary?

2017-09-11 Thread Dan Book
It is deeply embedded in the logic of Mojo servers and clients, but you may be able to replace it with IO::Socket::INET adjusting calls as needed (so you'd need to maintain a fork with these changes essentially), if you don't need ipv6. On Mon, Sep 11, 2017 at 4:16 PM, Alejandro Imass wrote: > H

Re: [Mojolicious] Is IO::Socket::IP absolutely necessary?

2017-09-11 Thread Dan Book
However, even the latest version of IO::Socket::IP only requires Test::More version 0.88, which is core on any version of perl supported by Mojolicious. On Mon, Sep 11, 2017 at 5:52 PM, Dan Book wrote: > It is deeply embedded in the logic of Mojo servers and clients, but you > may be a

Re: [Mojolicious] jstree and mojolicious

2017-09-13 Thread Dan Book
Static files are by default served from the "public" directory, make sure that is where you put your file. https://metacpan.org/pod/Mojolicious::Guides::Tutorial#Static-files On Wed, Sep 13, 2017 at 11:16 AM, Luis Diaz wrote: > Hi! > > I've been asked at work to create a website that runs under

Re: [Mojolicious] Private sub _monkey_patch removed in Mojo::Base 7.55, breaks Mojo::Redis2

2017-11-10 Thread Dan Book
There is a PR open to fix this: https://github.com/jhthorsen/mojo-redis2/pull/26 I did a search and it seems nobody else is abusing this internal function thankfully. -Dan On Fri, Nov 10, 2017 at 10:54 AM, Scott wrote: > Just noticed the private sub _monkey_patch was removed in Mojolicious > 7

Re: [Mojolicious] Mojo::Promise swallows exceptions in rejection handlers

2017-11-15 Thread Dan Book
The problem is that no exceptions in promise handlers are fatal, they occur in the event loop. The only way the exception could be propagated is if the call to ->wait checked for a failure and rethrew it as an exception afterward (this is how ->get works in Future). Also note that $p is not the las

Re: [Mojolicious] Re: Mojo::IOLoop->recurring start several job at the same time

2017-11-21 Thread Dan Book
If you add a recurring timer in startup it will execute in each worker process that is forked. You might consider having a separate process (possibly with a command for your application to spawn it) that just does this recurring work. -Dan On Tue, Nov 21, 2017 at 9:40 PM, Nancy Li wrote: > OK.

Re: [Mojolicious] Documentation "bug"

2017-11-22 Thread Dan Book
When the auto_escape option is set on Mojo::Template, it reverses this behavior; auto_escape is set by default for the EPRenderer template handler, which the rendering guide is referring to. I agree it is a bit confusing but I'm not sure the best way to clarify things. On Wed, Nov 22, 2017 at 8:29

Re: [Mojolicious] re-direct to calling page

2017-11-22 Thread Dan Book
"flash" puts the data into the session, not the parameters. If it's in the same request just use the stash to pass the data, if it's in a different request then you need to retrieve it from the session - https://metacpan.org/pod/Mojolicious::Controller#session . Be careful using flash since it is b

Re: [Mojolicious] hypnotoad systemd start problem

2017-11-23 Thread Dan Book
There is probably more relevant information higher in the log; the status command is only showing you the end of the log. Try running: journalctl -u mojo_test.service -Dan On Thu, Nov 23, 2017 at 4:24 AM, wrote: > Dear sir; > I meet a problem when systemd start hypnotoad, detail follow: >

Re: [Mojolicious] Re: hypnotoad systemd start problem

2017-11-23 Thread Dan Book
I would not recommend running hypnotoad as a Type=simple service with -f. This will not allow you to use hot-restarts via systemctl reload. -Dan On Thu, Nov 23, 2017 at 10:13 AM, wrote: > Hi David, > > I'm no expert with systemd, but this is my mojo.service file which runs > the application in

Re: [Mojolicious] Re: hypnotoad systemd start problem

2017-11-23 Thread Dan Book
directives. You can check if those are > supported in your system with > > $ man systemd.directives > > If you have those, you will probably not need the ExecStartPre directives > above, because the only thing these do is to create those directories. > > Hope it helps. > BR,

Re: [Mojolicious] Re: hypnotoad systemd start problem

2017-11-23 Thread Dan Book
t; forking mode. -Dan On Thu, Nov 23, 2017 at 11:36 AM, Boyd Duffee wrote: > On 23/11/17 16:14, Dan Book wrote: > > I would not recommend running hypnotoad as a Type=simple service with -f. > > This will not allow you to use hot-restarts via systemctl reload. > > Naively, I

Re: [Mojolicious] Re: hypnotoad systemd start problem

2017-11-24 Thread Dan Book
he log file). If you restart >> instead of course it will kill the process and then start again, and you >> can check that also in the log file. >> >> One last thing, if you happen to have a recent version of systemd or you >> are allowed to install that (not my case unfortu

  1   2   3   >