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

IRC log for #mojo, 2015-08-06

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

All times shown according to UTC.

Time Nick Message
00:48 cpan_mojo Mojolicious-Plugin-BasicAuthPlus-0.10.2 by BLR https://metacpan.org/release/BLR/Mojolicious-Plugin-BasicAuthPlus-0.10.2
01:53 genio So, when dealing with an API a la Salesforce, you run a query() and then if there are more responses, it's indicated by a value returned in the JSON.  You then use a queryMore() method with a URL supplied in the JSON of the query().  If yet more exist, you'll use this queryMore() JSON response to know what the next url is.  rinse, repeat until done to get all results.  I'm having a hard time conceptualizing how to make this non-blocking as it ...
01:53 genio ... has to wait on the next one to continue, etc.
01:54 Grinnz genio, sounds like a perfect use for delay steps
01:55 Grinnz https://metacpan.org/pod/Mojo::IOLoop#delay
01:59 Grinnz in a mojo app use the delay helper: https://metacpan.org/pod/Mojolicious::Guides::Cookbook#Synchronizing-events
01:59 Grinnz otherwise just use Mojo::IOLoop->delay
02:02 * genio is still reading and thinking
02:04 Grinnz i have a few several-step delays for using APIs in my bot plugins if you want an example: https://github.com/Grinnz/maverick/blob/master/lib/Bot/Maverick/Plugin/Translate.pm#L105
02:06 thowe joined #mojo
02:08 genio Thanks, that's pretty helpful for dealing with my auth token expiration issue as well
02:08 genio Grinnz++
02:08 Grinnz yeah, microsoft API is the only one so far that i'm using that has an expiring token
02:14 davido___ joined #mojo
02:41 kaare_ joined #mojo
02:43 noganex joined #mojo
04:29 davido__ joined #mojo
04:42 dotandimet joined #mojo
05:58 jdporter joined #mojo
05:59 jdporter aloha
05:59 jdporter got a prob, hope someone can help
06:07 inokenty-w joined #mojo
06:14 arpadszasz joined #mojo
06:27 juikuen joined #mojo
06:45 trone joined #mojo
07:13 Vandal joined #mojo
07:14 AndrewIsh joined #mojo
07:18 eseyman joined #mojo
07:46 marcusr ask to ask?
07:46 * marcusr smacks purl
07:46 * marcusr cries
08:01 jkramer left #mojo
08:23 lb smack your bot up
08:26 irqq joined #mojo
08:44 sopanshewale joined #mojo
08:44 sopanshewale Hello Mojolicious
08:45 sopanshewale I am trying to use HAML template with Mojo
08:46 Zoffix \o
08:46 sopanshewale % layout 'default' expands to <> layout 'default'
08:46 sh4 joined #mojo
08:46 sopanshewale how to handle % here.. i do not want that to expand
08:48 Zoffix sopanshewale, change it to HAML's idea of what code is?
08:48 Zoffix Seems to be '=' instead of '%', based on a cursory reading of Text::Haml's docs
08:48 Zoffix How are you parsing that template?
08:49 KindOne joined #mojo
08:50 sopanshewale % layout 'default';
08:50 sopanshewale % title 'Welcome';
08:50 sopanshewale %h2 <%= $msg %>
08:50 sopanshewale this gets expanded to:
08:50 sopanshewale <>% layout &#39;default&#39;;</>
08:51 sopanshewale <>% title &#39;Welcome&#39;;</>
08:51 sopanshewale <h2>&lt;%= $msg %&gt;</h2>
08:51 Zoffix In the future, please use a pastebin. Easier to read
08:51 sopanshewale % is from Mojo
08:52 Zoffix sopanshewale, right. layout 'default'; is just Perl code. % in HAML is a shortcut for rendering a tag. So change your '%' to whatever HAML's idea of "perl code" is; my suspicion is that it's '=' character
08:55 sopanshewale nope... does not work :(
08:55 Zoffix sopanshewale, like this, probably: http://fpaste.scsys.co.uk/496626
08:55 Zoffix sopanshewale, what "doesn't work" mean? You get errors? Wrong rendering?
08:57 sopanshewale sorry.. = default expands default layout but in browser its printing as source code
08:58 Zoffix OK, so that's a step forward. You now just need to tell it not to encode HTML entities.
08:59 sopanshewale thx... one step ahead :)
09:01 Zoffix sopanshewale, change = to !=
09:02 Zoffix http://haml.info/docs/yardoc/file.REFERENCE.html#unescaping_html
09:04 sopanshewale no change
09:04 sopanshewale let me spend time at HAML side instead of Mojo
09:04 sopanshewale thx...
09:05 Zoffix ¯\_(ツ)_/¯
09:10 jontaylor joined #mojo
09:20 Adura joined #mojo
09:26 batman sopanshewale: are you using https://metacpan.org/pod/MojoX::Renderer::Haml ?
10:01 arthas joined #mojo
10:06 sopanshewale I am using $self->plugin('haml_renderer');
10:06 stephen joined #mojo
10:07 sopanshewale something described here http://showmetheco.de/articles/2010/2/haml-renderer-for-mojolicious.html
10:16 Vandal joined #mojo
10:21 Zoffix sopanshewale, this works fine for me: http://fpaste.scsys.co.uk/496639
10:21 Zoffix sopanshewale, err, this: http://fpaste.scsys.co.uk/496640
10:22 Zoffix I get boldened 'Test' in the browser
10:22 sopanshewale you mean - the Perl variables described by % expanded as par expectations
10:23 Zoffix sopanshewale, there are no Perl variables described by %
10:23 Zoffix sopanshewale, % is part of EP. You're using HAML now, not EP, so you don't use %; use HAML's syntax
10:23 batman sopanshewale: why do you use haml anyway, if you don't know how to write it...? :/
10:25 batman Zoffix: % is part of haml as well...
10:26 batman http://haml.info/tutorial.html
10:26 Zoffix batman, yeah. I meant using % to get variables
10:26 Zoffix i.e. <%= content %> needs to be written differently in HAML
10:27 batman right
10:29 sopanshewale yes
11:07 eitz joined #mojo
11:20 mattastrophe joined #mojo
11:33 sawtooth joined #mojo
11:48 ladnaV joined #mojo
12:01 absolut_todd joined #mojo
13:02 sh4 joined #mojo
13:23 trone joined #mojo
13:30 hernan605 joined #mojo
13:31 kaare_ joined #mojo
13:33 jb360 joined #mojo
13:59 gryphon joined #mojo
14:24 lluad joined #mojo
14:44 njlg joined #mojo
15:04 sopanshewale joined #mojo
15:33 disputin joined #mojo
15:59 tencendur joined #mojo
16:03 tencendur I'm parsing a kml (xml) file with Mojo::DOM, and it seems that capital letters within tags get changed to lower case (even with $dom->xml(1);) Can I prevent this?
16:04 Grinnz_ do you set xml(1) before or after parsing the xml?
16:04 tencendur before
16:05 jontaylor joined #mojo
16:05 tencendur immediately after   my $dom = Mojo::DOM->new( $content );
16:06 Grinnz_ that would be after parsing :)
16:06 Grinnz_ try Mojo::DOM->new->xml(1)->parse($content)
16:57 tencendur thx. That solved several issues! The one remaining is oddball. It has to do with a tag's text field being identified as "text, or "cdata". Is there a way to determine what 'type" a text field is parsed as?
16:57 Grinnz_ i believe so...
16:58 Grinnz_ there is a "type" method for Mojo::DOM objects
16:58 tencendur ah, yes.
17:00 * Grinnz_ wonders if a ->dom_xml or ->xml method for Mojo::Message might be useful, to parse it with an XML-enabled dom
17:19 tencendur I can't seem to get the "type" of the text field.  If I  "for my $e ($dom->find('Placemark > description')->each) { say $e->type; }", it returns "description" instead of one of the "usual" types.
17:24 njlg joined #mojo
17:24 Grinnz tencendur, that's because those nodes are "description" tags
17:25 Grinnz at least... thats my guess
17:28 hernan605 joined #mojo
17:33 hernan605 joined #mojo
17:34 hernan605 joined #mojo
17:34 PryMar56 joined #mojo
17:54 amon joined #mojo
17:57 njlg joined #mojo
18:21 njlg joined #mojo
18:22 tencendur SO how can I get\set the "type" of a text field? It appears the text field is a 3 element array (with the "type" field is the first element, the actual "text" is the second, and I'm not sure what the 3rd element is).
18:41 njlg joined #mojo
19:13 marty joined #mojo
19:33 hernan605 joined #mojo
19:52 genio Man, I'm good at screwing myself up and getting confused in callback hell
19:52 mst delays and/or futures are your friend
19:53 jberger genio: yeah, it takes a while to learn to trust in delays (or futures)
19:53 mst but trying to do it yourself is http://trout.me.uk/ds.jpg
20:00 genio If there's a way to confuse things and mess them up, rest assured that I'll find it!
20:17 njlg joined #mojo
20:20 Craftsmanship joined #mojo
20:22 Craftsmanship can I just create controllers in a Plugin and route there from there
20:22 Craftsmanship or is that some kind of bad manners?
20:24 jberger you can create routes there
20:24 jberger I suppose you could create the controller classes there too
20:24 jberger its not inherently evil, but I'm curious what the use-case is
20:25 jberger (note that the docs even show how to mount entire apps in a plugin)
20:25 Craftsmanship i'm writing a twitter plugin, and i need to get the postbacks
20:25 jberger yeah, that seems fine
20:25 Craftsmanship but the app-proper needs some kind of a "twitter and then" bridge(?)
20:25 jberger you should probably accept a path or route instance for mounting at
20:28 Craftsmanship oh, that's better manners than calling $app->route myself
20:28 genio Dealing with an API that could be used within or outside of a Mojo app, I'm attempting to figure out the non-blocking bits and confusing myself.  https://gist.github.com/genio/07042b30dc9df4a8e7da  I've been changing things left and right, so please forgive some terrible naming, etc.  (a) am I doing anything correctly.  (b) how in the world would I step out the ->query() method with a callback?  (c) man, I suck!
20:29 Craftsmanship the lib you're using blocks?
20:29 Grinnz_ delays are a learning process :)
20:30 genio yea, I've been shooting myself in the foot for about an hour and am learning that I know/understand nothing.
20:30 Craftsmanship "start stuff in the first one, and get a bunch of 'here, wiat for this' tickets"
20:30 Grinnz_ your first delay looks correct
20:31 Grinnz_ but that ->wait is going to run the event loop and block
20:31 Grinnz_ I'm not sure how you're intending to run these methods
20:32 Craftsmanship so, you want to get back a list of found records by id, and then request all of them at once?
20:32 jberger Grinnz_: I always recommend having the wait method in place
20:32 Grinnz_ yeah, it should be there, i'm just not sure where the event loop is running in this program
20:33 trone joined #mojo
20:33 jberger genio: that first method doesn't have an error handler attached to the delay
20:33 jberger that's usually a good idea too
20:34 jberger anyway, sorry but that's too long to debug visually
20:35 Grinnz_ genio: the biggest thing to remember is that if the program "die"s in a delay step, it's going to be in the event loop, so that delay's "error" event needs to be caught somewhere if you want better handling than just a warning in the log
20:36 Grinnz_ i like to return delays so the calling context can specify how to deal with errors; jberger likes to assign an error handler that passes the error to the next step
20:37 jberger correction, not to the next step, out to the caller via the callback
20:37 Grinnz_ right
20:39 Dave how would I do DBD::Pg->execute_array() in Mojo:Pg in a non-blocking way? :D
20:39 Grinnz_ hmm what does execute_array do?
20:40 Dave it's a means to process multiple values for the same sql
20:40 Dave so for example many INSERTS at once
20:40 Dave you make the sql once and pass arrays of the insert values you want done
20:41 Grinnz_ ah... yeah for that you can't really do anything better than ->query repeated for each set of values
20:41 Grinnz_ but statements are cached so it's probably not going to be slow or anything
20:41 Dave I could construct an array of callbacks ... hm
20:42 Grinnz_ you also might be able to specify a multiple insert using arrays in postgres... my postgres-fu isn't good enough to know how to do that though :)
20:42 Dave well "insert" is already a plpgsql idea because I
20:42 Dave am really upserting
20:43 Craftsmanship do you need to wait for it?
20:43 Dave yes, but in a non-blocking way
20:43 genio Grinnz_: You've asked about how it would be run.  from within a Mojo app I am doing something akin to   $c->render_later; $sf->query('...', sub { ... $c->render(...) });    When not in a Mojo app, I guess the goal is that the caller starts an IOLoop, calling the method with a callback similar to within the Mojo app.
20:43 Craftsmanship i mean, for the page to work
20:43 Dave I don't have to, it'd be nice to tell the user "your data is uploaded"
20:43 Craftsmanship you could just stuff the results in a queue, and let something else do the processing
20:43 jberger Dave: that's "steps" in delay terms
20:43 Grinnz_ genio: ah ok. makes sense. in a mojo app, the delay helper would be useful to recommend though
20:43 Dave yes jberger, exactly my thinking
20:43 Craftsmanship "is uploaded" and "has been procssed" can be different things
20:44 jberger its "then" in futures if you want
20:44 Grinnz_ genio: it takes care of render_later and exception handling
20:44 Dave yeah well the jquery widget I'm using for file uploads only takes one response JSON
20:44 Dave so I want to respond "it's all done" rather than "we have your data, but it may disappear if there's an error"
20:45 Craftsmanship it would disappear anyway
20:45 Craftsmanship you know, if the data was ruined
20:45 Dave right
20:46 Dave so isn't it better to say "it's all uploaded"?
20:46 Grinnz_ something something partial success
20:46 Grinnz_ (hope you're using a transaction :D)
20:56 tencendur after I've extracted a txt field and munged it, how do I stuff it back into place in thedom?
20:57 Grinnz_ if you still have the parent node, you can update its contents
20:58 meshl joined #mojo
20:58 Grinnz_ the text part itself is technically a node... so it might be easiest to get that directly
20:58 tencendur would that be $dom->replace?
20:59 Grinnz_ if you have the text node itself, yea you could use replace on it
21:00 tencendur I tried     $e->[0] = $newcontent;  but that didn't update the main\original $dom object
21:00 Grinnz_ otherwise you could use ->content on the parent node
21:01 Grinnz_ (the surrounding tag)
21:04 irqq joined #mojo
21:21 cfedde <GroupId>YesPrinting&copyingCLE</GroupId> becomes <GroupId>YesPrinting�ingCLE</GroupId>  Is that a bug or a feature?
21:22 Grinnz_ how did you enter that?
21:23 Grinnz_ as XML, &copy is a HTML-encoded copyright symbol
21:23 cfedde $dom->command->content(join '',@part); then return $dom->to_string; where one of the @part is a bunch of  push @part, "<$k>$v</$k>"
21:23 Grinnz_ you might want to run your text through Mojo::Util::xml_escape
21:24 concerned joined #mojo
21:24 cfedde yeah.
21:24 Grinnz_ (content expects raw XML)
21:25 cfedde yeah.  I thought that &copy; was the entity not &copy
21:26 Grinnz_ it is, but i guess the browser thinks &copy is good enough
21:26 cfedde no browser in here yet.
21:27 cfedde just mojo. But yeah.
21:27 Grinnz_ html_unescape, then
21:27 cfedde yuo!
21:27 cfedde s/o/p/
21:47 njlg joined #mojo
22:04 irqq joined #mojo
22:05 Grinnz_ hmm
22:06 Grinnz_ exceptions in DESTROY get ignored now, don't they
22:06 Grinnz_ that might explain this strangeness
22:09 Grinnz_ buh... nope it's not even throwing an exception
22:16 cfedde Turns out I had already solved my problem but the version with the fix had not been shipped to the server where this ETL was running.
22:36 Grinnz_ heh
23:59 jontaylor joined #mojo

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