The web in a box - a next generation web framework for the Perl programming language

IRC log for #mojo, 2016-07-13

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
02:47 noganex joined #mojo
03:13 che-quest joined #mojo
04:03 zivester joined #mojo
05:08 jberger ningu: eats some poi
05:09 jberger ningu: clearing the session is the same as expiring it
05:09 jberger Set the expiration time to 1
05:21 pkuptsov joined #mojo
05:24 prajith joined #mojo
05:25 prajith jberger: When you get time, please check this and let me know. https://github.com/Prajithp/mojo-ami
05:35 ningu jberger: ah ok
05:51 jberger prajith: i can't really audit now
05:51 jberger But the fact that the package name is incorrect makes me wonder if you have tried to use this thing at all yet :p
05:55 prajith <jberger>:I tried with just 'AMI' and renamed it to MOJO::AMI. Thanks for pointing out this
05:55 prajith corrected now
06:04 ningu jberger: $c->session(expires => 1) is not working for me, any idea why?
06:04 ningu it's doing nothing
06:06 jberger ningu: how are you setting it?
06:07 jberger Remember that it its heart it is a cookie so certain rules apply
06:07 ningu oh, doh
06:07 ningu yeah, I see what's going on, nevermind :)
06:07 jberger Cool
06:07 ningu I was using a proxy method to return the session so I can't call it like a function
06:07 ningu I'll just do ->{expires} = 1
06:09 jberger helper clear_session => sub { shift->session(expires => 1) };
06:10 ningu jberger: it was more like sub { shift->session }
06:10 jberger Maybe clear is a bad name, expire_session is more correct
06:10 ningu I was just setting things directly on the hash in the app
06:10 jberger Yeah
06:10 ningu I don't need a helper just to clear/expire the session
06:11 ningu the issue is the $c object is less accessible in this app than it should/could be so I made a helper method to return the session rather than doing ->c->session
06:30 dod joined #mojo
06:33 cuechan joined #mojo
06:35 dod joined #mojo
07:00 jamesaxl joined #mojo
07:01 anton joined #mojo
07:03 AndrewIsh joined #mojo
07:06 Vandal joined #mojo
07:13 pkuptsov joined #mojo
07:23 trone joined #mojo
07:39 nothing joined #mojo
07:41 cpan_mojo Mojolicious-Plugin-XML-LX-0.02 by RSHADOW https://metacpan.org/release/RSHADOW/Mojolicious-Plugin-XML-LX-0.02
08:16 Dandre joined #mojo
08:17 pkuptsov joined #mojo
08:22 Dandre Hello,
08:22 Dandre Is there any way to know whether a GET request has been completed? ie all data data sent by the server received by the client.
08:23 Dandre I have tried this code: http://pastebin.fr/47234 but returned code is always 200 even if I stop the connection.
08:33 cuechan joined #mojo
08:47 dod joined #mojo
08:58 Vandal I don't think that HTTP allows something like that
08:59 Vandal only thing I can think of is JS fired up AJAX request on page load to report its got every thing
09:00 nic Can't you check the content has the "</html>" ?
09:01 jberger Somewhere one of the lower level classes probably has a drain event
09:05 jberger Ok so starting here:  http://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Streaming
09:05 jberger You see how to do a streaming response
09:08 jberger If you subscribe to the response message's content object's (http://mojolicious.org/perldoc/Mojo/Message#content) drain event
09:08 jberger http://mojolicious.org/perldoc/Mojo/Content#drain
09:08 jberger Then you should be able to tell what has actually been written
09:09 jberger (Not a bad bit of digging from a phone if I do say so myself)
09:14 Dandre Ok I will try
09:28 cuechan joined #mojo
10:22 dod joined #mojo
10:38 punter joined #mojo
10:57 tchaves joined #mojo
11:09 kid51 joined #mojo
11:23 rhino joined #mojo
11:23 rhino hey how do i get my mojo light app to start on my public ip?
11:24 prajith rhino: do you have public IP?
11:24 rhino yep
11:25 prajith rhino: and if you are sure, the ip address is pointing to your machine, then you don't need to do anything much
11:25 prajith simply start the application
11:25 prajith and access with <ip>:port
11:26 rhino it only hosts on 127.0.0.1
11:27 noize rhino: use nginx, Luke )
11:28 prajith then you should pass following arguments to the script,   daemon -m production -l http://*:5000
11:28 noize use nginx as proxy which point on your localhost and <mojoapp>-port, by example. 127.0.0.1:8080
11:31 rhino cheers, will go try some of them things
11:37 batman joined #mojo
11:40 batman joined #mojo
12:01 McA joined #mojo
12:10 kid511 joined #mojo
12:17 cuechan joined #mojo
12:35 zivester joined #mojo
12:36 dvinciguerra joined #mojo
12:42 punter joined #mojo
12:55 bumpy joined #mojo
13:13 gizmomathboy joined #mojo
13:30 marty joined #mojo
13:34 Dandre Could I have your opinion about this: http://pastebin.fr/47238
13:34 Dandre I have updated my code using jberger pointers. The idea is to emit a custom event (k_completed) when there is no more data to be sent
13:35 sri why not just use the finish event of the transaction?
13:35 gizmomathboy joined #mojo
13:37 sri actually, ignore me, you're using some ancient version of mojolicious
13:37 Dandre yes I do
13:38 Dandre Do you mean that with an updated version the finish event is not emitted if the client disconnect from the server?
13:40 neilhwatson joined #mojo
13:40 wingfold joined #mojo
13:55 Atog joined #mojo
13:58 dantti_laptop joined #mojo
14:04 PryMar56 joined #mojo
14:05 dod joined #mojo
14:11 jacoby joined #mojo
14:22 dvinciguerra joined #mojo
14:34 prajith joined #mojo
14:35 mcsnolte joined #mojo
14:35 ptolemarch joined #mojo
14:41 zivester joined #mojo
14:47 firnsy joined #mojo
14:47 marty joined #mojo
14:51 skinch joined #mojo
14:57 zivester joined #mojo
15:01 dod joined #mojo
15:10 gizmomathboy joined #mojo
15:14 disputin joined #mojo
15:28 dod joined #mojo
16:38 dvinciguerra_ joined #mojo
16:39 disputin joined #mojo
16:41 punter joined #mojo
16:49 Adura joined #mojo
16:53 disputin joined #mojo
17:22 trone joined #mojo
17:26 lluad joined #mojo
17:32 jberger Dandre: i think you mistook my meaning
17:32 jberger And i wasn't very clear
17:32 jberger You don't want to use the streaming code examples
17:33 jberger That was just where i started looking for the drain event
17:34 jberger sri: I'm curious too, dies the finish event not get emitted I'd the client disconnects early? I thought finish was always emitted
17:35 jberger s/dies/does/; s/I'd/if/ # yeah yeah phone keyboard
17:37 prajith joined #mojo
17:43 asarch joined #mojo
17:45 zivester joined #mojo
17:46 sri jberger: it always gets emitted
17:56 zivester joined #mojo
18:20 itaipu joined #mojo
18:51 lluad joined #mojo
18:52 ptolemarch joined #mojo
19:09 genio joined #mojo
19:12 jberger I thought so, Dandre is looking to know for sure that the response was actually sent to the client, I think the drain event on content is the right thing
19:12 lluad joined #mojo
19:24 sri you can't know that, so it's pointless
19:25 sri sockets don't work that way
19:28 punter joined #mojo
19:38 jberger sure, but at least you know you've written the data
19:38 jberger nothing is going to guarantee that it got there
19:38 jberger sorry, I thought that that was implied, Dandre does that make sense to you
19:38 jberger ?
19:43 sri no, all you know is that it has been written to the kernel send buffer
19:43 sri where it went then you have no clue
19:43 sri so, it's totally pointless
19:50 jberger hmmm true
19:50 jberger ok I stand corrected
19:56 punter joined #mojo
19:56 iamb joined #mojo
20:22 disputin joined #mojo
20:38 bc547 joined #mojo
20:47 dantti_laptop joined #mojo
20:58 itaipu joined #mojo
20:58 cuechan joined #mojo
21:06 jberger sri: thoughts on adding a Mojo::JSON::bool (possibly prototyped $) which is basically sub Mojo::JSON::bool { $_[0] ? Mojo::JSON::true : Mojo::JSON::false }?
21:06 jberger something we are starting to do at $work anyway
21:07 Grinnz_ i've had a json_if function that does basically exactly that for a while
21:07 Grinnz_ not really any precedent in any existing modules though
21:08 jberger we've already broken from most other module's apis though
21:10 sri jberger: why?
21:10 sri looks so verbose
21:12 jberger because encode_json({ something => \($value ? 1 : 0) }) is ugly and encode_json({ something => \(!! $value) }) isn't portable and encode_json({ something => $value ? Mojo::JSON::true : Mojo::JSON::false }) is even more verbose
21:12 sri how is \!!$value not portable?
21:13 preaction JSON::XS chokes because it's \"" and not \0
21:13 jberger JSON::XS::encode({false => \('')}) chokes
21:13 sri eww
21:13 preaction yeah. that's what i had before that has now led to this
21:14 jberger btw, preaction is now at ServerCentral too \o/
21:14 preaction one would think that a ref to PL_sv_no would work in that instance :p
21:15 sri you should report that against Cpanel::JSON::XS
21:15 preaction but i'm not gonna be the one to send the JSON::XS patch, questioning the perfection of schmorp's code, which i'm sure has a reason to be what it is and i'm just too stupid to realize it from the existing code that's there...
21:15 sri i'm sure reini will fix it
21:15 jberger true, reini probably would
21:15 sri what JSON::XS does will have no influence on mojolicious
21:16 sri not as long as Cpanel::JSON::XS exists
21:16 jberger I still think that a boolean coercion function would be semantically nice (I have started to use the booleans in contexts where I only MIGHT render to JSON but still want a falsey value)
21:16 sri -1 from me
21:17 * jberger ponders core utility
21:18 jberger I wonder if we ternary in the codebase much, even in examples/doc?
21:18 * jberger wishes the ternary were easier to grep for
21:21 jberger from my best-attempt searches I don't see much
21:22 jberger if you don't see end-user utility in such a function than I guess I don't have much of an argument for it
21:23 jberger but I cite the fact that Grinnz_ does a similar thing as circumstantial evidence
21:24 jberger some results in Mango: http://grep.cpan.me/?q=%5C%5C1%5Cs%2A%3A%5Cs%2A%5C%5C0+dist=Mango
21:24 Grinnz_ the biggest hurdle to me would be the name, "true" and "false" being imported as subs isn't usually a problem but "bool" might be too generic
21:24 jberger they aren't exported by default, I don't see how that's a problem
21:25 jberger I usually use true/false fully qualified anyway
21:25 Grinnz_ just from a usability standpoint
21:25 Grinnz_ but, eh
21:26 jberger I have no idea what this is but: https://metacpan.org/source/TYPESTER/JSON-Types-0.05/lib/JSON/Types.pm#L19
21:26 preaction i was thinking "bool" because we have "int" to truncate scalars down to an integer. otherwise, boolean.pm calls it "boolean"
21:27 jberger I can see it being handy with json(b?) documents in Mojo::Pg too (something I already do at $work)
21:28 jberger ok, I've laid out use-cases, I won't go overboard
21:32 cuechan_ joined #mojo
21:56 CHYC jberger: Your Mojo::JSON::bool(undef) would return Mojo::JSON::false no? For me, I would expect undef.
21:57 jberger CHYC: for null?
21:57 jberger hmmm, interesting point
21:58 CHYC Exactly
22:00 jberger http://tinyurl.com/zroaq64
22:02 preaction it means that to do it right, having a bool() function saves even more code: !defined $_[0] ? undef : $_[0] ? true : false; :p
22:02 jberger well null is not a boolean, so I could argue it the other way, but I conceed that it muddies the waters
22:02 jberger preaction: decent point
22:02 preaction but yeah, having undef pass-through is a toss-up
22:06 Grinnz_ I used to have it return undef for undef, but it ended up that returning false was more useful for me
22:07 Grinnz_ I use it basically exclusively where I want to give the frontend either true or false
22:08 Grinnz_ as it's more like an "if" condition, typified
22:08 Grinnz_ undef is "false" in that context
22:10 dvinciguerra_ joined #mojo
22:11 sri there will be no bool function ;p
22:12 preaction there is no undef only bool!
22:12 Grinnz_ well, bool, and not bool
22:19 * sri installs pokemon go
22:27 _dave_ it's amazing that a single bit of information causes so much headache :)
22:28 Grinnz_ a whole byte, in many implementations :P
22:53 kid511 joined #mojo
22:59 disputin joined #mojo
23:15 nothing joined #mojo
23:30 disputin joined #mojo
23:36 nothing joined #mojo
23:59 disputin1 joined #mojo

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary