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

IRC log for #mojo, 2015-10-14

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

All times shown according to UTC.

Time Nick Message
00:00 jontaylor joined #mojo
00:48 asarch joined #mojo
01:08 PryMar56 joined #mojo
02:18 noganex_ joined #mojo
02:43 jberger Grinnz_: I think for simple wrappers the Webservice:: namespace is recommended
02:47 bwf joined #mojo
02:49 aborazmeh joined #mojo
02:52 Grinnz hmm that could work
02:54 zivester joined #mojo
03:05 mattastrophe joined #mojo
03:27 inokenty-w joined #mojo
03:34 davido_ joined #mojo
06:12 panshin joined #mojo
06:52 batman off topic... does anyone know if readdir will pick up new items in a directory or if it will just read the files which is present on opendir?
06:52 batman dummy code: opendir($DH, "."); while (my $file = readdir $DH) { sleep 1; warn $file }
06:53 batman i could test it locally, but i have no idea about portability :/
07:04 henq joined #mojo
07:07 coolo batman: readdir internally stores some kind of offset where it is in the DIR stream (you can manipulate it with seekdir(3)) - so as new files appear another call to readdir will continue reading from it
07:07 batman "continue reading from it" = what is "it" ?
07:08 coolo but technically this is implemented by the filesystem, so you can't really rely on it - as complex file systems that store files in b-trees instead of lists like to buffer the open directory as a list
07:08 coolo batman: the open directory stream
07:08 Andreas joined #mojo
07:09 coolo batman: opendir is actually open(2) with O_DIRECTORY
07:09 batman ok. thank you
07:09 coolo and readdir is actually getdents64 on that file descriptor
07:17 eseyman joined #mojo
07:19 trone joined #mojo
07:20 henq joined #mojo
07:25 berov joined #mojo
07:26 AndrewIsh joined #mojo
07:29 henq joined #mojo
07:31 sugar joined #mojo
07:37 henq joined #mojo
07:55 panshin_ joined #mojo
07:56 henq joined #mojo
08:07 meshl joined #mojo
08:07 berov joined #mojo
08:17 henq joined #mojo
08:18 nic getdents64?  that could be the name of my car
08:28 Vandal joined #mojo
08:37 gatitskiy joined #mojo
08:40 henq joined #mojo
08:46 vanHoesel joined #mojo
08:50 davido_ joined #mojo
08:54 henq joined #mojo
09:03 henq joined #mojo
09:09 henq joined #mojo
09:21 henq joined #mojo
09:23 melo joined #mojo
09:33 gaunt_ joined #mojo
09:40 Mikey joined #mojo
09:48 asarch joined #mojo
10:03 henq joined #mojo
10:09 vytas joined #mojo
10:24 henq joined #mojo
10:36 vytas joined #mojo
10:41 dvinciguerra joined #mojo
10:47 jontaylor joined #mojo
11:00 neilhwatson joined #mojo
11:17 Shaeto joined #mojo
11:47 Shaeto left #mojo
11:51 henq joined #mojo
12:13 panshin joined #mojo
12:14 jabberwok joined #mojo
12:16 jabberwok Is there an explanation of what exactly --home (or $MOJO_HOME) affects? For example, is lib/ (as used, and as monitored by morbo) still relative to the script's directory, but config files and public/ moves with --home ? I'd like to add that to the docs.
12:17 nic public, templates, log
12:18 jabberwok =bow=  thank you
12:19 jabberwok knowing that would have saved me a lot of stress!  i'll write it up for the next fellow.
12:19 nic basically app->home has to be your working directory or things go a bit crazy
12:20 nic eg in a cgi environment it's common for home to be wrong, but you can set it manually with app->home->parse(...)
12:21 nic btw, it's unusual to need to set it outside of a cgi env, so if yours is going wrong you might want to look into why
12:22 jabberwok hmm.  i am looking for a way to have a single codeset (from a single git repo) that runs multiple websites.  or at least a way to keep each website's stuff out of the directory tree controlled by git.
12:23 nic heh, was just about to mention app embedding
12:23 nic wow
12:24 nic just googled 'mojofarm' and got a _lot_ of results I wasn't expecting :D
12:27 nic err, Toadfarm is what I should have been looking for
12:28 jabberwok Ahhh yes
12:28 batman nic: app->home is _not_ your current directory.
12:28 nic correct
12:28 nic "working directory" :)
12:29 batman how is that different? https://metacpan.org/pod/Mojo::Home#detect
12:30 batman jabberwok: https://metacpan.org/pod/Toadfarm
12:30 nic 'current' means the one you're in at this instant, 'working' means the heart of where the working is happening (at least in my head)
12:31 batman jabberwok: if it doesn't work as expected, you might want to look at https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides/Cookbook.pod#Making-your-application-installable
12:31 jabberwok Ahh batman so I can mount "MyApp" multiple times with different hostname+config for each? ... lovely!
12:32 batman yes
12:32 batman you don't even need the executable script/myapp
12:33 jabberwok i gave an informal demo of Mojolicious to some of the NodeJS guys here and they were like... "whaaaaa... wait, this is Perl? No, really? what'
12:33 jabberwok s that url again?"
12:33 batman :)
12:35 batman jabberwok: Toadfarm is also init-script compatible, so you can put the toafarm script in /etc/init.d/ - https://metacpan.org/pod/distribution/Toadfarm/lib/Toadfarm/Manual/RunningToadfarm.pod#Init-script
12:41 nic that's an unusual init script
12:41 nic batman: Do you mean it to call 'start' even when invoked with the argument 'stop'?
12:43 bd and no proper exit codes
12:49 ZoffixW joined #mojo
12:53 mattastrophe joined #mojo
12:53 batman nic: what do you mean?
12:54 batman bd: sure there are. https://metacpan.org/source/JHTHORSEN/Toadfarm-0.68/lib/Toadfarm/Command/start.pm
12:55 nic batman: I don't know if I'm just missing something, but it appears to assume it was invoked with 'start'
12:55 nic so if I invoke instead "/etc/init.d/myapp stop" will I get a nasty surprise or is there some magic I'm not seeing?
12:56 batman nic: /etc/init.d/toadfarm-script {start,stop,restart,reload}
12:56 batman do you mean that "stop" will "start" the server? if so, that is incorrect
12:57 nic I'm just asking where 'stop' is implemented
12:57 batman nic: https://metacpan.org/pod/Toadfarm::Command::stop
12:58 nic I seeeee
12:58 ajr_ joined #mojo
12:59 jabberwok i think it's the clever placement of "if 0;" in the init-script that's confusing?
12:59 batman nic: you know how you have "./script/yourapp daemon", where "daemon" will call Mojolicious::Command::daemon->run() ?
12:59 nic So it's unusual insofar as it's unusual having the parts in separate files
12:59 nic batman: I know how Mojolicious commands work, yes
12:59 hernan605 joined #mojo
12:59 batman jabberwok: that if 0; is important, since the script is not executed under a shell on boot
13:00 jabberwok that's the bit of magic
13:00 nic I'm just saying it's unusual for an init.d script to be split up in non-apparent files
13:00 batman nic: right, so i'm adding a new namespace to the commands, allowing the script to execute commands in the Toadfarm::Command namespace
13:01 nic batman: It's probably worth putting some words in there so that sysadmins don't balk at it
13:01 batman nic: most of the sh-init-scripts i use "source" other shell scripts. not sure how this is different.
13:01 nic A sysadmin is expecting to be able to sanity check the script and is looking for how it handles start/stop/status/reload
13:01 nic so you need some words saying where those are handled
13:01 batman nic: "use Toadfarm" :)
13:04 batman i doubt every sysadmin has the need to sanity check the contents of files such as /lib/lsb/init-functions
13:05 nic They don't need to, those are standard
13:05 nic (but a good sysadmin will be very familiar with its contents)
13:06 batman Toadfarm::Commands:: is the same thing, just written in another language.
13:07 batman how does "start-stop-daemon" work? you don't care, you just need to know it does the right thing.
13:07 nic I can tell you're not a sysadmin :)
13:07 batman how does toadfarm work? you don't care, you just need it to do the right thing and follow the init-script "protocol"
13:07 batman nic: imo your argumentation is circular.
13:08 batman i've had this discussion so many times before. it's pretty old :/
13:08 nic I think our argumentation is moot, seeing as a good sysadmin won't be in that situation:
13:08 nic it only works if Toadfarm is installed in perl's global path, which a sensible sysadmin isn't going to do
13:08 nic (it'll be under /srv most likely)
13:08 batman nic: that is also incorrect.
13:09 batman please come back after you read the documentation.
13:09 batman your comments are incorrect and destructive :(
13:10 nic I'm sorry you feel that way.  I was only suggesting you add some soothing words to allay the fears of some readers
13:11 batman i would appreciate a pull request with those words, but the feedback you've given me so far is simply incorrect
13:11 batman (at least about exit codes and global perl)
13:12 * nic hasn't mentioned any exit codes
13:12 nic nor global perl
13:12 batman sorry, that was bd about the exit codes :(
13:13 jabberwok Washington Metro and BART make you pay exit codes.  i mean... oh, wait... that's exit fare.
13:13 batman ;)
13:14 jabberwok subways with the apple mentality: it's free to enter, but you have to pay to leave.
13:17 batman my Toadfarm.pm is located in /path/to/www/.plenv/versions/something. that's why the documentation has "#!/path/to/your/perl" and not "#!/usr/bin/perl" or something else
13:18 batman the "Required-Start" should probably have "filesystems" or something, but i'm not familiar with those to make a good example.
13:18 batman i would appreciate help om making that default init-script better.
13:19 jabberwok a comment on the magic if (shells don't see this line) would clarify that bit.
13:23 batman jabberwok: yeah, i see that "# not running under some shell" is not very understandable :/
13:26 sri batman: do you know what's going on here? https://github.com/kraih/minion/issues/15
13:29 batman sri: in my way home.... Can look at it in ~10 minutes.
13:31 nic sri: In Ex1, is there an ioloop already running?  I see they call 'start' instead of 'wait'
13:35 sri nic: event loops do not run in the worker process
13:35 sri even calls Mojo::IOLoop->reset before starting a job
13:36 nic ah, I wondered what that was for
13:37 nic In delays, when do I call 'pass' without arguments?  Is it so I can jump to the next step?
13:38 MartinR joined #mojo
13:39 sri yes
13:39 nic thanks
13:50 nic using delays is saving me from so much thinking, but I can't help thinking about how much thinking it's saving me from, and thinking about the unnecessary thinking is making my head explode
13:51 genio heh.  stop thinking
13:51 PryMar56 joined #mojo
13:51 nic I'm sure A A Milne wrote a poem about it, but I have no capacity to think about that
13:53 stephen joined #mojo
13:54 batman sri, jberger: i don't get https://github.com/kraih/mojo/pull/854 ... what's wrong with json_is("/", {..}, "description"); ?
13:55 sri batman: you mean "", not "/" ;p
13:56 batman sri: i thought https://github.com/kraih/mojo/pull/851 allowed botht "/" and "" :/
13:56 batman sri: but... yes :)
13:57 sri i don't think the pull request is correct, since you can't do ref checks for json anymore
13:57 sri why existing tests don't fail i don't know, but it shouldn't be possible for it to work correctly
13:59 batman does that mean that you have to do "/foo/bar", "plain string" and not "/foo", {bar => "plain string"} ?
14:00 sri do you mean "have to" or "can"?
14:00 sri because both are fine
14:01 genio how do you distinguish between a possible trailing string description and a string.    json_is($string)   json_is($string,$string)  json_is($string,$description)   json_is($string,$string,$description)
14:01 batman no, i just misunderstood "but it shouldn't be possible for it to work correctly"
14:01 batman thanks for the clarification
14:07 * batman eats dinner.
14:07 batman sri: i'll check in on the minion issue later when i get a response
14:13 gryphon joined #mojo
14:27 panshin joined #mojo
14:30 jberger genio: thats why it behaves as it does currently
14:31 jberger one arg is the spec data to check, two args is pointer and data, three is pointer data and description
14:35 henq joined #mojo
14:42 good_news_everyon joined #mojo
14:42 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/vCrFV
14:42 good_news_everyon mojo/master c99ece3 Sebastian Riedel: fix "0" value bug in Mojo::JSON::Pointer
14:42 good_news_everyon left #mojo
14:45 sri not sure if it should check for defined, considering undef represents null in JSON
14:46 sri Mojo::JSON::Pointer->new(undef)->contains('') is true too right now
14:46 * sri shrugs
14:48 henq joined #mojo
14:50 jberger I hate the new json spec so much
14:50 jberger it was such a simple spec before
14:51 henq Hi, I tried to get inline javascript call in a taghelper , like so
14:51 henq %= input_tag 'foo' ,  onclick => "dojs()"
14:51 henq but that raises an error.  Any way to do this?
14:52 hernan606 joined #mojo
15:09 asarch joined #mojo
15:11 genio I'm not sure I understand the purpose of JSON pointers yet.
15:19 y1mmm joined #mojo
15:21 cpan_mojo JSON-Validator-0.59 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/JSON-Validator-0.59
15:21 MartinR joined #mojo
15:29 jberger genio: mojo get http://api.metacpan.org/v0/module/Mojolicious /version
15:31 jberger think xpath (or even css3 selectors) for json
15:36 genio I guess I've only been looking at it from a simple case point of view like that where it's no easier than $object->{version}.  but if you have a more complicated selector I guess I can see where that would be easier
15:38 jberger you also don't need to specify types, so ->{foo}[1]{bar} becomes /foo/1/bar
15:38 jberger and it DTRT
15:39 jberger not its not a panacea, but it is very simple (which is its strong suit)
15:39 sri you can also ship the pointer in a json structure
15:39 sri for stuff like this https://tools.ietf.org/html/rfc6902
15:47 MartinR hmm it looks like when two prototype aps are on the same ip with different port form_for gets overwritten ?
15:47 MartinR apps*
15:52 jberger MartinR: you have to be careful about how you do that
15:52 jberger this is reverse proxy?
15:55 MartinR I just have two lite apps one on port 3000 and another one 3001, both have any '/login' route and it looks like the second one on port 3001 overwrite that one on port 3000
15:56 MartinR so when I do ip:3000/login I gets results from 3001:/login
15:57 MartinR when I change routes name so they are different all works correct
15:57 jberger that seems wrong
16:00 MartinR looks like a bug in form_for
16:01 hernan605 joined #mojo
16:12 sri that would very much surprise me, seems more like a misunderstanding
16:17 sri batman: from the test case, it seems like the only difference is the worker command
16:17 sri maybe something here makes EV trip up https://github.com/kraih/minion/blob/master/lib/Minion/Command/minion/worker.pm
16:17 sri perhaps the signals?
16:18 batman sri: oh! local $SIG{CHLD} = 'DEFAULT'; <--- don't think this will fly
16:18 batman let me make a test case.
16:18 batman yeah! thanks :)
16:19 batman why do you have SIG{CHLD} there?
16:19 sri i don't know
16:19 batman :(
16:20 sri seems to be irrelevant
16:20 sri might be legacy
16:21 batman can you remove it..?
16:21 sri sure
16:21 punter joined #mojo
16:21 batman cool! care to commit with ".... #15" so Logioniz gets notified?
16:22 punter Where can I find the best vim plugin for editing Mojolicious .ep files?
16:22 batman just ran his test now with $SIG{CHLD} = "DEFAULT" which makes it hang
16:22 punter or a good one, at least?
16:22 batman punter: https://github.com/yko/mojo.vim
16:22 henq joined #mojo
16:22 punter takk
16:23 sri batman: https://github.com/kraih/minion/commit/3be062eae189ee518b4a53192f52568215490432
16:24 batman sri++
16:24 sri looks like it's leftover code from the old process management stuff
16:25 sri before it used waitpid in a loop
16:27 batman yeah, waitpid makes life easier :)
16:31 cpan_mojo Minion-2.04 by SRI https://metacpan.org/release/SRI/Minion-2.04
16:41 jontaylor joined #mojo
17:07 trone joined #mojo
17:17 sh4 joined #mojo
17:21 ladnaV joined #mojo
17:35 disputin joined #mojo
18:03 zivester joined #mojo
18:15 panshin joined #mojo
18:26 MartinR is it the correct way to pass file param with UserAgent ? http://paste.scsys.co.uk/500279?ln=on&amp;tidy=on&amp;hl=on&amp;submit=Format+it%21
18:27 MartinR it works ok for text param
18:28 MartinR but here I get "Can't locate object method "size"" -> line 40 at pasted code
18:32 jb360 joined #mojo
18:35 thowe joined #mojo
18:39 marty joined #mojo
18:42 Grinnz https://metacpan.org/pod/Mojolicious::Guides::Cookbook#Large-file-upload
18:42 Grinnz form => { example => { file => $file } }
18:43 MartinR joined #mojo
18:48 Grinnz https://metacpan.org/pod/Mojolicious::Guides::Cookbook#Large-file-upload if you missed it
18:48 MartinR Grinnz, thanks :)
18:49 MartinR now "Mojo::Reactor::EV: I/O w
18:49 MartinR package "Mojo::Upload"
18:50 jberger MartinR: http://mojolicio.us/perldoc/Mojo/Message#upload
18:52 sugar joined #mojo
18:53 Grinnz you can actually pass file => $upload->asset, though i'm not sure if that's documented
18:54 Grinnz ah it is, https://metacpan.org/pod/Mojo::UserAgent::Transactor#tx -- The file value should contain the path to the file you want to upload or an asset object, like Mojo::Asset::File or Mojo::Asset::Memory.
19:03 sugar joined #mojo
19:05 MartinR Grinnz, thanks I will check it
19:06 MartinR I wonder how to use jberger link
19:10 MartinR what would be that $msg object under my lite app ? "my $upload = $msg->upload('example');"
19:11 sri http://mojolicio.us/perldoc/Mojo/Message#DESCRIPTION
19:12 Grinnz_ MartinR: you're already getting the Mojo::Upload from ->param
19:12 Grinnz_ https://metacpan.org/pod/Mojolicious::Controller#param
19:12 sri http://mojolicio.us/perldoc/Mojolicious/Controller#req
19:13 sri the link from jberger was not great though
19:20 MartinR thanks for recources guys
19:22 sri this would have been the best link http://mojolicio.us/perldoc/Mojolicious/Guides/Tutorial#File-uploads
19:28 jberger is ->uploads used in any of the guides?
19:28 sri very unlikely
19:59 MartinR it works coded as here -> http://paste.scsys.co.uk/500281?tidy=on&amp;hl=on&amp;submit=Format+it%21
19:59 MartinR the only mistake is filename mojo.tmp. instead of real file name
19:59 MartinR so I guess I did something wrong
20:00 NwBhy_ joined #mojo
20:05 mattastrophe joined #mojo
20:56 disputin joined #mojo
20:58 MartinR do I pass it correctly --> http://paste.scsys.co.uk/500281?tidy=on&amp;hl=on&amp;submit=Format+it%21 ?
20:59 MartinR file => $file->asset as the doc says upload works but it doesn't know filename
21:00 MartinR the funny thing is filesize is ok :P
21:00 Grinnz_ see https://metacpan.org/pod/Mojo::UserAgent::Transactor#tx, it also discusses setting a filename
21:01 Grinnz_ you're setting enctype incorrectly, but it gets set automatically since you have a {file} param anyway
21:01 Grinnz_ just remove that
21:01 MartinR "enctype => 'multipart/form-data'});" is wrong ?
21:01 Grinnz_ yes, that is just adding a form field called 'enctype'
21:02 MartinR sure ;)
21:02 Grinnz_ the docs also tell how to set that manually, but you don't need to
21:04 Grinnz_ form => { example => { file => $file->asset, filename => $file->filename } }
21:05 MartinR ok I set filename, you were right it was there, I even read about it but it was strange to me that size is detected automaticly and filename doesn't
21:06 pink_mist size is a  property of the data, a filename isn't
21:06 Grinnz_ the asset will always have the same size, but it could easily be moved to a different filename, or no filename at all if it is a Mojo::Asset::Memory
21:06 Grinnz_ so you want to get the filename from the Mojo::Upload
21:07 MartinR yes I think so, Grinnz_ thank you ;]
21:08 MartinR pink_mist, but there is filename attribute in MOjo::Upload
21:08 MartinR I was hoping it will be inluded in ->asset hash
21:08 Grinnz_ because an upload will have a filename associated, but this isn't used to store it
21:09 MartinR so I bet the way I save file is correct -> $file->move_to('C:\Users\Martin\Desktop\uploaded'.'\\'.$name);
21:09 Grinnz_ think of asset as "temporary data"
21:09 MartinR I am on windows so the path may seems weird to you ;)
21:16 berov1 joined #mojo
21:17 MartinR Grinnz_, would it be worth setting it as websocket ?
21:17 Grinnz_ what?
21:20 MartinR I mean user agent WebSocket transaction
21:21 Grinnz_ i know what it is, but i dont know what benefit a websocket could bring
21:24 jberger MartinR: did you give up on the client side pre-flight call then?
21:24 MartinR jberger, heh nice question - no, I am testing User:Agent first ;)
21:27 cpan_mojo Swagger2-0.60 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/Swagger2-0.60
21:29 MartinR jberger, do you have ready solution for that ;)
21:31 disputin joined #mojo
21:32 MartinR I have plan to use ajax request for that pre-flight call ;)
21:33 dvinciguerra joined #mojo
21:35 neilhwatson joined #mojo
21:46 jberger nothing pre-packaged no
21:50 stephen joined #mojo
21:52 sugar joined #mojo
22:00 MartinR i will post my solution soon ( I hope)
22:03 d4rkie joined #mojo
22:17 sri MartinR: i hope you're sanitizing that name before concatenating the path
22:21 MartinR since this is just test app I didn't but in production sure - I plan to produce uniq $name that will be saved in db not filename
22:24 MartinR i.e wfd82ed2 instead of file.jpg
22:25 henq joined #mojo
22:32 zivester joined #mojo
22:48 sri Zoffix: i do sense a bit of a contemptuous attitude towards perl5 in #perl6
22:49 sri that relationship should only get more interesting as people from other languages try perl6
22:51 meshl joined #mojo
23:02 sri it's a bit sad that server side web development has become so boring
23:02 sri so few things to improve in mojolicious
23:16 sri i guess we could do more fun stuff if we decided to venture more into javascript territory
23:17 sri like for multiplexing named channels over a websocket
23:27 cpan_mojo App-docsisicious-0.01 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/App-docsisicious-0.01
23:29 Grinnz that's a mouthful
23:32 batman sri: i've exposed swagger over websockets: https://metacpan.org/pod/distribution/Swagger2/lib/Swagger2/Guides/WebSocket.pod
23:33 batman and split the json-schema part into https://metacpan.org/pod/JSON::Validator
23:33 batman not sure if this is news or not...
23:33 henq joined #mojo
23:47 zivester joined #mojo
23:50 cpan_mojo App-docsisicious-0.02 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/App-docsisicious-0.02
23:56 sri batman: you know what i think about REST over websockets ;p
23:56 batman sri: did you look at the documentation? :)
23:59 sri batman: anything specific i should look at?
23:59 batman just that i try to "hide" all the rest stuff as best as i can
23:59 batman just using the meta info instead

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