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

IRC log for #mojo, 2016-02-24

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

All times shown according to UTC.

Time Nick Message
00:07 Andreas2 joined #mojo
00:12 bf joined #mojo
00:20 bradjm \quit
00:20 bradjm whoops :p
00:50 asarch joined #mojo
00:50 bpmedley joined #mojo
01:13 bf joined #mojo
01:42 sri ok, robots are getting really creepy https://www.youtube.com/watch?v=rVlhMGQgDkY
01:48 bf joined #mojo
02:15 zivester joined #mojo
02:21 acamari joined #mojo
02:22 dabudabu Nice
02:49 bf joined #mojo
03:03 noganex_ joined #mojo
03:07 mcsnolte joined #mojo
03:37 bf joined #mojo
04:19 inokenty-w joined #mojo
04:42 melo joined #mojo
05:57 bf joined #mojo
06:27 bf joined #mojo
06:28 bf joined #mojo
07:05 dod joined #mojo
07:10 dod joined #mojo
07:29 bf joined #mojo
07:52 melo joined #mojo
08:09 melo1 joined #mojo
08:10 taichi joined #mojo
08:14 osfabibisi joined #mojo
08:17 AndrewIsh joined #mojo
08:20 Vandal joined #mojo
08:21 taichi joined #mojo
08:22 melo joined #mojo
08:23 taichi joined #mojo
08:25 trone joined #mojo
08:26 taichi joined #mojo
08:30 bf joined #mojo
08:48 lb the first real ai will scan youtube and see lots of robot-torture and decide humanity is a threat
08:50 mishanti1 It is probably for the better.
08:50 taichi joined #mojo
08:57 berov joined #mojo
08:59 taichi joined #mojo
09:31 bf joined #mojo
09:35 stephan48 lb: http://xkcd.com/1646/
10:27 arthas joined #mojo
10:29 arthas joined #mojo
10:32 bf joined #mojo
11:07 cpan_mojo Minion-5.01 by SRI https://metacpan.org/release/SRI/Minion-5.01
11:15 denny joined #mojo
11:15 denny I'm having trouble digging a file upload out of my request.  Or, quite possibly, my test is uploading the file incorrectly in the first place.  Help?  :)  http://pastebin.com/z8z4DXyE
11:19 sri oh my, this has already become a meme... stop bullying robots! https://pbs.twimg.com/tweet_video/Cb9kAYlWwAECBs4.mp4
11:20 CandyAngel Robots are people too
11:21 CandyAngel We are all guilty of the botpression
11:22 Adura That's just a filthy ARM robot.
11:22 melo joined #mojo
11:32 bf joined #mojo
11:33 taichi joined #mojo
11:36 taichi joined #mojo
11:38 sri jberger: any news on the web framework benchmark update? i don't want to miss the next round with the improvements ;p
11:40 taichi joined #mojo
11:45 trone joined #mojo
12:13 asarch joined #mojo
12:29 CandyAngel If I am have a class that creates an object to pass to another class (through an emitted event), but the other class needs to store extra information about the object, should I handle that in the objects class or have another class that wraps/delegates?
12:30 CandyAngel I feel the wrapping class with delegation makes the most sense..?
12:32 pink_mist wrapping sounds safer to me, you could probably just do it as a hashref though? { obj => $obj, additional_data => { data => 'point', }, }?
12:33 bf joined #mojo
12:37 CandyAngel The class that created it can also "remotely delete" it, so some tidying up needs to be done in that case
12:37 batman CandyAngel: why not just pass on extra data as \%extra ?
12:37 CandyAngel I think the wrapper would be best, because it can listen to update events to, which it needs to update the additional data on
12:38 CandyAngel I don't pass the exta data, the receiving class generates it when the object is created
12:47 bf joined #mojo
12:57 denny I'm having trouble digging a file upload out of my request.  Or, quite possibly, my test is simulating a file upload incorrectly in the first place.  Help?  :)  http://pastebin.com/z8z4DXyE
13:01 sri denny: use MOJO_USERAGENT_DEBUG=1
13:10 denny sri: and what am I looking for in there that wasn't in the other output?
13:11 denny oh wait, ignore that  :)
13:11 * denny finds an error in the middle of his errors
13:22 CandyAngel denny: And thus, progress was made? :)
13:34 kaare joined #mojo
13:36 taichi joined #mojo
13:45 neilhwatson joined #mojo
13:49 zivester joined #mojo
14:09 good_news_everyon joined #mojo
14:09 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/v2C5h
14:09 good_news_everyon mojo/master 26efcb9 Sebastian Riedel: fix a few small CGI bugs
14:09 good_news_everyon left #mojo
14:19 odc Hello guys! I have a Mango user here using CentOS who cannot resolve localhost from his mojo app. I remember seing people here who had the same issue. Do you remember what causes this?
14:20 ramortegui_ joined #mojo
14:20 Adura All that comes to mind is... did they install Net::DNS::Native?
14:21 odc hm i will ask him
14:23 sri why would Net::DNS::Native prevent localhost from getting resolved?
14:23 Adura On a technical level, I don't know, but you'd expect a default install to be able to resolve localhost.
14:24 sri no
14:25 sri out tests use 127.0.0.1 instead of localhost for good reasons
14:25 sri s/t/r/
14:25 odc but if he uses ping(1) on centos, localhost is resolved
14:25 odc why not perl/mojo ?
14:26 dotan joined #mojo
14:29 arthas joined #mojo
14:46 jb360 joined #mojo
14:47 taichi joined #mojo
15:00 mcsnolte joined #mojo
15:24 jacoby joined #mojo
15:38 Grinnz_ odc: does he have an ipv6 tunnel? on my machine "localhost" would try to resolve using ipv6 and fail because it couldnt be resolved via the tunnel, but using 127.0.0.1 works fine
15:39 batman joined #mojo
15:41 odc Grinnz, thanks. I will ask him but i don't think so.
15:42 odc i should have mentioned that he is using Mango with AnyEvent
15:42 odc but i'm not sure it changes anything
15:42 Grinnz_ (normally with IO::Socket::IP you would be able to force IPv4 with https://metacpan.org/pod/IO::Socket::IP#Family-INT but this isn't exposed via mojo)
15:43 odc interesting
15:43 zivester joined #mojo
16:11 arthas joined #mojo
16:12 jberger sri: I'm working on the FWBM stuff right now
16:12 jberger I get one new warning:
16:12 jberger Content encoding found in "text/plain;charset=UTF-8" where "text/plain" is acceptable.
16:12 jberger is it worth manually setting the header manually to send fewer bytes?
16:13 sri i suppose it is
16:16 jberger their tooling looks really nice now
16:26 jberger "This branch is 1782 commits behind TechEmpower:master"
16:32 bf joined #mojo
17:02 jberger https://github.com/TechEmpower/FrameworkBenchmarks/pull/1940
17:05 pink_mist 0_o Canary::Stability?
17:05 jberger EV
17:05 pink_mist oh
17:06 jberger because MLEHMANN
17:06 sri jberger: oh, the mojolicious version is still hardcoded :S
17:06 jberger ?
17:06 jberger https://github.com/TechEmpower/FrameworkBenchmarks/pull/1940/files#diff-b142e146fba59ff5d0e84aee3db5b181R154
17:06 jberger I just updated the cpanfile.snapshot
17:06 good_news_everyon joined #mojo
17:06 good_news_everyon [mojo] kraih tagged v6.48 at 2fb1491: https://git.io/v2W6L
17:06 good_news_everyon left #mojo
17:06 sri pull request is already outdated :(
17:06 jberger gah!
17:07 Grinnz_ -not- hardcoding it seems like a worse idea :P
17:07 jberger were there performance improvements in that one?
17:07 sri yes
17:08 good_news_everyon joined #mojo
17:08 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/v2W6g
17:08 good_news_everyon mojo/master 09d0ca1 Sebastian Riedel: bump version
17:08 good_news_everyon left #mojo
17:08 jberger then why did you poke me this morning?!
17:08 sri how am i supposed to know versions will always be hardcoded?
17:08 sri you made it sound like a temp solution earlier
17:09 jberger the cpanfile.snapshot is committed
17:09 jberger that's how carton works
17:10 sri and they make you use carton?
17:10 jberger remember that when I started this venture all of the perl demos were broken
17:10 jberger and so they all showed "failed" in red letters
17:11 jberger so I specifically used carton so that they wouldn't break out from under me
17:11 jberger I can remove the Carton architecture if we promise never to break Mojolicious
17:11 sri i'm out, don't like the tone of this coversation
17:11 jberger but since that's not gonna happen, I think its wise to use it
17:12 jberger sri: sorry, it does read bad
17:12 jberger I should have tossed a few :-P in there
17:12 PryMar56 joined #mojo
17:12 jberger I'm not upset
17:15 jberger "<jberger> then why did you poke me this morning?! :-P"
17:17 jberger sri: would you have me not use Carton?
17:18 vicash i am trying to monkey_patch a model function in a unit test. it isn't working. I am using Test::Mojo to load my app but I am monkey patching before that is called. Is that the correct way ?
17:19 jberger vicash: if you monkey patch a symbol before its package is loaded then loading the package replaces your monkey patch with the "original" symbol
17:20 vicash yes that is correct. i tried it and it works now. thanks.
17:20 jberger I even built a check for that into my recent Mock::MonkeyPatch to keep me from accidentally doing that (most of the time at least) https://metacpan.org/source/JBERGER/Mock-MonkeyPatch-0.03/lib/Mock/MonkeyPatch.pm#L44-45
17:22 vicash nice module.
17:24 jberger thanks
17:28 jberger hmmmm FWBM also offers Redis now
17:28 jberger maybe I should add a redis variant
17:31 * jberger waits for metacpan to index 6.48
17:33 bradjm joined #mojo
17:44 user_5132 joined #mojo
17:45 user_5132 $self->...   is there any variable I can use to check whether the request is POST or GET from any ['POST', 'GET']?
17:46 user_5132 I could check the headers or if there are parameters (GET), but..
17:46 jberger user_5132: $c->req->method
17:46 jberger http://mojolicious.org/perldoc/Mojo/Message/Request#method
17:46 user_5132 Thank you! very nice
17:47 jberger np
18:04 taichi joined #mojo
18:06 kes joined #mojo
18:29 bf joined #mojo
18:45 dod joined #mojo
18:46 dod joined #mojo
18:57 lluad joined #mojo
19:23 bf joined #mojo
19:34 jnm_theMailman joined #mojo
19:37 Mikey joined #mojo
19:38 jnm_theMailman I'm a Perl learner (not brand-new, but have been playing with it pretty regularly for a few months, mostly scripts and interactive CLI tools). I have a couple questions...
19:39 pink_mist ask away .. though maybe it'd be better to ask in a more general perl channel such as #perl on freenode?
19:39 pink_mist (though maybe your questions are fully mojo-related, in which case never mind :P)
19:39 jnm_theMailman @pink_mist Thanks! These are actually specific to Mojo. ;)
19:40 jnm_theMailman I'm trying to build a private journal/public blog, and I have some existing content -- unformatted HTML
19:40 jnm_theMailman I know Mojo can serve static content, but is there a way for me to read that into a template as <body>?
19:41 jnm_theMailman (I'm sure there is... I'm just not grokking it yet)
19:42 jberger jnm_theMailman: have you read the Guides?
19:42 jberger starting here: http://mojolicious.org/perldoc#TUTORIAL
19:43 jnm_theMailman jberger: I worked through the lite app guide, and have muddled about a good deal with Growing, yes.
19:43 pink_mist sounds like you might want to use a layout directive in the existing html files
19:43 jberger I'd expect that for your current question you'll learn a lot from the Rendering guide
19:48 jnm_theMailman pink_mist: I have a layout prepared, and I'm calling it lite app style: @@ file.html.ep has % layout 'mylayout', but I'm hung up on how to get an existing file into <%= content =>
19:49 pink_mist jnm_theMailman: you put the existing file in the template directory, name it appropriately, put the % layout directive at the top, and render it
19:51 jnm_theMailman pink_mist: In that scenario, I'd need to add my CSS to each existing file, yes? I think maybe a better way to explain what I hope to do is to read the contents of a given file in as a variable that can be expanded into <%= content %>.
19:53 pink_mist jnm_theMailman: no you'd do that in the layout
19:53 jnm_theMailman jberger: I've been trolling my way through all the docs for more hours than I care to admit. They're not quite getting me there; hoping for a more specific nudge from a friendly expert. ;)
19:54 pink_mist jnm_theMailman: if you put the % layout 'Foo' directive in the file that you render, it will be sucked into the <%= content %> part of the layout
20:08 jberger jnm_theMailman: where does the content come from?
20:09 jnm_theMailman jberger: It's an unformatted .html file under public in the Mojo lite app's directory.
20:09 jnm_theMailman I have @@ post.html.ep that refers to % layout 'landing-page', which has all my CSS and js in it.
20:09 jberger and then you slurp it in?
20:10 jberger files that are in public/ get served as static content directly
20:10 jnm_theMailman jberger: I looked at using Mojo::Asset::File to slurp it in, yes, but as I say, I'm relatively new at this. I enjoy using Perl a good deal, and this is a fantastic way for me to stretch beyond my current skill level.
20:11 Grinnz just use it as a template
20:11 jberger so let me see if I'm following, you have a file that you want to (1) read in to the server (2) wrap with some surrounding HTML (3) serve to the client
20:11 jberger is that correct?
20:13 jnm_theMailman jberger: Yessir. That's it. The existing file would be the content in <body><%= content %></body>
20:14 jberger can I suggest that you try doing it without layouts first
20:14 jberger read the content in with Mojo::Util::slurp
20:14 jberger then render it with ->render(text => "<body>$slurped</body>")
20:24 jnm_theMailman jberger: Ok, cool. And if I add ", layout = 'mylayout'", it adds the css. Sweet.
20:24 jnm_theMailman jberger: Some of the unicode renders differently with slurp than it does when rendering the static file directly, but I'll poke about and see what I can figure out.
20:25 jnm_theMailman jberger pink_mist Thanks a bunch, both of you.
20:25 Grinnz if you slurp a file manually you likely will need to decode it from UTF-8 as well
20:26 jnm_theMailman Grinnz: Can you point me in the right direction for reading about how to do that?
20:28 Grinnz https://metacpan.org/pod/Mojo::Util#decode
20:28 jnm_theMailman Grinnz: Thank you!
20:28 Grinnz I still think it would be much simpler to just use the file as a template, and the layout as a layout
20:30 jnm_theMailman Grinnz: You may well be correct. I'm iterating toward a blog and private journal. So I anticipate having a good deal of unformatted content I'd like to bring in. My thinking was that I'd need a template I could read each of those files into. But I may be attacking this from the wrong direction altogether. Open to suggestions.
20:31 Grinnz well at that point it would be better to store them in a database
20:31 jnm_theMailman This first effort was meant to be a way of figuring out how all the parts fit together.
20:32 Grinnz the template would be more what every instance should have in common
20:33 Grinnz then you just pass the content from the DB into a stash variable, and render the template.
20:35 jnm_theMailman Grinnz: Hmm, ok. That's a new horizon altogether, I'm afraid (databases). I'd been leaning toward not using one just because I feel like I've bitten off a big enough chunk without it. :D
20:35 Grinnz databases are the basis of dynamic content
20:36 Grinnz you can always start with something like redis or sqlite, easy to set up
20:36 * perlpilot notes that a filesystem is a "database" of sorts
20:37 Grinnz sort of, but an extremely inconvenient one
20:37 pink_mist wish I could run sql over it :P
20:37 jnm_theMailman Grinnz: For some definitions of inconvenient. ;)
20:37 Grinnz inconvenient to do anything complex with, and inconvenient to avoid attack vectors :P
20:37 Adura fuse plugin to sqlite.
20:38 pink_mist Adura: haha, excellent :P
20:38 Adura I'm not writing it.
20:38 pink_mist aww :P
20:38 cfedde the file system is exactly a database. One with keys being file names and values being the content. A kind of hierarchical associative memory if you will.
20:38 Adura Feel free to steal the idea.
20:38 jnm_theMailman everyone: I really appreciate the input. I'm off to look at DB options. Thanks again.
20:39 perlpilot jnm_theMailman: If you're going to use a real database, sqlite is a good one to try first.
20:39 Grinnz i would suggest Mojo::Redis2, Mojo::SQLite, or Mojo::Pg, depending on what you want to use; they all have pros and cons
20:40 jnm_theMailman Grinnz: I'm inclined to look at Pg...
20:40 Adura As you should be.
20:40 jnm_theMailman perlpilot: Can you flesh that out? Why's SQLite good to start with?
20:41 cfedde sqlite is simple and does most of what you want from an RDBMS.
20:41 perlpilot jnm_theMailman: sqlite gives you a single-file database without the need to setup any kind of server.
20:41 cfedde Except right joins.
20:41 Grinnz Redis has a server to run, but it's still no-setup. however it is a noSQL key-value store so it works differently from a relational database
20:42 Grinnz postgres has the most setup, but is the most advanced and capable
20:42 perlpilot jnm_theMailman: But ... if you're going to go ahead and setup postrgres ... just do that.   :-)
20:42 cfedde IN all the places where I used to consider a custom mysql db I now use sqlite.
20:42 Grinnz sqlite's downside is mostly just scalability and performance, comparatively
20:42 perlpilot cfedde: me too mostly.  (unless the database is "too big")
20:43 jnm_theMailman perlpilot: Oh, I'm not locked in on the idea. Just chewing on the options. I like the *idea* of full-text search from a Pg database, that's all.
20:43 Grinnz i wouldnt rely on any of those three for fulltext search honestly
20:43 jnm_theMailman And scalability's probably not an issue for my piddly little thing.
20:43 cfedde scalability of sqlite is pretty darn good. It big down side is concurrency. and real types, and the rest of sql. and. well and a lot of stuff. but still
20:44 Grinnz sqlite still is better at transactions than mysql which is kind of funny
20:44 perlpilot jnm_theMailman: if you use Pg, you'll probably never need another RDBMS.   (unless you're doing something highly specialized)
20:44 cfedde Grinnz++ yeah.
20:45 cfedde Pg is a darn good RDBMS. And probably as good as any for most things.
20:45 jnm_theMailman perlpilot: No offense to any recovering DBA's in the room, but I hope I never have to do anything that kind of highly specialized... >.>
20:45 sri Grinnz-- # Pg is a great choice for adding full-text search to a blog
20:45 cfedde the one thing that Pg won't do for you is sap all the money out of your budget. For that you need Oracle.
20:45 perlpilot heh
20:46 Floyd-ATC joined #mojo
20:47 cfedde Pg's down side has most to do with distribution and replication. Though that is much better now than it once was.
20:47 jberger I'm assuming Grinnz was thinking about ElasticSearch and the like
20:47 jberger but Pg does have some GIN stuff IIRC
20:47 sri ElasticSearch for a blog is insane
20:47 jberger it would certainly be overkill
20:47 cfedde Elastic search is pretty easy to setup and performs well given enough hardware.
20:47 cfedde it also clusters well.
20:48 perlpilot Surely the point of creating a blog is to learn new stuff and the blog is really a side-effect.
20:48 sri that's crwzy advice, he's building his first blog... and you tell him about elasticsearch clusters
20:48 cfedde heh
20:48 sri http://www.postgresql.org/docs/9.5/static/textsearch.html
20:50 cfedde a blog mostly needs a key value store. a simple File::DB is probably enough. Or even just a json document.
20:50 cfedde er DB::File even
20:50 cfedde or what ever perl calls the dbm thing these days.
20:50 preaction you could make a markdown file, and put a bit of yaml on top for metadata
20:50 Floyd-ATC write_chunk() barfs on a unicode character (\x{3bc}) but handles other special chars just fine (like æøå)
20:51 jberger Floyd-ATC: are you encoding first?
20:51 Floyd-ATC do I have to do some manual encoding or is the character simply too strange?
20:51 Floyd-ATC I don't do any explicit encoding/decoding but I'm unsure what Text::CSV_XS or Mojo::Mysql might be doing
20:52 jberger IIRC write_chunk doesn't do any encoding
20:52 Floyd-ATC my source data is a CSV file written by mysql (using "select into outfile")
20:52 jnm_theMailman Grinnz: decoded my slurp and that did the trick... thank you
20:53 Floyd-ATC I let Text::CSV_XS slurp and parse it, then do a $db->quote() using Mojo::mysql
20:53 sri jnm_theMailman: you might like the blog example included with Mojo::Pg https://github.com/kraih/mojo-pg/tree/master/examples/blog
20:54 sri i think other Mojo::* modules might have that example as well
20:54 jnm_theMailman sri: Thanks. I've been grepping a couple other projects (bootylite and contenticious, I think) for ideas, too.
20:55 jberger Floyd-ATC: wait, you are reading columnar data out of sql as csv, passing that to a csv parser and then passing that to DBI's quoting functions?
20:55 jberger that sounds ... odd
20:55 sri today is a strange day
20:55 Floyd-ATC I have exported the data from one server, then I'm importing it into another db using Mojo
20:56 jberger Floyd-ATC: mysqldump?
20:56 Floyd-ATC I'm actually working on that import feature in my web app
20:56 Floyd-ATC No, mysql has "select into outfile" with native support for csv
20:56 sri guess it would be fitting for me to watch the new x-files files on such a day
20:56 jberger oh, as an application feature
20:56 sri s/files/season/
20:56 Floyd-ATC yes, the web app needs to be able to import data from csv
20:57 jberger that's tough because you have to assume that the users exported their data correctly (and assuming they had it stored correctly)
20:57 jberger some will store unicode data without the mysql utf8 enabled
20:57 Floyd-ATC I know, I was actually surprised to see that norwegian chars and other accents didn't cause any problems
20:58 jberger anyway I don't think its a problem that I can hold in my head
20:58 Floyd-ATC but this one char has caused lots of problems in the past. It's the greek "mu" character but it exists as two different code points
20:58 jberger write lots of tests
20:58 Floyd-ATC one works "everywhere" and one works "nowhere". GUESS which one this is :-/
20:59 Floyd-ATC $VAR1 = { 'type' => "'Fiber, 9 \x{3bc}m, singlemode'" };
20:59 Floyd-ATC $self->write_chunk( $VAR1->{'type'} );
20:59 Floyd-ATC Mojo::Reactor::Poll: I/O watcher failed: Wide character in syswrite at /usr/lib/perl/5.18/IO/Handle.pm line 222.
20:59 jberger that just means that you aren't encoding/storing/extracing/decoding/reading/etc correctly somewhere along the line
21:00 jberger good luck
21:00 Floyd-ATC lol
21:00 jberger ;)
21:01 Floyd-ATC Data::Dumper seems to recognize it and Mojo::mysql appears to insert it as expected
21:01 good_news_everyon joined #mojo
21:01 good_news_everyon [mojo] kraih pushed 2 new commits to master: https://git.io/v2lg4
21:01 good_news_everyon mojo/master 3c34fe9 Eugen Konkov: Small optimizations
21:01 good_news_everyon mojo/master be78a4b Sebastian Riedel: Merge pull request #915 from KES777/small_optimization...
21:01 good_news_everyon left #mojo
21:01 Floyd-ATC although I'm not 100% sure about the latter
21:02 good_news_everyon joined #mojo
21:02 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/v2lgM
21:02 good_news_everyon mojo/master 21c34d8 Sebastian Riedel: fix formatting
21:02 good_news_everyon left #mojo
21:03 sri Floyd-ATC: if the method docs say $bytes, you're responsible for encoding
21:06 Floyd-ATC My unicode-fu is weak, but as long as I never decode then the output encoding /should/ be as it was when it came in, right?
21:06 Grinnz_ no
21:07 Grinnz_ always decode on input and encode on output. mojo rendering assumes you are passing it decoded characters, because that's what you usually work with in perl
21:07 sri your data can be in two states, characters and bytes, and you need to be aware of that state at any given time
21:08 sri when data enters or leaves perl, it always has to be bytes
21:10 perlpilot .oO( two bytes enter, one character leaves )
21:11 sri it's really not that hard once you're aware of that
21:12 sri just follow the data, and watch for bytes/chars transitions
21:13 * sri still hopes that some day perl scalars will just have a flag for that, so we don't even have to follow it
21:16 Grinnz_ you mean like... a utf8 flag? /runs
21:16 sri yea, you better run fast!
21:19 Floyd-ATC Decoding on input is dead simple, there's one single point of entry
21:20 Floyd-ATC Encoding on output, on the other hand.... it's like a million places :-|
21:20 sri well, in many places encoding is done for you, like templates
21:20 sri or anything json
21:21 Floyd-ATC yep but I generate tons of sql queries which all have to be dynamic because I never know in advance exactly what fields I will be getting
21:22 sri Mojo::Pg (through DBD::Pg) for example handles encoding/decoding automatically in both directions
21:22 Floyd-ATC the import must be able to update existing data without wrecking it you see :-/
21:23 Floyd-ATC WHat about Mojo::mysql? Does it also do encoding for me? I found nothing in the doc
21:23 sri dunno, never used that
21:24 Floyd-ATC DBI::MySQL does support it as long as the mysql server isn't ancient
21:25 Floyd-ATC but the option goes in the connect string, which is completely different in Mojo::mysql
21:25 Floyd-ATC or rather, the connect /call/
21:25 jberger yes it seems to be the default in Mojo::mysql https://metacpan.org/source/JHTHORSEN/Mojo-mysql-0.14/lib/Mojo/mysql.pm#L21
21:26 Floyd-ATC right, ok, so the queries should be fine then
21:26 jberger was the data stored in mysql correctly in the first place/
21:26 jberger ?
21:27 Floyd-ATC yes, I'm pretty sure. It shows correctly both in the mysql cli and in the old web app.
21:29 jberger then all you should need to do is encode before write_chunk
21:30 Grinnz_ Floyd-ATC: if you use mysql_enable_utf8 then DBD::mysql will make stupid assumptions and hope your input character strings end up as bytes across the wire. which usually works. and you'll get decoded characters back.
21:30 Grinnz_ https://rt.cpan.org/Public/Bug/Display.html?id=87428
21:31 Grinnz_ i've only had to mess with it once, by running utf8::upgrade on the input strings before passing them as parameters
21:31 jberger ugh
21:32 Grinnz_ Floyd-ATC: and you can change the connection charset dynamically too. you just set mysql_enable_utf8 on the driver then run "SET NAMES utf8" as a query
21:32 Grinnz_ but setting it by default and keeping it consistent is much easier of course
21:34 Grinnz_ Floyd-ATC: but just note that it's somewhat wrong to say "DBD::mysql/Mojo::mysql does the encoding for you" :/
21:34 Floyd-ATC Yes, it doesn't seem to be exactly right
21:35 Grinnz_ it relies on perl's internal utf-8 representation of strings, which usually means it doesn't need to encode or decode anything
21:35 Floyd-ATC norwegian chars get stored properly but that pesky "mu" character shows as "?"
21:35 Grinnz_ are the charsets of your tables all utf8?
21:36 Floyd-ATC but.. If I encode all the queries (oh god no please) then won't I risk it getting double encoded?
21:36 Floyd-ATC yes, I made sure all the tables use utf8
21:36 Grinnz_ no don't encode anything
21:37 Grinnz_ utf8::upgrade is the only thing you may need to do, and that's if something gives you a string which has high bit chars that aren't internally utf8-encoded for some reason (some XS modules might do this)
21:37 Grinnz_ that doesn't actually change the string, just the internal representatin
21:38 Grinnz_ also check "show variables like 'character_set_%';
21:38 Floyd-ATC I did just try decoding on csv import and encoding on the specific write_chunk() where I first spotted the problem and it appears to work
21:38 Floyd-ATC so atleast I'm on the right track
21:39 sri mysql sounds pretty annoying
21:39 Grinnz_ the server, client, connection, database, and tables, all can have different character sets
21:39 Floyd-ATC mysql ius sweet, unicode is migraine material
21:39 Grinnz_ which normally works ok, but affects what you can store
21:39 Grinnz_ and retrieve
21:39 * jberger looks at current stack and weepes
21:39 jberger weeps even
21:40 sri with postgres i usually don't even think about charsets
21:40 Grinnz_ the whole utf8 repesentation problem is just a bug in DBD::mysql
21:40 Grinnz_ actually all of the utf8 problems with mysql are because of DBD::mysql being badly designed
21:40 Grinnz_ (that ive run into)
21:42 Grinnz_ i dont know if i could refer to mysql as "sweet" though
21:48 Floyd-ATC I'm not even remotely qualified to point at any one module and say "there's the stupid error" because I barely understand the problem :-/
21:55 Floyd-ATC ugh... those "mu" characters are resisting every attempt to squeeze them into the table though :-(
22:08 punter joined #mojo
22:14 kaare joined #mojo
22:19 csson for utf8 and mysql, see this: https://mathiasbynens.be/notes/mysql-utf8mb4
22:20 csson tl;dr: CHARACTER SET = utf8mb4 instead of CHARACTER SET = utf8
22:23 cpan_mojo Toadfarm-0.73 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/Toadfarm-0.73
22:30 flingtoad joined #mojo
22:32 flingtoad Will mojolicious allow me to set my static->path to an S3 bucket or is there a better way to use s3 for delivering static files?
22:33 Grinnz_ that doesn't make any sense, mojolicious wouldn't be serving those files at all
22:33 Grinnz_ you'd just link to them from the template
22:34 jnm_theMailman left #mojo
22:34 flingtoad My understanding was that mojo would automatically search the paths in static->path. If it will let me set the path to a base URL, then I was wondering if I could avoid add any new bits to the template.
22:35 Grinnz_ the path is not a URL, it is a filesystem path
22:35 Grinnz_ making an HTTP request is completely different
22:35 Grinnz_ at which point, why use S3 at all?
22:36 perlpilot_ joined #mojo
22:36 flingtoad I suppose that was the main point of my question. I just wanted to know if it would accept URLS, S3 being an example.
22:36 flingtoad Thanks for the help.
22:37 Grinnz_ you can't "search" a url anyway, not in any portable manner
22:55 punter csson: very interesting, thanks
23:18 jabberwok joined #mojo
23:29 PryMar56 joined #mojo

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