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

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 gri...@gmail.com wrote: You are doing a synchronous get() so the entire page

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,

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 gri...@gmail.com wrote: I submitted a PR for this issue. https://github.com/kraih/mojo/pull/758 Thanks! On Wed

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 najbeza...@gmail.com 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

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 s...@alexbyk.com wrote: by storing the callbacks outside of the delay

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 set in

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 dma...@gmail.com wrote: In Mojo::IOLoop either $delay-begin or $delay-end

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

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 gri...@gmail.com wrote: You need to save the return value of $delay-begin

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

2015-04-22 Thread Dan Book
; } } ); }, sub { my $delay = shift; $self-render(json = $delay-data('rows')); } ); 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

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

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

2015-04-22 Thread Dan Book
; Mojo::IOLoop-remove($r_id); $self-render(json = $delay-data('rows')); } ); On Wednesday, 22 April 2015 15:15:22 UTC+1, Dan Book wrote: 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

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

2015-04-21 Thread Dan Book
!' });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+1, Dan Book wrote: The finish event of the controller is not really appropriate here. It will not fire until

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. On

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

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 this to

[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

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 gri...@gmail.com wrote: $app-log-handle(\*STDOUT); (untested) On Fri, Apr 3, 2015 at 6:04 PM, Nathan Waddell arafean...@gmail.com wrote: After some research, it looks like

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 pavel.p.seri...@gmail.com wrote: Hello everyone, Is it possible to get

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

2015-05-28 Thread Dan Book
sending such hash: my %hash = ( city = Rostov-on-Don, model = {file = stick.stl}, image = {file = test.jpg}, promo = TEST, ); And *$self-req-params-names* will show only *[city, promo]*. пятница, 29 мая 2015 г., 3:58:12 UTC+4 пользователь Dan Book написал: That Wiki page

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 mojoliciousgr...@unitedgames.co.uk 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

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, gmenyh...@academicbenchmarks.com wrote: Is it possible to invoke the interactive Perl debugger with hypnotoad or morbo like you can with Apache? Any

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 richards...@gmail.com 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

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 pavel.p.seri...@gmail.com wrote: Hi guys, Here is a

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

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

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,

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

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.

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:

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

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

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

Re: [Mojolicious] SSL when behind a proxy

2016-08-10 Thread Dan Book
is unique to ws, and 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" <gri...@gmail.com> wrote: >

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

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

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

2016-07-15 Thread Dan Book
d in 6.38, and 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,

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

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 >

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

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

2016-08-04 Thread Dan Book
the team wants to implement in core. On Thu, Aug 4, 2016 at 8:51 PM, Stefan Adams <s1037...@gmail.com> wrote: > > On Thu, Aug 4, 2016 at 7:41 PM, Dan Book <gri...@gmail.com> wrote: > >> Systemd has an option for this, see Restart= here >> https://www.fre

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

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

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

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

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

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

2017-03-28 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

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

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,

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] $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

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

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] 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

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

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

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 <gri...@gmail.com> 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

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.

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

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

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

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 <gri...@gmail.com> wrote: > It is deeply embedded in the logic of Mojo servers and clients

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

Re: [Mojolicious] Re: hypnotoad systemd start problem

2017-11-23 Thread Dan Book
tory= 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. &

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

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

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

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

Re: [Mojolicious] Re: hypnotoad systemd start problem

2017-12-04 Thread Dan Book
stance in RHEL 7.x /var/run (or /run, it is a symlink to it > actually) by design will delete all subdirectories during reboot. > > BR, > Daniel > El viernes, 24 de noviembre de 2017, 1:14:19 (UTC-3), Dan Book escribió: >> >> The best practice IMO in regards to permissions

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

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

Re: [Mojolicious] Minion args

2018-04-26 Thread Dan Book
What backend are you using? Note that the args have to be decoded from JSON whenever accessed and when starting the job, which for pure-perl parsers can be very slow. Perhaps try loading Mojo::JSON::MaybeXS in your app. Otherwise I'd suggest storing it in a separate table in a way that doesn't

Re: [Mojolicious] Minion::Backend::Redis

2017-12-31 Thread Dan Book
Please, I welcome any attempts at making it work! My development of the Redis backend is stalled because I have been unable to find a way to make the dequeue process efficient enough. I have copied the minion benchmark script with the modification to use Redis here:

Re: [Mojolicious] decode_json and utf8 data from Mojo::mysql error

