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

IRC log for #mojo, 2015-05-08

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

All times shown according to UTC.

Time Nick Message
00:21 mattastrophe joined #mojo
00:26 Grinnz hmm.. theres a problem with that actually, the delegated emit() would use the stored EventEmitter as the invocant instead of the object
00:26 Grinnz but i'm not using it anyway.. heh
00:27 Grinnz ill just reimplement emit() if i need to...
01:08 hshong joined #mojo
01:10 klapperl joined #mojo
01:46 mattastrophe joined #mojo
01:47 Zoffix joined #mojo
01:47 Witch joined #mojo
01:54 asarch joined #mojo
02:13 noganex_ joined #mojo
02:16 dave joined #mojo
02:23 Repaster joined #mojo
02:42 disputin joined #mojo
02:59 caveman_ joined #mojo
03:45 basic6_ joined #mojo
04:41 Grinnz and apparently preaction already has a Moo role event emitter :P
04:42 Grinnz https://metacpan.org/pod/release/PREACTION/Beam-Emitter-1.000/lib/Beam/Emitter.pm
04:43 preaction yes, but mine has a crucial difference that some people find distasteful: i prefer having event objects
04:43 preaction i have a way to bypass that, but still it's my preferred thing
04:44 preaction Beam itself is kind of like Java design patterns applied to Perl (where useful)
04:46 Grinnz yeah i wouldn't use the object. but looks nice
04:47 kaare joined #mojo
04:50 polettix joined #mojo
04:51 Grinnz i'd still have to override the emitting... apparently i have an odd requirement where i want to continue processing subscribers if one callback dies
04:53 Grinnz and continue whatever code emitted the event after
04:54 mst easy enough with compound futures
04:55 Grinnz let's not get crazy now :P
04:55 Grinnz i don't mean continuations
04:55 preaction Grinnz: perhaps create a Beam::Emitter::Safe? I'd gladly merge something like that
04:56 Grinnz preaction, hmm maybe
04:56 preaction i mean, it seems like a good idea that other people would also be interested in
04:56 preaction or maybe emit_safe?
04:56 preaction hmm... but then there'd need to be emit_args_safe
04:57 Grinnz well the problem i'm not sure about generalizing, is that right now i'm logging the error it gets
04:57 preaction make it an event ;)
04:57 Grinnz obviously, the generic emitter role can't count on the object having a logger
04:57 Grinnz eh
04:57 Grinnz that seems overly complex
04:57 preaction or a callback attribute
04:57 preaction or an argument to emit_safe
04:57 preaction er.. emit
04:58 Grinnz i dunno...
04:59 preaction up to you. imma add a ticket for it, so i might do it myself anyway ;)
04:59 Grinnz i guess the event idea isn't the worst
05:00 preaction it depends on who wants to be informed about the events. if it's the consuming code, then yeah, it'll need to be some API the consumer has access to
05:00 preaction if it's just the emitter, then an argument to the emit() method would work fine
05:00 Grinnz i'm assuming the emitter would be what would either warn or log the error
05:01 Grinnz so a sub passed to that could work
05:24 Grinnz meh.. i dunno
05:25 Grinnz seems too awkward as an argument to every emit call
05:25 Grinnz esp with args
05:33 marcus oh sweet http://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=168d5805e4c08bed7b95d351bf097cff7c07dd65
05:33 Grinnz it's about damn time
05:34 marcus ON CONFLICT DO NOTHING/CRY
05:40 preaction the default could be sub { warn $@ }
05:41 Grinnz i think i like the event idea better, then it can be handled uniformly by the consuming class
05:45 melo joined #mojo
05:53 Grinnz well i need to go to bed but here's my completely untested and undocumented idea https://github.com/preaction/Beam-Emitter/compare/master...Grinnz:safe_emitter
05:53 Grinnz i don't know what happened with the makefile and stuff, i just ran dzil test
05:53 Grinnz lol
06:06 melo1 joined #mojo
06:11 bramirez joined #mojo
06:15 preaction they're dzil-generated files, so every time dzil is invoked, they get created
06:16 preaction /updated whichever
06:17 bpmedley_ joined #mojo
06:29 fhelmber_ joined #mojo
06:42 polettix joined #mojo
06:45 dod joined #mojo
06:51 dod joined #mojo
06:56 kaare joined #mojo
07:00 kaare_ joined #mojo
07:10 fhelmber_ joined #mojo
07:14 trone joined #mojo
07:19 ryozi joined #mojo
07:53 hshong joined #mojo
08:03 marcus hmm
08:03 marcus I've been thinking, Test::Mojo would probably be really nice for writing health checks for Nagios/Zabbix and such.
08:06 pete joined #mojo
08:06 pete Is Mojolicious::Plugin::Database recommended?
08:06 pete Do I get `free` reconnects when using it?
08:09 Shaeto joined #mojo
08:09 absolut_todd joined #mojo
08:15 dod joined #mojo
08:19 Vandal31341 joined #mojo
08:20 mishanti1 marcus: There was someone in here talking about that the other day.
08:21 pink_mist pete: I don't think it is, and I don't think you do ... but I may be wrong ... Mojo::Pg and Mojo::mysql are the ones I hear recommended most of the time, depending on what database you have.
08:22 pete Thanks, /me looks
08:22 pink_mist I don't know that those will give you free reconnects either, however
08:23 pete It looks like perhaps not
08:23 pete Does anything? Have I just imagined them in Catalyst?
08:24 pete Oh, there's a DBD::mysql attribute
08:49 mattastrophe joined #mojo
08:49 murre joined #mojo
08:49 jkramer joined #mojo
08:49 jkramer Ahoy
08:50 jkramer I have a weird problem and can't figure out what's wrong. :( https://dpaste.de/p6qA
08:51 jkramer Same goes for any URL I tried. I also ran netcat -l -p 5000 and tried to fetch http://127.0.0.1:5000/, but it doesn't even connect
08:51 caveman_ joined #mojo
08:51 Jonis joined #mojo
08:52 jkramer Just updated to the latest mojo from cpan (6.10)
08:52 jkramer Didn't help
08:52 pete Could be user-agent sniffing on Google's side
08:53 jkramer I only picked google because everything else didn't work either. Also it doesn't even connect apparently
08:54 jkramer wget/curl can fetch the same URLs without any problems on the same machine
08:58 jkramer Ah f*ck, stupid me
08:58 jkramer Nevermind, I screwed up :D
08:59 jkramer It's an async call, so I had to start the event loop :) Mojo::IOLoop->start
08:59 jkramer Anyway, the 404 is very confusing
09:01 pink_mist buu: you have a friend in thinking :P
09:29 romel i noticed that async code based on Promises with Mojo backend doesn't work inside Minion tasks. when i switch from Search::Elasticsearch::Async to blocking Search::Elasticsearch, everything works fine.
09:31 romel if i put 'Mojo::IOLoop->start unless Mojo::IOLoop->is_running;' inside helper's code which is being started by Minion job, it works but worker processes stay running after the job is finished
09:38 bramirez joined #mojo
09:54 jkramer left #mojo
09:56 sven joined #mojo
09:57 sven hey
09:59 sven i am about to migrate my project from catalyst to mojolicious
09:59 nicomen good for you ;)
09:59 sven not sure yet :)
10:00 sven it seems like system() behaves a bit different under mojo, it seems like child processes inherit tcp listeners and block port 3000 from then on
10:00 nicomen what are you doing with system() ?
10:00 sven start some background jobs
10:01 sven some of them should continue even if the server goes down, others are just temporary
10:01 nicomen http://mojolicio.us/perldoc/Minion <-- like that?
10:01 sven anyway, they should not inherit any open files
10:02 sven no, they are not workers, really just programs i want to start from my perl app
10:03 nicomen ok
10:03 sven ex. run htpass to let users change their passwords or something like that
10:03 sven *htpasswd
10:03 nicomen I'm not sure that system() itself behaves differently
10:04 nicomen what do you mean by block port 3000?
10:04 sven already tried IPC::open3, but its the same problem
10:04 nicomen sure it's not the entire process that doesn't fork?
10:04 sven my dev server listens on port 3000, if i run a cmd by "system()" it inherits the open files and therefor also listens on port 3000
10:04 berov joined #mojo
10:05 sven well yes, system() itself forks according to perldoc, so maybe its not system which behaves different, but fork
10:05 bd sven: anyevent::util::fork_call ?
10:05 bd or run_cmd
10:06 bd i think there was even a mojolicious plugin for one
10:07 sven yes, there are at least 2 plugins for that, but first i want to understand whats happening :)
10:07 nicomen http://search.cpan.org/~jberger/Mojo-IOLoop-ForkCall-0.16/lib/Mojolicious/Plugin/ForkCall.pm ?
10:07 bd btw you cant mix fork_call and run_cmd
10:07 bd had to learn that the hard way yesterday ;)
10:10 sven i can't find any references to fork_call or run_cmd in mojo
10:10 sven does mojo use anyevent in the background?
10:16 kaare_ joined #mojo
10:30 go|dfish sven: no. fork_call is provided by a plugin. nicomen already linked to it. http://metacpan.org/pod/Mojolicious::Plugin::ForkCall
10:37 mattastrophe joined #mojo
10:43 sven i already saw that, but it seems a bit odd to fork twice to run system() first you fork to exit all mojo ioloop things and then system() forks another time
10:53 Shaeto left #mojo
11:07 neilhwatson joined #mojo
11:22 batman sven: why do you care? isn't it nice that someone has bothered to make a solution that works and you don't have to think about?
11:23 batman sven: that code has gone through quite a process to make it actually work.
11:23 sven well, it makes me wonder what else is different to vanilla perl if even simple things like system or `` won't work as expected
11:24 batman same goes for Mojo::IOLoop::ReadWriteFork (it still has some issues)
11:24 sven i for sure can change my code, but if i use modules from cpan, i cannot
11:24 batman sven: it is vanilla perl.
11:26 bramirez joined #mojo
11:28 batman sven: so... mojolicious does not tamper with any of the fork, system, ... calls. it's just perl. and it's unix behavior for a child to inherit the parent filehandles
11:32 sven thats true for unix but i thought perl closes filehandles before a system()
11:32 sven let me see why i worked before :)
11:33 mattastrophe joined #mojo
11:33 batman hm... maybe you're right.
11:33 batman if so, then it's the same under mojo
11:33 sven http://pastebin.com/3810Vhy8
11:33 Repaster Repasted text from sven: http://fpaste.org/219814/08483214/
11:34 sven there is a open socket for perl, but none in the second system() which uses the shells pid
11:35 batman sven: never ever paste.
11:35 batman ah. sorry
11:35 batman haha! my irc client inlined the paste :(
11:35 sven :)
11:35 nicomen loool
11:35 batman hm... looks awful :P
11:36 caveman_ joined #mojo
11:36 dp_ joined #mojo
11:40 sven hmm, maybe mojo changes some socket parameters... perldoc system mentions you should enable autoflush on all open filehandles
11:43 batman sven: i can't see that perl close any filehandles when calling system()... i might have to clean my glasses though :/
11:43 batman (using strace)
11:44 DaTa maybe sh is closing filehandles
11:44 batman DaTa: sh..?
11:44 purl sh is still listed in top or Silent Hill or Hitachi's SuperH or shell
11:45 batman DaTa: the shell is not invoked, unless you have shell meta characters in your command
11:45 DaTa lsof -p, space is such a character right?
11:46 * batman out.
11:46 batman i'm more confusing to myself and others than helpful :(
11:49 sven i assume FD_CLOEXEC is the key here
11:52 sven Mojo/IOLoop/Server.pm:  local $^F = 1023;
11:53 sven so it should be find if i set $^F back to 2 before any forks, systems, etc...
11:53 trone joined #mojo
11:54 bobkare sven: CLOEXEC is set when the handle is opened, not when exec is run
11:54 batman sven: i don't get that... isn't it localized?
11:54 mattastrophe joined #mojo
11:57 jberger sven: yes your problem is FD_CLOEXEC
11:57 coolo bobkare: that's O_CLOEXEC. sven is taking about FD_CLOEXEC which is used in fcntl and not in open
11:58 jberger romel: Minion doesn't start the event loop in the worker, so everything you are experiencing is expected
11:58 jberger pete: you are looking for DBIx::Connector
12:00 jberger marcus: re upsert \o/
12:28 romel jberger: got it. thanks
12:34 Kripton joined #mojo
12:39 romel jberger: i end up with the following construction which works but i'm not sure it looks well http://paste.scsys.co.uk/477290
12:43 jberger romel: one of the nice things about $delay->wait is that it only stops the loop if it had to start it
12:44 kwa joined #mojo
12:44 jberger I would almost say that if you know you are starting the loop, just unconditionally start it
12:45 jberger in my view, that's more clear about your intentions
12:45 ajr_ joined #mojo
12:45 jberger as to the rest of it, I know very little about Futures/Promises so I'll defer to someone else
12:48 jberger I've actually just started using elasticsearch at $work and I've just been using a Mojo::UA to make HTTP JSON queries
12:48 jberger but I'm sure the S::ES stuff provides some useful sugar that I'm missing out on
12:54 marcus and yells to the cook with the arms with his arms open wide / oh send me more fish, put it down on my side
12:55 * jberger wonders if marcus is losing it?
12:55 jberger https://www.youtube.com/watch?v=IhJQp-q1Y1s
13:01 marcus jberger https://www.youtube.com/watch?v=4uPZIG5BHD4
13:07 zivester joined #mojo
13:07 jberger I think I would more generally associate Bowie with tempire on first glance
13:07 * jberger suspect the stardust
13:09 marcus jberger: I have a very eclectic music taste.
13:09 marcus everything from death metal to japan pop
13:09 marcus and japan pop metal https://www.youtube.com/watch?v=WIKqgE4BwAY
13:12 Grinnz why did i know thats what you linked
13:15 * jberger responds with https://www.youtube.com/watch?v=rW6M8D41ZWU
13:16 jberger marcus: wow, that's a thing
13:16 Adurah €https://www.youtube.com/watch?v=blpe_sGnnP4
13:20 * jberger thinks every day should start with yatta actually
13:21 jberger one of those songs that can't fail to make you smile
13:22 AirDisa joined #mojo
13:27 gryphon joined #mojo
13:37 Kripton joined #mojo
13:40 asarch joined #mojo
14:08 ZoffixWork joined #mojo
14:10 AirDisa_ joined #mojo
14:29 caveman_ joined #mojo
14:35 zackiv31 joined #mojo
14:42 Grinnz_ https://groups.google.com/forum/#!topic/mojolicious/F2K-tAVy6L0
14:42 Grinnz_ http://th07.deviantart.net/fs71/PRE/f/2013/219/2/9/oh_god_why_in_hd_by_lemmino-d61t8ou.png
14:47 Kripton joined #mojo
14:51 jberger this was recently linked in #p5p if people missed it
14:51 jberger http://www.pagerduty.com/blog/the-discovery-of-apache-zookeepers-poison-packet/
14:52 jberger quite a thing
14:53 Grinnz_ heh
14:57 disputin joined #mojo
15:00 disputin joined #mojo
15:35 jb360 joined #mojo
15:41 sh4 joined #mojo
16:07 mattastrophe joined #mojo
16:24 polettix joined #mojo
16:30 ajr_ joined #mojo
16:37 dvinciguerra joined #mojo
16:43 kaare joined #mojo
17:08 mattastrophe joined #mojo
17:25 ajr_ joined #mojo
17:52 ajr_ joined #mojo
17:52 dave *sigh* ... it seems the upgrade I did to mongod causes the mongod perl driver to report invalid utf8 in the database, rendering some documents inaccessable
17:53 Grinnz_ encoding is hard!
17:53 dave sri already has a good rep with me as a developer, so I'm hoping his Mango driver will help
17:53 dave yes it is :(
17:53 Grinnz_ mango is no longer supported by sri
17:53 dave The problem I'm finding is that, given an arbitrary string, unless you know the encoding in advance you can't interpret it
17:54 Grinnz_ yes, that's the general idea.
17:54 dave and I know he doesn't support mango ... it's a pure perl driver so I can fix it if I have to
17:54 dave but he did write it...his style is everywhere on it and I'm counting on that
17:55 dave So how do you deal with encoding? The case I'm thinking of is when you get a string and you -don'
17:55 dave t know the encoding
17:55 dave so you assume "utf-8" because...reasons
17:55 Grinnz_ you should know where you get it from, and that way know what encoding it should be sent to you in
17:56 g3ar joined #mojo
17:56 dave hah
17:56 Grinnz_ for example, in mysql you would set the connection charset to UTF-8 and then expect all data received in UTF-78
17:56 Grinnz_ 8 *
17:56 dave you don't deal with 50k media files from 20 musicians
17:56 Grinnz_ the charset of the actual data doesn't matter. the database should be able to encode it to what you need
17:57 dave ancient mp3 taggers have placed all manner of cruft in the tags
17:57 dave wait
17:57 Grinnz_ then you should find out if the MP3 tag specification requires an encoding
17:57 dave the charset doesn't matter?
17:57 Grinnz_ it matters when you input the data, and when you retrieve the data
17:57 dave right
17:57 Grinnz_ what the database does in between doesn't matter
17:58 dave so I get this arbitrary binary string from the mp3 file
17:58 dave and I assume it's utf-8 because I have no choice
17:58 Grinnz_ don't assume it's UTF-8 unless it actually is.
17:58 dave how can I do that?
17:58 hernan604 you can try to guess it
17:58 Grinnz_ you can use a module to see if it's valid UTF-8, as a start
17:59 dave and if it's invalid? in some cases this data is a filename :/
17:59 Grinnz_ then it's not UTF-8
17:59 Grinnz_ https://metacpan.org/pod/distribution/Unicode-UTF8/lib/Unicode/UTF8.pod one module you can use to check
17:59 dave I have the checking part down :D
17:59 dave it's the guessing part
17:59 hernan604 https://metacpan.org/search?q=encoding+guess&amp;size=50
18:00 Grinnz_ if it's not UTF-8 then it's likely some form of latin1
18:00 hernan604 ^^ i agree
18:00 hernan604 you can also test https://github.com/chardet/chardet (i just found it out)
18:01 Grinnz_ for example: iso-8859-1
18:01 dave nooo not python! ;)
18:02 dave seriously though, thanks for the pointers...I'll need to use one of these detectors it seems
18:03 ZoffixWork joined #mojo
18:03 ZoffixWork sri, were you joking about this (unsorted methods in sauce are bugs) :)  : http://irclog.perlgeek.de/mojo/search/?nick=sri&amp;q=%22would+be+right%22
18:03 Grinnz_ he was not
18:03 ZoffixWork hehe
18:04 ZoffixWork Would it mess up git blame to make such changes?
18:04 ZoffixWork (i.e. sort the methods in the code)
18:04 Grinnz_ probably
18:05 Grinnz_ but i don't think that's widely used in mojo anyway
18:05 hernan604 dave: usually these encoder guessing require you to name 2 encodings you think are correct
18:05 dave yer kidding right?
18:05 hernan604 i said usually
18:05 hernan604 i have not tested them all
18:06 Grinnz_ it's pretty unlikely you'll get any encoding other than the two i mentioned, unless MP3 tags have a specific required encoding (in which case your job would be easier)
18:06 dave my problem is I can't really trust myself to test since iso-8859-1 is all I really know
18:06 hernan604 yes its usually utf8 or iso-8859-1
18:06 dave I have some japanese imports
18:06 Grinnz_ not in utf-8??
18:06 dave there's some japanese encoding which really screws with utf-8, can't remember where I came across that
18:07 dave also some Brazilian and Cuban jazz has some really weird characters in the tags
18:07 Grinnz_ ah, it may be Shift-JIS
18:07 dave THAT'S it
18:09 Grinnz_ dave: according to this, there should be a field specifying the encoding: http://forums.mp3tag.de/index.php?showtopic=5941
18:09 dave I tried that quite a while ago, that tag has incorrect data sometimes
18:10 Grinnz_ :|
18:10 dave yeah
18:10 dave hey I had successfully gotten everything to "valid" utf-8 (by perl's standards) before this upgrade
18:10 dave then I stored that
18:10 dave and before the upgrade, I could retreive it all
18:11 dave maybe I shouldn't all this an upgrade :/
18:11 dave *call
18:12 dave can't we just go back to ascii? *wince*
18:13 ZoffixWork Hell naw! :D
18:19 chansen dave: you can use Unicode::UTF8's fallback if you have mixed data, $string = Unicode::UTF8::decode_utf8($octets, sub { $_[0] })
18:19 dave won't that fail on invalid utf8 data?
18:20 mattastrophe joined #mojo
18:20 polettix joined #mojo
18:20 chansen no, it will decode i'll formed UTF-8 sequences as ISO-8859-1
18:27 Grinnz_ ZoffixWork: don't forget to reorder the method docs too :D
18:32 amon joined #mojo
18:35 ZoffixWork good call
18:36 buu Speaking of things I'm sure I missed.. how do you find the pid for the hypnotoad manager process?
18:37 ZoffixWork it's in the hypnotoad.pid file in that dir where you launched it
18:37 buu uh
18:37 buu I don't seem to have one of those
18:40 ZoffixWork Are you sure your hypnotoad manager is still alive?
18:42 buu yep
18:43 buu I even know what pid it is
18:43 buu From other methods
18:44 ZoffixWork *shrug*
18:44 Grinnz_ are you setting the pid_file in hypnotoad config? that would be the only reason you wouldnt have one
18:45 Grinnz_ not where you launched it, bu in the application base dir
18:46 ZoffixWork oh
18:47 buu I'm doing neither!
18:47 buu And I'm in the base dir
18:48 ZoffixWork I know what it is!
18:48 ZoffixWork Solar Flares!!
18:52 buu I'm in pwd=app dir
18:52 buu hypnotoad script/my_app
18:53 ZoffixWork what about hypnotoad -f script/my_app ?
18:54 buu oh
18:54 buu That says its in script/myapp.pid
18:54 buu One mystery down.
19:02 buu Next mystery, where is it hiding the log files
19:03 Grinnz_ make a directory called log/
19:03 Grinnz_ and it will hide them there
19:03 buu oh
19:03 buu log, not logs
19:03 buu its big, its heavy, etc.
19:05 buu I guess its time to learn mojo logging
19:14 mattastrophe joined #mojo
19:25 ZoffixWork Well, this is weird. Recall my websocket app that weren't sending ->send() right away? And I fixed it?
19:26 ZoffixWork Ran it today, now the same problem is there. It waits until the end before sending me messages. Here's the delay code: http://fpaste.scsys.co.uk/477357 and I get both messages only after 3 second (the sleep)
19:26 Grinnz_ yes, it's supposed to
19:26 Grinnz_ a delay specifically doesn't run until the control goes back to the loop
19:26 Grinnz_ that's why you put the code that's supposed to run after, in the next delay step
19:26 ZoffixWork But this code was working fine last night!
19:26 ZoffixWork Yeah, that's what I did. The sleep is in the second step
19:26 Grinnz_ oh, -both- messages
19:27 jberger don't immediately call the callback!
19:27 Grinnz_ right, $c->send("blah", $d->begin);
19:27 jberger $c->send('logging in', $d->begin)
19:27 jberger right
19:27 Grinnz_ let that method call it for you when its done
19:29 ZoffixWork Oh, OK. I get it now.
19:29 ZoffixWork jberger++ Grinnz_++
19:39 ToApolytoXaos joined #mojo
20:11 gorfel joined #mojo
20:15 mattastrophe joined #mojo
20:31 _dave_ joined #mojo
20:31 ZoffixWork joined #mojo
20:39 dod joined #mojo
20:41 dod joined #mojo
20:55 punter joined #mojo
21:20 mattastrophe joined #mojo
21:25 zackiv31 joined #mojo
21:41 ajr_ If $p->cname = "AD", why does return $self->redirect_to('edit', id => $partner->company_nm  ); not generate a URL ending in "edit/AD" ?
21:42 ajr_ s/partner->company_nm/p->cname/
21:42 ajr_ I was trying to de-clutter
21:47 nicomen ajr_: how does the route look like?
21:53 ajr_ edit/:id
21:54 mattastrophe joined #mojo
21:55 ajr_ I'm trying to create the URL to match that
21:59 Grinnz_ what does it return?
21:59 Grinnz_ i -think- that should work but i don't know much about how the url_for logic works
22:00 Grinnz_ also, did you name that route 'edit'?
22:02 dvinciguerra joined #mojo
22:03 ajr_ No, I'm trying to convert code written for another framework, which has a method called "edit"
22:03 ajr_ could that be a cause of problems?
22:06 ajr_ BTW, pretty as the error diagnostics are, it's awkward not being able to cut-and-paste easily (e.g. to here).
22:07 ajr_ Sorry, Grinnz, in answer to 17:59, "Page not found..yet!"
22:08 jberger ajr_: url_for takes a route name
22:08 ajr_ I can make it work by entering the URL  manually, but I want to generate that
22:08 jberger if you just want to programmatically make a path like that do something like
22:09 jberger my $url = Mojo::URL->new; push @{$url->path->parts}, 'edit', $partner->company->name;
22:10 ajr_ And then render_fill('edit') ?
22:11 jberger what is render_fill?
22:11 jabberwok render_file ?
22:11 ajr_ Sorry, legacy code. I meant redirect_to
22:12 zackiv31 joined #mojo
22:12 jberger redirect_to($url) then?
22:15 ajr_ Would redirect_to("edit/$name") work (assuming $name contains the desired string)?
22:16 jberger yes, but lets reexamine the problem
22:16 jberger you have a route that is defined like $r->any('/edit/:id')
22:16 jberger if you give that a name, then you can use it like you initially wanted
22:17 jberger $r->any('/edit/:id')->to(...)->name('edit_by_id');
22:17 jberger then $c->redirect_to(edit_by_id => id => $id);
22:21 ajr_ All this redirection is getting me lost. Perhaps if I rephrase the larger problem, my mistakes will be clear?
22:26 ajr_ There's a page that adds records to a file. At the end of that page, I want to transfer to another, "edit", page, that will display the record just entered, which can be identified by the unique name. A route has been defined with the pattern edit/:id, but the generated URL doesn't match that
22:26 ajr_ (because there's nothing after "edit")
22:27 ajr_ I could redefine the route, but then how is the identifier to be forwarded?
22:28 sven left #mojo
22:28 jberger http://pastie.org/10178709
22:28 jberger ajr_: I think I understand completely
22:29 jberger now is when I try to break you of the notion of thinking of routes as urls and thinking of routes as names
22:29 jberger yes, you CAN do $c->redirect_to("/edit/$id")
22:30 jberger but if you name the edit route, you can do $c->redirect_to('edit route name here', id => $id);
22:30 jberger and the nice thing then is, if that url ever changes, you don't have to go back and change all your code
22:30 jberger route by name, not by absolute path
22:30 Grinnz_ (unless you decide you don't like that name)
22:30 jberger I usually have descriptive names
22:31 ajr_ Thanks, jberger. That may be part of the problem; a subtle variation in the underlying assumptions of the 2 frameworks.
22:31 jberger 'create_new_lab_order'
22:31 Grinnz_ i have a coworker that regularly commits like 500 variable renames along with his actual changes =_=
22:31 jberger Grinnz_: obfuscation?
22:31 purl rumour has it obfuscation is the inevitable result of power
22:31 Grinnz_ no... indecision :P
22:31 jberger botsnack
22:31 purl :)
22:33 jberger ajr_: what is the fundamental assumption you are coming from?
22:33 jberger ajr_: I'm not saying that you can't do redirect_to a raw url
22:33 jberger but to do it the way you originally asked, you do it by route name
22:35 ajr_ Personally, ignorance. I don't know the original framework, and I'm new to Mojo.
22:35 jberger are you using Lite or Full?
22:35 ajr_ Full.
22:36 ajr_ The site is far too large for Lite.
22:36 jberger so on the route where you define the '/edit/:id' route, add ->name('edit_by_id') to the end of the creation
22:36 jberger or just edit if you prefer
22:37 jberger then $self->redirect_to('edit', id => $partner->company_nm  ); (from your original post) will work as you expect
22:37 jberger (or 'edit' --> 'edit_by_id' depending on which name you use)
22:39 jberger see this: http://mojolicio.us/perldoc/Mojolicious/Guides/Routing#Reversibility
22:39 jberger ajr_: you have read through the Guides in order, right ??
22:40 ajr_ Yes, and frankly found them confusing.
22:40 jberger they are densely packed, but we agonize over every word
22:40 jberger you can't just skim (as many people do)
22:42 ajr_ I appreciate the effort that has gone into the preparation; it was clearly a lot, but I think I must be missing some background (or foundation).
22:43 jberger what has you confuse?
22:43 jberger d
22:46 ajr_ Perhaps I should try to answer that offline, and mail you. A good answer will take time to prepare, and clog up the channel.
22:47 jberger you are welcome to ask, though, I really believe that if you have a basic understanding of HTTP and HTML and clear your head, get a beer and curl up with the Guides in the order seen here http://mojolicio.us/perldoc
22:48 jberger that you will come away with most of your questions answered
22:49 jberger (don't skip the Tutorial! though it is focused on ::Lite, you need the knowledge it contains)
22:49 * Grinnz_ wonders if adding more non-Lite examples to the tutorial would be worthwhile now that it's a separate document
22:49 jberger Lite is just a miniscule sugar syntax layer over Full
22:50 jberger Grinnz_: Full examples are just too hard to keep concise
22:50 jberger that's part of the reason that Lite exists
22:50 Grinnz_ jberger: not full examples; just examples of the syntax you'd use in a non-Lite app
22:51 jberger but without the boilerplate around it, you get the questions like "what is $self" or "where do I call $r methods"
22:51 jberger that's why there is an entire Growing Guide
22:51 jberger I get why you want that, and in concept it makes sense, but in practice, I'm not so sure
22:51 Grinnz_ right, the problem is in a lot of cases people don't actually start with a Lite app, which could lead them to skip both of those, and thus skip a lot of important knowledge
22:52 ajr_ The Mojo documents are a bit like the Unix man pages; comprehensive but slightly abstract definitions that need copious examples to illustrate them.
22:52 jberger Grinnz_: thus the reason we renamed the ::Lite documentation to ::Tutorial
22:52 Grinnz_ jberger: yeah that helps.
22:52 jberger ajr_: correct me if I'm wrong, but I believe there are copious examples included :-P
22:53 Grinnz_ jberger: it's still quite brazenly a ::Lite tutorial though, that's what i'm getting at
22:53 purl i think getting is one thing, but when setting, i want to avoid the type constraint checking
22:53 jberger ajr_: if you notice things that are too abstract, perhaps mention them (politely please) and we can see if there are ways to improve the doc
22:53 jberger Grinnz_: sure, but just try hitting someone with a Full app when starting
22:53 Grinnz_ purl: wtf?
22:53 purl i haven't a clue, grinnz_
22:53 Grinnz_ jberger: i started that way, i did fine
22:54 Grinnz_ jberger: it's really not that hard a starting point for people who are used to modules
22:54 Grinnz_ well, classes specifically
22:54 Grinnz_ if you don't understand $self and all that... yeah that's a problem
22:54 jberger hmmmm, Mojolicious::Guides::StartingWithFullApps?
22:54 ajr_ It's not obvious to a noob whether one is looking at an example or a definition in many cases.
22:54 jberger I don't know if sri will like two entry points
22:55 Grinnz_ yeah i dunno
22:55 jberger ajr_: sorry I don't follow
22:55 jberger what would a definition look like?
22:56 jberger things that look like code are typically examples
22:56 ajr_ Taking "stash" as a case:
22:56 ajr_ my $hash = $c->stash;
22:56 ajr_ my $foo  = $c->stash('foo');
22:56 ajr_ $c       = $c->stash({foo => 'bar'});
22:57 ajr_ $c       = $c->stash(foo => 'bar');
22:57 Grinnz_ those are examples how the method is used
22:57 jberger each line is an example
22:58 jberger one thing that you may not be used to is the chainable setters
22:58 ajr_ But what is the effect of each, and which terms are "reserved" words, and which are just examples of names?
22:58 mattastrophe joined #mojo
22:59 jberger the first gives you the entire stash hash
22:59 jberger the second gets you one value out of the hash
22:59 jberger the latter two are setters
22:59 jberger setters return the invocant for chaining
22:59 Grinnz_ ajr_: the variable names are meant to try to indicate that; this is method documentation though, not a guide
23:00 jberger Grinnz_  http://mojolicio.us/perldoc/Mojolicious/Guides/Growing#Model-View-Controller
23:00 jberger does it look like the ASCII art text is borked to you?
23:00 ajr_ A comment on the line to explain the purpose?
23:00 Grinnz_ ajr_: i could see that being helpful, sri would want it to be consistent across docs though
23:01 Grinnz_ jberger: yeah
23:01 jberger ajr_: in many places that is actually done, I think in the example you are pointing at, it was assumed that it was easy to extract the usage from the semantics of the names involved
23:01 Grinnz_ jberger: looks right on metacpan though
23:01 jberger Grinnz_: odd
23:01 jberger unless it changed since the last release
23:02 Grinnz_ jberger: the pod rendering on mojolicio.us appears to be collapsing the starting spaces
23:02 jberger mojolicio.us is synced with master
23:02 jberger Grinnz_: but shouldn't there be | characters leading?
23:02 Grinnz_ jberger: nope
23:03 Grinnz_ in the source there are 2 spaces before Input and 11 spaces before the +
23:04 Grinnz_ github renders it correctly too
23:04 jberger oh, yeah, I see it
23:05 jberger sorry, it was rendered so wrong that I was misunderstanding what it was suppoesd to look like correctly at first
23:05 Grinnz_ yeah i thought so too at first lol
23:08 jberger hunh, does it locally too
23:08 jberger perl -Mojo -E 'plugin "PODRenderer"; app->start' daemon
23:09 jberger I wonder if the underlying renderer changed
23:10 jberger oh! https://github.com/kraih/mojo/commit/8b9f7e48953d8203fbf30e75ffc481fafcbf8324
23:12 ajr_ There's a problem with technical documentation, (actually all forms of instruction). Writers who are unconsciously competent in a topic, (e.g. the developers of a package),  can no longer realise how much or what the uninitiated don't know.
23:12 ajr_ Building on a foundation that isn't there, doesn't create sound edifices.
23:14 jberger ajr_: actually, that block you are quoting is here: http://mojolicio.us/perldoc/Mojolicious/Controller#stash
23:14 jberger class documentation is reference only
23:14 jberger by the time you are reading those, you should have gotten your foundation in the Guides
23:14 jberger http://mojolicio.us/perldoc/Mojolicious/Guides/Tutorial#Stash-and-templates
23:16 mishanti1 When running tests for a mojo-app, what is the best way to serve mojo app its configuration (instead of having it load it from a file somewhere)?
23:17 ajr_ I'll go back to the Tutorial for another run through.
23:18 jberger mishanti1: you need to change the configuration for the tests?
23:18 jberger wow another doc bug?
23:18 jberger http://mojolicio.us/perldoc/Mojolicious/Controller#stash
23:18 jberger ^^ misses reserved stash key "inline"
23:18 jberger maybe that doesn't count
23:19 jberger sri, is inline a reserved stash key?
23:20 mishanti1 jberger: correct. Need to make sure some values are/are not there.
23:23 jberger Grinnz_ / Oleg: https://github.com/kraih/mojo/pull/781
23:30 jberger https://github.com/kraih/mojo/issues/795
23:33 Grinnz heh
23:35 Grinnz mishanti1, you can modify the config hash directly: https://metacpan.org/pod/Mojo#config
23:36 Grinnz e.g. $t->app->config(...)
23:37 jberger Grinnz: yep
23:38 jberger its just as stashy value
23:38 jberger https://metacpan.org/source/SRI/Mojolicious-6.10/lib/Mojo.pm#L24
23:39 jberger then again, you can do other fun things like local *MyAPP::config = sub { ... } too
23:39 Grinnz that seems a bit silly in this case :P
23:40 jberger mocking for testing is a common practice
23:41 jberger and the app that I'm writing is a port of a Mason app that used Config::JSON, so I overload config in MyApp.pm
23:42 Grinnz heh
23:42 Grinnz test files: where we can break encapsulation like crazy and not feel bad about it
23:46 jberger Grinnz: exactly!
23:46 jberger actually, mocking public api isn't breaking encapsulation
23:46 jberger by strict definitions
23:47 Grinnz :P
23:48 jberger fwiw, I'm working on a patch that finds the minimum indent level to drop
23:48 jberger but I have to go have dinner now, so I'll come back to it later
23:48 jberger o/
23:49 Grinnz pssh, dinner. just get an IV installed at your computer desk.

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