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

IRC log for #mojo, 2015-07-28

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

All times shown according to UTC.

Time Nick Message
00:11 buu send an email to it?
00:19 damaya :)
00:19 damaya Not that it's a valid email, but that it's valid to RFC spec.
00:23 Adura joined #mojo
00:30 bpmedley damaya: https://metacpan.org/pod/Email::Valid <-- I like this one
00:32 damaya Awesome, thanks bpmedley :D
00:37 melch joined #mojo
01:05 sseche joined #mojo
01:32 sseche hi everybody
01:34 sseche i'm having a hard time trying to figure out why my option selected from my form is not working, i know is cause of @options but can't figure why
01:34 sseche i will paste the code
01:35 sseche http://paste.debian.net/hidden/3644f4a2/
01:35 sseche any thoughts ?
01:40 bpmedley my $options = \@options;        <-- Try something like that.
01:41 bpmedley The "\" gives you a reference.
01:42 sseche already tried, still got the Global error for @options
01:45 bpmedley You'll need to use $options like an array ref in the template.
01:45 bpmedley $options->[...]  and the \@options changes.
01:45 bpmedley *change
01:45 Grinnz my $options = @options; # this sets $options to the size of @options
01:46 Grinnz just do options => \@options, directly, no need for the intermediate variable
01:46 Grinnz then in the template, $options will be an array reference
01:47 Grinnz you have to keep in mind that the variables the template creates are completely separate from the variables you have above
01:47 Grinnz if you did foobar => \@options, you would get $foobar in the template
01:52 sseche mmm
01:52 sseche Grinnz i understand what you are telling me or i think so
01:52 sseche and I already tried it in my desesperate time of trying everything without thinking :P
01:53 sseche but still got Global error on @options
01:53 sseche the problem is when i render /
01:53 Grinnz did you change the template to use it as an array ref, like bpmedley said?
01:54 Grinnz $options[0][0] tries to use @options, which does not exist in the template
01:54 sseche but on http://perldoc.perl.org/perlreftut.html, says that Instead of $a[1]->[2] , we can write $a[1][2] ; it means the same thing.
01:55 sseche i was basing my thinking on that
01:55 Grinnz the arrow is only optional in between
01:55 Grinnz because in between, it can only be a reference
01:55 Grinnz but directly after the variable, it is the difference between using it as a reference, or not
01:56 Grinnz in other words, $arr[1]->[2] and $arr[1][2] are the same, but $arr->[1][2] is not
01:56 sseche and the template doesn't know about @option
01:56 sseche i think i understand now
01:57 sseche i will make the necessary changes and see
01:57 sseche thanks for the help :)
02:01 Onigiri joined #mojo
02:01 Dave joined #mojo
02:01 jb360 joined #mojo
02:01 robinsmidsrod joined #mojo
02:01 BinGOs joined #mojo
02:01 McA joined #mojo
02:01 atom joined #mojo
02:01 bpmedley joined #mojo
02:01 buu joined #mojo
02:01 garu joined #mojo
02:01 eduardow joined #mojo
02:01 mishanti1 joined #mojo
02:01 caeles joined #mojo
02:01 skaji joined #mojo
02:01 tinita joined #mojo
02:01 bzero joined #mojo
02:01 preaction joined #mojo
02:01 lb joined #mojo
02:01 allison joined #mojo
02:01 upasana_ joined #mojo
02:01 Phil21 joined #mojo
02:01 ssm joined #mojo
02:01 salparadise joined #mojo
02:01 Zx3 joined #mojo
02:01 stephan48 joined #mojo
02:01 bayashi joined #mojo
02:01 mgrimes joined #mojo
02:01 bjoernfan joined #mojo
02:01 al joined #mojo
02:01 Kundun joined #mojo
02:01 abracadaniel joined #mojo
02:01 Quai joined #mojo
02:01 cfedde joined #mojo
02:01 saki joined #mojo
02:01 dustinm joined #mojo
02:01 kmx joined #mojo
02:01 D4RK-PH0ENiX joined #mojo
02:01 sri joined #mojo
02:01 tempire joined #mojo
02:01 mtths joined #mojo
02:01 oetiker joined #mojo
02:01 yt7fms joined #mojo
02:01 rwp joined #mojo
02:01 jnbek joined #mojo
02:01 phillipadsmith joined #mojo
02:01 absolut_todd joined #mojo
02:01 elik joined #mojo
02:01 da5id joined #mojo
02:01 diegok joined #mojo
02:01 spicyjack joined #mojo
02:01 btyler_ joined #mojo
02:01 ashleyde1 joined #mojo
02:01 meredith_ joined #mojo
02:01 sivoais joined #mojo
02:01 Rallias joined #mojo
02:01 DaTa joined #mojo
02:01 Foxcool joined #mojo
02:01 cosimo joined #mojo
02:01 stokachu joined #mojo
02:01 davido__ joined #mojo
02:01 stuart_ joined #mojo
02:02 odc joined #mojo
02:13 sseche bpmedley, Grinnz, options => \@options and $options->[...] made the magic
02:15 sseche but on rendering / i get warnings cause of Use of uninitialized value in string from $searchInRepo
02:15 sseche which is normal cause that value is after the post
02:24 sseche thanks for the help! really aprecciate and i learn the $variable->[...] stuff
02:24 sseche didn't know it
02:32 zivester joined #mojo
02:46 damaya joined #mojo
02:49 melch So, vim colors everything under __DATA__  a single color, does anyone have a decent setup they could share?
02:49 melch so it is easier to read the html
02:53 noganex_ joined #mojo
03:15 buu Where is the best place to find documentation on implementing a mojo plugin?
03:17 buu Gah
03:25 McA2 joined #mojo
03:31 atom I have my controller here:  http://paste.scsys.co.uk/495712
03:31 atom and my template:  http://paste.scsys.co.uk/495713
03:32 atom and this error:  http://paste.scsys.co.uk/495714
03:33 atom I have this working in other examples... but wtf.. I can't get that variable to render no matter how I try
03:35 atom actually here is the correct error... http://paste.scsys.co.uk/495715
03:48 buu I had this conversation like a month ago in here
03:48 atom you had this problem?
03:49 atom when I copy the code from a working controller and template I get the error in this controller... I'm going to try and get rid of the underscore in the controller name... I got no other ideas
03:50 atom I'm starting to wonder if I had a stroke
03:56 shadowpaste "atom" at 217.168.150.38 pasted "Template ./templates/service/infov1/index.html.ep" (12 lines) at http://paste.scsys.co.uk/495719
03:56 shadowpaste "atom" at 217.168.150.38 pasted "Controller" (12 lines) at http://paste.scsys.co.uk/495720
03:57 atom right?  is there any reason this would give me an error: Global symbol "$role" requires explicit package name at template service/btsinfov1/index.html.ep line 1.
03:58 melo joined #mojo
04:01 preaction atom: they're the same file
04:01 atom no, they are not
04:02 preaction yes. they are.
04:04 atom I have ./lib/App/Controller/InfoV1.pm and templates/InfoV1/index.html.ep ... is that what you mean?
04:04 preaction look at your pastes!
04:04 atom what I shadowpasted was another more simple test
04:05 preaction one says "template". it is not a template. it is the same as the paste that says "Controller"
04:05 preaction so i'm assuming you meant to show us a template, but you did not, so i don't want to try to answer a question when the parameters could change
04:07 atom dang nabbit!
04:07 atom I figured it out
04:09 atom so... the controller is InfoV1.pm, in app.pm it needs to be routed as ->get('/infov1')->to('InfoV1#index');
04:09 kaare joined #mojo
04:09 atom and the template directory needs to be named "info_v1", not "infov1"
04:10 atom thanks @preaction, hope I didn't waste ur time... thanks for looking :)
04:20 buu preaction: Are the hooks documented anywhere?
04:22 buu oh
04:22 buu They're in Mojolicious.pm
04:23 preaction i believe they're all over the place, based on which object is emitting the events?
04:23 preaction the Rendering guide I was just looking at had a few
04:30 buu Yeah, they're mentioned in a bunch of places, but Mojolicious.pm has a list
04:31 buu Ok next question, how does mojo decide it's outputting html?
04:31 buu I'm looking at the data in before_render hook and then after_render
04:54 preaction format stash value would be my guess
05:00 jberger buu: http://mojolicio.us/perldoc/Mojolicious/Plugin/DefaultHelpers#accepts
05:12 buu um
05:13 buu 172   my ($output, $format) = $app->renderer->render($self, $args);
05:15 buu ahh, 110   $options->{format} = $stash->{format} || $self->default_format;
05:15 buu hrm
05:25 jzawodn_ joined #mojo
05:38 davido__ joined #mojo
05:40 marty joined #mojo
05:58 buu It's actually checked inside the Renderer::render sub
05:58 buu And sadly isn't abstracted out
06:11 damaya joined #mojo
06:16 Grinnz sooo i finally got migrations working for this stupid thing https://github.com/Grinnz/Mojo-SQLite
06:17 Grinnz tl;dr: SQLite really does not like running multiple statements at once
06:17 Grinnz at least not with prepare
06:20 Grinnz that said, it's probably still more reliable than mysql migrations ;D
06:22 Nemix joined #mojo
06:29 Vandal joined #mojo
06:35 zivester joined #mojo
06:37 arpadszasz joined #mojo
06:38 elik joined #mojo
06:55 AndrewIsh joined #mojo
07:04 trone joined #mojo
07:07 Grinnz huh, where's cpan_mojo got to
07:07 Grinnz well, https://metacpan.org/release/DBOOK/Mojo-SQLite-0.001
07:19 eseyman joined #mojo
07:24 dotandimet joined #mojo
07:28 d4rkie joined #mojo
07:39 ans joined #mojo
08:00 kaare joined #mojo
08:02 ans1 joined #mojo
08:06 absolut_todd joined #mojo
08:18 gatitskiy joined #mojo
08:19 berov joined #mojo
08:20 punter joined #mojo
08:40 inokenty joined #mojo
08:42 jontaylor joined #mojo
08:53 jzawodn joined #mojo
09:04 stephen joined #mojo
09:47 jzawodn joined #mojo
09:48 gatitskiy joined #mojo
10:21 gatitskiy joined #mojo
10:23 stuart_ oo thats handy, Im was just about to start looking at using a SQLite with Mojo.
10:24 stuart_ shame the code uses SQL string and not DBIx::Class
10:38 batman Grinnz: that is very cool :)
10:38 batman could you add support for a callback to query() ? I know it does support non-blocking, i just want a unified API
10:45 mattastrophe joined #mojo
10:53 Lee joined #mojo
11:00 frederico joined #mojo
11:31 dexteruk joined #mojo
12:03 gatitskiy joined #mojo
12:05 mattastrophe joined #mojo
12:08 D4RK-PH0ENiX joined #mojo
12:13 stephen joined #mojo
12:38 Onigiri joined #mojo
12:45 gatitskiy joined #mojo
12:46 ashimema :w
12:46 neilhwatson joined #mojo
12:52 ashimema joined #mojo
12:56 gatitskiy joined #mojo
13:03 zivester joined #mojo
13:04 hernan605 joined #mojo
13:08 icjs joined #mojo
13:24 gatitskiy joined #mojo
13:25 Grinnz batman, sure, i don't see that it could hurt, it will just call the callback before it returns..
13:27 batman Grinnz: cool!
13:27 batman remember to return $self instead of $res :)
13:33 sawtooth joined #mojo
13:36 gatitskiy joined #mojo
13:46 stryx` joined #mojo
14:08 ajr_ joined #mojo
14:18 * Grinnz_ wonders what group the JSON-pretty-sortby crowd came from
14:18 Grinnz_ (https://github.com/kraih/mojo/issues/822)
14:19 jberger given their similar level of english I'm guessing they know eachother
14:20 Grinnz_ i would have guessed that regardless...
14:20 genio I don't see that as a needed feature
14:21 Grinnz_ right, i wouldn't support it unless it was absolutely fitting with the current API, and i don't really see a way to do that off the top of my head
14:22 genio It doesn't exist in JSON::XS that I see either
14:22 Grinnz_ pretty print does
14:22 jberger genio: pretty printing does
14:22 Grinnz_ ive never used sort by, no idea about that...
14:22 inokenty joined #mojo
14:23 genio I was looking for sort by
14:23 jberger especially in a world of hash randomization, sorting hashes (especially by anything other that asciibetiically) is silly
14:23 Grinnz_ oh is that what it's doing? eesh
14:23 jberger I assume that's what they are asking for
14:24 jberger JSON::XS does sorting asciibetically
14:24 jberger if you ask for it
14:24 genio I need to go through the JSON::XS docs and submit a patch to get rid of all of the suggestions for   new JSON::XS
14:24 jberger hahahahahahha
14:24 jberger good luck with that
14:24 * jberger hides
14:25 genio oh, I just realized who maintains that module.  nevermind
14:25 Grinnz_ hehehe
14:27 Grinnz_ you'd have better luck with a doc patch for Cpanel::JSON::XS, there's a few instances there
14:27 Grinnz_ and it has a github issue tracker even ;)
15:19 PryMar56 joined #mojo
15:20 jontaylor joined #mojo
15:23 disputin joined #mojo
15:58 thowe So, I had a better grasp on this in Catalyst...  But Mojo is different enough that I suspect there may be a better way...
15:59 ajr_ joined #mojo
15:59 thowe If I have a method for, say, modifying a record in a Controller, and I have a form and whatever that routes to that method, great...
16:00 nicomen is there a question in there somewhere?
16:01 thowe But what if I have another route/page that modifies some other related thing that then also wants to make Changes to those records.  What's the best way to use reuse the method modifying those related records?  In other words, how to I only ever use that method to modify those records from anywhere in the code.
16:02 thowe Would I abstract out the editing portion from the route handler?
16:02 thowe Or use the UA?
16:04 thowe I guess I might use a private method in Catalyst and the route handler and everything else would use it...  I'm not sure why I'm confused by this.  Maybe I just always assume I'm not doig things the best way.
16:04 batman what is a record?
16:04 thowe a database row or whatever
16:04 batman then move all the logic to the model
16:05 thowe a product, or account, or whatever.  I would have a form for editing it.  but other places in the code that might edit it too.  I only want one bit of editing code, though.
16:06 batman it sounds like your controller is too thick and to tightly coupled to your backend
16:06 thowe batman, well, yeah, the logic is in the model, I guess I am more thinking about how the data gets to the method.  If I route to a page with a form, it goes to the form.  If I want some other process to edit it, it doesn't go to the form.
16:07 nicomen some people like to distinguish with get/post methods
16:07 nicomen others with the presence of data or not
16:07 batman i don't follow
16:07 nicomen others with totally different routes (/person/add, /person/edit, /person/form, /person/show etc.)
16:08 thowe But still, an additional abstracted model method might be what I am after to solve my particular problem.
16:08 batman browser => controller => validation => model => backend
16:09 thowe I tend to put validation in my controller, is there a better place above the model for that?
16:09 batman so the validation part converts the parameters from the browser to a hash of data i can pass on to the model
16:10 batman i always put validation (using $c->validation) in my controller
16:10 thowe I guess that's a cobination of some Controller stuff and some DBIC stuff for me
16:10 batman (but i might also have validation in my model)
16:12 thowe like with Mojolicious::Validator?  I haven't used that yet.  I think I should
16:12 thowe whatere do you like to put your validators?  in the controller?  In the startup?
16:12 batman http://mojolicio.us/perldoc/Mojolicious/Guides/Rendering#Form-validation
16:13 batman if you add more validation methods, you do it in startup()
16:13 batman but the actual validation is either in a helper or in an action
16:13 thowe so validation has access to params?
16:13 batman yeah
16:15 batman but the validation object doesn't have access to $c, which makes it a nice bridge between the controller and model imo
16:15 batman i used to be very tempted to pass on $c before, but it's not possible to even consider that if you use validation
16:16 batman you might be tempted to pass on the validation object though, hehe
16:16 batman i often just pass on $c->validation->output to the model, if the hash keys match (they often do in my case)
16:21 robinsmidsrod joined #mojo
16:30 ajr_ joined #mojo
16:52 jberger thowe: you might build a helper that bridges the gap between your controllers and your model
16:52 jberger that's pretty common practice
16:59 thowe hmm...
17:01 Grinnz_ batman: https://metacpan.org/pod/Mojo::SQLite::Database#query
17:04 thowe jberger, The helper idea is growing on me...
17:04 mattastrophe joined #mojo
17:17 inokenty joined #mojo
17:19 batman Grinnz_: nice. the doc doesn't say anything about returning $self though.
17:19 batman still, it works as expected :)
17:21 batman Grinnz_++
17:22 amon joined #mojo
17:36 thowe I need to create an entire group of hierarchically organized records.  I think I should just throw a chunk of JSON at my record creation thingamajig
17:36 thowe interestingly, thingamajig is apparently in my spell check database =|
17:45 meshl joined #mojo
17:46 sh4 joined #mojo
17:53 meshl joined #mojo
17:54 Grinnz_ batman: its same as Mojo::Pg doc, i dont think it actually needs to return $self, but it doesn't matter ;)
17:55 batman Grinnz_: it returns $self for chaining
17:56 Grinnz_ batman: Mojo::Pg doesn't... https://metacpan.org/source/Mojo::Pg::Database#L92
17:56 batman oh. i wonder why not :/
17:57 Grinnz_ chaining a non-blocking query in Mojo::Pg is not going to work well, maybe thats why
17:57 batman maybe
17:58 batman uhm... btw: i thought that was fixed?
17:58 Grinnz_ for blocking queries; you still can't queue up async queries
17:59 batman i think you can: https://metacpan.org/source/SRI/Mojo-Pg-2.07/Changes#L6
18:00 Grinnz_ sequential; not concurrent :)
18:01 trone joined #mojo
18:05 batman can you give me an example? not sure if i follow
18:06 batman oh
18:06 Grinnz_ https://metacpan.org/pod/Mojo::Pg#DESCRIPTION the example at the end of the section; you can't use the same $db for the second query, unless you wait to add it until the first completes
18:08 batman Grinnz_: what about this? https://github.com/kraih/mojo-pg/blob/cf742aed51dff2233708832735c3b2209d2edc79/t/database.t#L39
18:08 Grinnz_ batman: each of those retrieves a new $pg->db
18:08 batman of course
18:09 batman sorry. i will shut up now :(
18:09 batman my head is so full of osx now i can't focus :(
18:12 Grinnz_ it was a fun debugging session for sri :)
18:15 ZoffixWork joined #mojo
18:38 dod joined #mojo
18:41 dod joined #mojo
19:32 lluad joined #mojo
19:40 genio Well, I went ahead and created that bug report and patch for JSON::XS anyway for the documentation.  Only because I was helping a coworker with a question and he was referring to that documentation and actually had  my $json = new JSON::XS; in his code
19:40 genio odds...
19:40 Grinnz_ you emailed it to him?
19:41 Grinnz_ (he isnt going to acknowledge it otherwise)
19:41 genio no, it's in rt.cpan.org.  it looked as if he'd been closing tickets there, so I took a shot
19:41 ajr_ joined #mojo
19:42 genio We'll see
19:42 Grinnz_ oh? is it the apocalypse already?
19:42 Grinnz_ he has an auto-responder that replies to RT tickets with a generic rant
19:43 Grinnz_ it looks like he's just blindly closed all RT tickets, lol
19:43 genio yep.  I just looked again and you're right.  it's an autoresponder rant that closes them
19:43 genio shit
19:43 Grinnz_ it doesn't close them, he must have done that manually
19:44 Grinnz_ and of course he still hasn't bothered to set his bugtracker in meta
19:44 Grinnz_ but closing a bunch of RT tickets, thats no problem
19:45 genio We'll see what happens.  I may not be good enough to help people fix/update Perl stuff, but I try to submit lots of doc changes (any little bit helps).
19:51 mattastrophe joined #mojo
20:09 gatitskiy joined #mojo
20:24 melo joined #mojo
20:47 meshl joined #mojo
21:06 Dave If you are using Mojo::Pg to do a query, how do you bind a parameter to a specific type?
21:06 Grinnz_ you probably have to use DBD::Pg directly for that
21:06 Dave arh ok
21:06 Grinnz_ fortunately that's easy: $pg->db->dbh->dostuffwithdbdpg
21:07 Grinnz_ if you want to do it for an async query though... good luck ;)
21:07 Dave :/
21:07 Dave is there some reason he didn't support binding parameters in an async query?
21:08 Grinnz_ it's uncommon usage, maybe it would be possible to support (similar to how json parameters are supported)
21:09 Dave is DBD::Pg supposed to figure out what you mean by examining the SQL?
21:09 Grinnz_ for bind type? DBD::Pg figures it out from the type of variable, i believe
21:10 Grinnz_ or for output, from what it gets from pg
21:10 Dave yeah well, it didn't successfully figure out that I was passing it an integer.
21:11 Grinnz_ i dunno, i just use DBD::mysql most of the time, which assumes all input are strings, which "works well enough" most of the time
21:12 Dave I have a workaround coded for this case, but when I get to location coordinates ... that will be fun
21:12 Grinnz_ what's the problem you're running into that it's passing as a string? pg doesn't like it?
21:12 Dave I have a key that's an integer
21:12 Grinnz_ you could probably do a cast in pg or something...
21:12 Grinnz_ not ideal i know
21:12 Dave hm
21:12 Dave that would be cleaner...I just don't know how to do that :) I'll go look
21:13 Grinnz_ ::integer (or similar)
21:13 Dave for a stored procedure right? I thought if I said "arg INT" it would auto cast it for some reason
21:13 Grinnz_ dunno
21:13 Grinnz_ mysql essentially does, but i think pg is more strict
21:15 Dave ::integer worked ... select my_upsert(?::integer, ?)
21:16 Grinnz_ cool
21:16 Dave thx :D
21:16 Grinnz_ if it was going to support bind types, it would probably be something like the third line https://metacpan.org/pod/Mojo::Pg::Database#query but with something else in the hashref indicating the type
21:17 Grinnz_ setting bind types restricts you to a certain DBD::Pg syntax unfortunately :/
21:17 Dave well for simple stuff, casting works well
21:18 Grinnz_ i might have to look into something to support that in Mojo::SQLite, as a "type-lenient" database it has even more issues with bind types, hehe
21:18 Dave yeah I remember :/ I've written stuff to translate between SQLite and MySQL before
21:19 Dave that was not fun
21:19 Dave and I probably still don't have it quite right
21:19 Grinnz_ between SQLite and MySQL... man i don't envy that haha
21:19 Grinnz_ that's like converting between PHP and javascript
21:21 Dave DBD was really helpful with this, fortunately
21:21 Dave er DBI
21:27 jberger oh no! where's purl!
21:27 Grinnz_ ran away with cpan_mojo
21:27 jberger that dirty minx
21:46 melch joined #mojo
22:50 disputin joined #mojo
22:58 frederico joined #mojo
22:59 frederico joined #mojo
23:00 mattastrophe joined #mojo
23:01 mattastrophe joined #mojo

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