2018-01-14 Thread Dan Book
Hello, Since Mojo::mysql sets mysql_enable_utf8, you should not use encode_json and decode_json since the transport will already be handling UTF-8 encoding. You should instead use to_json and from_json (as Mojo::Pg and Mojo::SQLite do, since their transports also handle UTF-8 encoding). If you use

Re: [Mojolicious] SQL::Abstract::Pg

2018-02-02 Thread Dan Book
A bulk insert would look more like: my $rows = $pg->db->select(...)->arrays; $pg->db->query('insert into b (first, last, birthday, age, phone) values ' . join(',', ('(?,?,?,?,?)')x@$results), @$results); Or with postgres you could probably use arrays rather than constructing the query with join

Re: [Mojolicious] Mojo::Base get all attributes names

2018-02-05 Thread Dan Book
Introspection capabilities are a feature of Moose. On Mon, Feb 5, 2018 at 5:14 AM, Konstantin Cherednichenko < dshadowukra...@gmail.com> wrote: > Hello! > > Is there any easy way to get all attributes names? > > I tried to get it via ISA but I also got methods names... I just want to > get

Re: [Mojolicious] Mojo::Base get all attributes names

2018-02-06 Thread Dan Book
г., 21:13:19 UTC+3 пользователь Charlie Brady > написал: >> >> >> On Mon, 5 Feb 2018, Dan Book wrote: >> >> > Introspection capabilities are a feature of Moose. >> >> Moose, however, adds many, many more dependencies than Mojo::Base... >> >> &

Re: [Mojolicious] strange behaviour with prefork

2018-02-23 Thread Dan Book
r JWT sign/encrypt stuff, for security they are refreshed every n hours > by a housekeeper script... and I don't want to get the secrets from Redis > cache every time I use them. > > Any hints will be much appreciated. > > Rgds, > Michael > > > On Friday,

Re: [Mojolicious] strange behaviour with prefork

2018-02-23 Thread Dan Book
The startup method is run in the manager process before any forking. If you want something to occur in each worker, you can run it in a Mojo::IOLoop->next_tick callback. However note that this will also run in each worker that is started later, to replace workers that reach their max_accepts or

Re: [Mojolicious] Re: Grouping Mojo::Collection of hashes

2018-08-03 Thread Dan Book
An alternative using Mojo::Collection::Role::UtilsBy: use Mojo::Collection 'c'; use Mojo::Util 'dumper'; my $start = c({name => 'name1', total => 2}, {name => 'name1', total => 3}, {name => 'name2', total => 7})->with_roles('+UtilsBy'); my $end = c(map { $_->reduce(sub { $a->{total} +=

Re: [Mojolicious] Re: Mojo::UserAgent and large files

2018-08-17 Thread Dan Book
Though the other problem in this case is that you are not keeping the Mojo::UserAgent object alive because it's scoped inside the action: https://mojolicious.org/perldoc/Mojolicious/Guides/FAQ#What-does-Premature-connection-close-mean On Fri, Aug 17, 2018 at 1:39 PM Dan Book wrote: > You do

Re: [Mojolicious] Re: Mojo::UserAgent and large files

2018-08-17 Thread Dan Book
You don't need to keep a reference to the controller but to the transaction. See https://mojolicious.org/perldoc/Mojolicious/Guides/FAQ#What-does-Transaction-already-destroyed-mean On Fri, Aug 17, 2018 at 1:22 PM Heiko Jansen wrote: > Hmm, there's no access to the controller ($c) and no

Re: [Mojolicious] Re: Using Mojo::DOM to update

2018-08-24 Thread Dan Book
Absolutely, that's what tap is for. -Dan On Fri, Aug 24, 2018 at 9:48 PM Stefan Adams wrote: > Sorry, I knew I should know better. > > I was using the ojo#x example and > I just added on to it: > > $ perl -Mojo -E 'say

Re: [Mojolicious] Mojo::Log seems to encode twice a message with multibyte characters

2018-01-18 Thread Dan Book
You cannot determine in perl whether a string is intended to be bytes or characters. is_utf8 checks how the string is internally stored, which is irrelevant. You must always pass characters to Mojo::Log. On Thu, Jan 18, 2018 at 7:14 PM, Geunyoung Park wrote: > Hello, > > I'm

Re: [Mojolicious] How to get array from params?

2018-03-09 Thread Dan Book
Mojo does not do parsing of "array" parameters, that's a specific PHP sort of thing. You either need to use the actual names that are posted (you can parse the list of parameter names from $c->tx->req->params->names) or use a JSON post so that you have real data structures. On Fri, Mar 9, 2018 at

Re: [Mojolicious] Highlight Current Page in Navigation

2018-03-13 Thread Dan Book
I usually put directly in the template: <% if (current_route 'foo') { %>...<% } %> This works as long as you make sure your routes have useful names, you can apply names manually at the end of a route definition. https://metacpan.org/pod/Mojolicious::Guides::Routing#Named-routes -Dan On Tue,

Re: [Mojolicious] Re: can't get Promise construct to wait

2018-03-14 Thread Dan Book
->wait will not block if the event loop is currently running, like if you are setting this up in an event loop callback like a request handler. In order to cause promises to block while running the main event loop, you need to run the promises in a separate event loop. my $promise =

Re: [Mojolicious] Last try

2018-04-12 Thread Dan Book
The wait method will only block until the promise completes if the event loop is not currently running. To be portable, anything that relies on the results of the promise should only occur in further promise callbacks. And note also that you can resolve promises using values by returning them from

Re: [Mojolicious] rendering images located outside of public directory

2018-04-05 Thread Dan Book
Sorry, your issue is in routing: your showimg route is POST-only, but browsers will always use GET to request an image. On Thu, Apr 5, 2018 at 2:32 PM, Dan Book <gri...@gmail.com> wrote: > Try this: https://metacpan.org/pod/Mojolicious::Guides:: > Rendering#Custom-responses >

Re: [Mojolicious] rendering images located outside of public directory

2018-04-05 Thread Dan Book
Try this: https://metacpan.org/pod/Mojolicious::Guides::Rendering#Custom-responses On Thu, Apr 5, 2018 at 2:26 PM, Caveman Pl wrote: > Hi group, > > I have no idea how to export images located outside of public directory. > Forgive me to disturbing groups such a lame

Re: [Mojolicious] Accessing SQLite database from two different modules

2018-04-24 Thread Dan Book
Even with write-ahead logging, committing a transaction or running a data update outside a transaction should be immediately reflected in any other readers -- as long as they run the read query after the commit/update has completed. The ability to read while another connection is writing (and see

Re: [Mojolicious] Re: Structured helpers

2018-03-29 Thread Dan Book
The template is rendered within its own namespace unique to that compilation, so you cannot inject subs directly. You can however pass coderefs in the stash and then do $foobar->() in the template. But namespacing the helpers seems reasonable to me. -Dan On Thu, Mar 29, 2018 at 9:47 AM, Leo

Re: [Mojolicious] Mojolicious::Lite how to refresh table only

2018-03-21 Thread Dan Book
Refreshing the page and refreshing the table are two different things. The latter you would need to do in javascript, ideally with a framework like vue or react that can handle the ugly details. If you refresh the page, you only need to have the route provide the subset of the data instead of the

Re: [Mojolicious] Getting File Extension of Mojo::Upload Object

2018-10-12 Thread Dan Book
The original filename is available from $upload->filename, you can parse the extension from that. Note that this filename can be literally anything the browser sends, some may even send a full Windows file path for example, or it's possible a client will not send a filename. -Dan On Fri, Oct 12,

Re: [Mojolicious] Mojolicious-8.04

2018-10-28 Thread Dan Book
This error comes from passing extra options to a 'has' attribute declaration. Previously it took two arguments and ignored the rest. Now it uses the rest as options and only the 'weak' option is allowed. -Dan On Sun, Oct 28, 2018 at 3:45 PM Jan Eskilsson wrote: > Hi All > > Today we upgraded

Re: [Mojolicious] Stable version to upgrade to

2018-10-24 Thread Dan Book
Yes, there is no reason to run an older release. Yes, there is a danger to blindly updating, it's recommended to manage all your CPAN dependencies (not just Mojolicious) with Carton to pin versions if this is a concern. -Dan On Tue, Oct 23, 2018 at 11:58 PM Stefan Adams wrote: > > > On Tue,

Re: [Mojolicious] Re: Mojo::Log and UTF-8

2018-10-10 Thread Dan Book
) data? > > суббота, 6 октября 2018 г., 20:30:12 UTC+3 пользователь Dan Book написал: >> >> The script is not quite correct. I suspect if you add "use warnings" you >> will see a "Wide character in print" warning, because you are not encoding >> your u

Re: [Mojolicious] How do I force Mojo::UserAgent to close connection?

2018-10-10 Thread Dan Book
$ua->max_connections(0); https://metacpan.org/pod/Mojo::UserAgent#max_connections -Dan On Wed, Oct 10, 2018 at 5:53 PM Alex Povolotsky wrote: > Hello > > Reusing connections as it does Mojo::UserAgent is nice, but sometimes I > have to change source IP of all next requests for given UA. Just

  1   2   >