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

IRC log for #mojo, 2015-06-03

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

All times shown according to UTC.

Time Nick Message
00:07 _dave_ To clarify the use of "under", I can chain several under callbacks in the same route as long as I call "continue" when I want to go to the next one?
00:27 disputin joined #mojo
00:32 woz joined #mojo
00:40 woz joined #mojo
00:43 woz joined #mojo
00:53 jberger _dave_: you can also just return a true value
00:53 jberger continue makes async under possible
00:57 woz joined #mojo
01:11 _dave_ async under? is this meaning I can run N under callbacks at once? O.o
01:23 bpmedley joined #mojo
01:30 zivester joined #mojo
01:35 klapperl_ joined #mojo
01:50 Grinnz _dave_, not at once... just the same way you can have a delay in a regular action method, you can have one in an under, and then call continue
01:50 Grinnz https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides/Routing.pod#Under
01:51 hshong joined #mojo
02:01 mattastrophe joined #mojo
02:06 damaya_ Hi fellers
02:07 damaya_ this is something I can't really test (i.e., don't know how I would anyway), so I ask you all.
02:07 damaya_ will something like this work:
02:09 damaya_ while ( my $b = $db->query('select name from table where value = ?', $foo)->hash; ) { $foo = rand(); }
02:09 damaya_ I'm basically trying to say, if it's in the database keep generating a random value into $foo until you find one that's not.
02:27 preaction why would you keep generating a random value and checking the database? that doesn't sound like a sufficiently random value
02:33 cpan_mojo Mojo-Webqq-1.3.2 by SJDY https://metacpan.org/release/SJDY/Mojo-Webqq-1.3.2
02:38 noganex_ joined #mojo
02:40 damaya_ joined #mojo
02:40 damaya__ joined #mojo
02:41 kaare joined #mojo
02:49 disputin joined #mojo
02:52 damaya preaction: How do I do it if I don't check the database?
02:52 damaya wrap in a try/catch?
02:52 preaction no. you make it random enough that it doesn't matter. UUIDs are that random
02:53 damaya so you're saying there is 0 chance a uuid will ever repeat?
02:53 preaction yes
02:53 damaya and nah, I really don't want some ugly uuid
02:53 preaction you don't want _this_ either
02:54 damaya I am doing base36 from time, and a 4 digit random number
02:54 preaction have an incrementing ID instead
02:54 damaya there is a surrogate key
02:54 damaya I'm not accessing the database from the surrogate key
02:54 damaya I don't see what's wrong with this approach. I've looked into this a lot and plenty of sites use it.
02:55 damaya TinyURL uses base36 for their shortening service, Reddit uses it...
02:55 damaya I have the surrogate key simply because joins are more efficient with an integer vs a string.
02:55 preaction use a hashing algorithm instead
02:56 damaya hrm, ok, if you insist on it, I guess I can use uuid, it's just ugly in the URL
02:56 preaction which, we explained last night: Don't put it in the URL
02:56 tempire ooo
02:56 tempire http://www.builtinperl.com/
02:56 tempire nice
02:57 damaya oh yeah, the stub situation
02:57 damaya the stub... I mean, there's nothing unique really in there other than the surrogate key
02:57 damaya not sure what I'm creating this stub from
02:58 preaction the title of the post
02:58 purl well, the title of the post is not returned in $post->{content} :-\
02:58 damaya tempire: Thank you for that.
02:58 damaya the title of the post is not unique.
02:59 damaya there is absolutely nothing unique to a post other than the surrogate key, and most likely the body (though that's not even a constraint either).
02:59 preaction my $count = $dbh->select('SELECT COUNT(*) FROM posts WHERE title LIKE "$current_title%"'); $current_title .= "-" . $count;
03:02 damaya mind blown
03:02 damaya that's pretty brilliant actually :D
03:03 damaya So, you're saying the base36 string in this URL is bad: http://www.reddit.com/r/AskReddit/comments/389uia/cat_owners_of_reddit_what_are_common_mannerisms/ ??
03:03 preaction in theory you could do the same for your current slug as well
03:03 damaya I like your approach, I am going with it
03:03 damaya I'm doing it to generate the slug, and the slug will have a unique constraint
03:04 damaya truncate at 60 characters, add the count to the end, that's the slug
03:04 damaya it's awesome
03:04 preaction with reddit's way, http://www.reddit.com/r/AskReddit/comments/389uia <- is all that's needed
03:04 preaction the rest is fluff
03:04 damaya Yeah, I think the slug is there for SEO purposes.
03:04 preaction no. it's for humans
03:04 damaya ok, I like your approach better anyway
03:05 damaya Thanks preaction, that's awesome
03:09 damaya last thing preaction, do you think the approach of slug+count is better than the reddit random base36 approach?
03:10 preaction depends on the urls you want
03:10 damaya Both require a query to the database, one to check if string is unique (because it's not a uuid), the other to query for count.
03:10 preaction they could both be querying for a count
03:10 damaya oh yeah, durr
03:10 preaction if you didn't, then you'd have to increment and test every single time
03:11 damaya I don't understand the last sentence, "if you didn't, then you'd have to increment and test every single time"
03:12 damaya How would you not test every single time when querying count?
03:13 damaya Or maybe I misunderstood you
03:15 PryMar56 joined #mojo
03:17 preaction once you have the count, you know how many posts you need to "skip"
03:18 preaction if i have a post with an id of "foo", or 389uia, i don't yet know if it's unique. but i want to know how to _make_ it unique, so i ask the database: how many posts would conflict if i tried to put this id into the database. then i add that number to mine
03:19 preaction then i'm unique, barring race conditions
03:21 damaya ohh, that's if 389uia is incrementing rather than random, right?
03:21 preaction start by making it random
03:21 preaction then make it unique by checking the database
03:24 bpmedley_ joined #mojo
03:25 basic6 joined #mojo
03:32 damaya preaction: I get it! Haha, thank you :D
03:33 damaya I just had a moment. I literally went, "ohh... OHHH!"
03:33 damaya :D
03:36 damaya preaction: The only issue with the count+increment that I can see is the possibility of race conditions.
03:36 damaya :/
03:36 preaction [22:19:28]  <preaction>then i'm unique, barring race conditions
03:37 preaction which is why you need to start from something marginally random/unique. else locking
03:37 damaya Ahh, didn't notice that. I think you could still get around it with a try/catch though.
03:37 damaya I don't know how to get around the possibility of colissions other than uuidv4.
03:38 damaya collisions*
03:38 damaya I imagine my misspelling of that would bother jberger, haha
03:40 preaction auto-increment IDs
03:41 damaya yeah, that's really it... though I read somewhere in my searching on this that the reason to use uuidv4 is the possibility of race conditions with surrogate keys (auto incrementing ids).
03:43 preaction there's no possibility of a race condition there unless you're in a replicated environment that doesn't know how to handle it. the database is the one incrementing the ID, not you
04:33 hshong joined #mojo
04:38 bakanov_da joined #mojo
06:23 dod joined #mojo
06:53 bakanov_da joined #mojo
07:12 AndrewIsh joined #mojo
07:16 dod joined #mojo
07:22 amon joined #mojo
07:27 trone joined #mojo
07:28 Nemix_ joined #mojo
07:31 eseyman joined #mojo
07:36 mtths joined #mojo
07:57 punter joined #mojo
08:00 Vandal joined #mojo
08:13 btyler anyone a moderator of the mojolicious google group? some spam snuck in: https://groups.google.com/forum/#!msg/mojolicious/asNjLV1rMgk/YeSWABRJi_YJ
08:21 batman i guess someone has, since it's removed now :)
08:29 fhelmber_ joined #mojo
08:46 cpan_mojo Mojo-UserAgent-DigestAuth-0.03 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/Mojo-UserAgent-DigestAuth-0.03
08:50 woz joined #mojo
08:51 woz Anyone had problems installing Mojo::Redis2 on a fresh Perl 5.22 install? Seems to be a problem with Protocol::Redis
08:52 woz ==> Found dependencies: ExtUtils::MakeMaker
08:52 woz Found ExtUtils::MakeMaker 7.04 which doesn't satisfy 7.0401.
08:52 woz ! Installing the dependencies failed: Installed version (7.04_01) of ExtUtils::MakeMaker is not in range '7.0401'
08:53 woz Oddly though, installed on my iMac, failed on my MacBook, failed on my Debian Linode. All freshly brewed 5.22.0
09:02 bin_005 joined #mojo
09:39 ans1 joined #mojo
09:53 odc woz, sounds like a problem for #p5p
09:55 batman woz: "seems"? can't you just try to run "cpanm Protocol::Redis" to see if that's the case?
09:56 batman woz: if so... could you check if the same goes for cpanm Protocol::Redis::XS ?
09:57 batman woz: i'm the author of the module, but i don't have time to investigate right now.
09:57 batman any input is appreciated.
10:04 hahainternet hello mojo friends
10:04 hahainternet we're down a programmer for a while
10:04 hahainternet any of you do UK contracting?
10:12 bakanov_da i want to ask about heartbeat in hypnotoad (prefork) server. I set interval 1 sec, but debug shows that heartbeat may be lost... I see first at 15:01:59, second at 15:01:10 . Is it normal behaviour?
10:14 batman bakanov_da: depends on what your server does
10:15 batman bakanov_da: to dig into the code... https://metacpan.org/source/SRI/Mojolicious-6.11/lib/Mojo/Server/Prefork.pm#L155 so, the heartbeat is written from child to parent, using the IOLoop
10:16 batman this means that if the worker (child) is busy doing a crazy blocking SQL query that takes 30 seconds, the child will not be able to write the heartbeat to the parent (manager)
10:16 batman sql was just an example... could be any blocking action.
10:20 bakanov_da no, no, no... Only short requests to Redis and blocking work no longer then 1 sec
10:22 bakanov_da Actually, it's not real application. I just testing... it's simple thing that do short requests
10:24 bakanov_da I thinks it's because there is recurring timer that do heartbeat. It's not robust stuff i guess
10:38 bakanov_da joined #mojo
10:54 woz @batman ok, take 'seems' out of the sentence - it is a problem with Protocol::Redis I was just being polite ;-)
10:55 batman ok, hehe... what about Protocol::Redis::XS ?
10:55 woz Just tried it and same problem
10:55 batman ok
10:56 woz Well, same problem for Protocol::Redis which is a dependency
10:57 woz Found ExtUtils::MakeMaker 7.04 which doesn't satisfy 7.0401.
10:57 woz ! Installing the dependencies failed: Installed version (7.04_01) of ExtUtils::MakeMaker is not in range '7.0401'
10:57 woz ! Bailing out the installation for Protocol-Redis-1.0003.
10:57 woz ! Installing the dependencies failed: Module 'Protocol::Redis' is not installed
10:57 woz ! Bailing out the installation for Protocol-Redis-XS-0.05.
10:57 batman oh. i didn't know it had Protocol::Redis as a dependency :S
10:57 woz 'Seems' to :-)
10:58 abracadaniel Hi everybody! i am having a bit trouble understanding how to use the routing correctly, is it possible to assign a sub to a route made like this: my $blog = $r->under('/blog'); ?
10:58 batman abracadaniel: $blog->to(cb => sub { my $c = shift; ... });
10:58 abracadaniel batman, thanks ill try that out :)
10:59 woz But it *did* just install fine on my iMac.
10:59 woz Failed on Debian Linode too
11:00 woz Only difference I can think of is that I installed 5.22 on the MacBook and Linode last night, and the iMac this morning. Can't think of any reason that'd make a difference though
11:08 dod joined #mojo
11:11 neilhwatson joined #mojo
11:14 jabberwok joined #mojo
11:17 ToApolytoXaos joined #mojo
11:21 bakanov_da @batman, so what do you think...
11:22 batman bakanov_da: i don't see how syswrite() from child process to parent process gets lost if there's no load and no crazy stuff going on
11:22 woz Protocol:Redis installs ok with cpan instead of cpanm
11:22 batman woz: do you have the same cpanm version on all systems?
11:22 batman ...so i have no idea why it happens bakanov_da.
11:22 batman bakanov_da: the recurring() timer is not exact, but it's never ten seconds off, unless something is blocking it.
11:23 woz Ah, possibly not. Good point.
11:23 woz Fresh 5.22 installs, but perlbrew cpanm lives outside of the distro
11:25 woz No, and the box it worked ok on is and OLD cpanm 1.5019. Failed on new 1.7034
11:25 woz s/and/an/
11:26 batman woz: "new" doesn't mean "less bugs", hehe :)
11:26 batman (but i have no idea what's going on)
11:28 mattastrophe joined #mojo
11:29 woz #p5p said known problem with Module::Install fixed in 1.05.
11:30 woz And no, just newer more shiny bugs :-)
11:31 bakanov_da @batman there are many events emitted in my ioloop... I simulate 1000 connections per worker. It may be reasone?
11:31 bakanov_da reason
11:31 ribasushi woz: that's not the problem though
11:32 ribasushi woz: the problem is a *dstribution* which was *packaged* with a Module::Install *before* 1.05
11:32 ribasushi whether or not you have a newer M::I on *your* system is not relevant
11:32 ribasushi (or whether you have one at all)
11:32 batman bakanov_da: that number of requests might fall into the "there's no load and no crazy stuff going on" category.
11:32 ribasushi so in other words - the distribution that failed needs a re-upload (or you need to use cpan)
11:33 batman (which i mentioned earlier)
11:35 woz @batman you did :-) Good call!
11:35 jabberwok re-reading docs again.  I was confused by Mojo::Base's tap() which is described as: "tap into a method chain to perform operations on an object within the chain" ... this sounds somehow malicious: tap into someone else's code? ... but perhaps it means this: "To facilitate method chaining, tap lets you wrap functions or operations (which return various values) within a tap function that will return its invocant." ... is that accu
11:35 batman woz: do you know that IOLoop is not threading/forking, but rather cooperative programming?
11:36 woz Eh? Crossed threads I think :)
11:36 woz I was the Protocol::Redis install issues thread
11:37 jberger woz: --uninst-shadows
11:38 woz Ha, for a while :)
11:39 batman woz: sorry. i meant bakanov_da
11:40 batman bakanov_da: ... it relies on *you* not spending too much time doing other blocking stuff
11:40 woz And @ribasushi yeah I get that - I'll get in touch with the maintainer.
11:41 batman note that everything is blocking. the *definition* of "non-blocking" is "blocking for a very short period of time"
11:41 ribasushi woz++ # proactive!
11:41 woz Well I might ;-)
11:41 dod joined #mojo
11:41 absolut_todd joined #mojo
11:42 woz I do have some round tuits that I picked up at Mojoconf 2014 still on my desk...
11:42 jabberwok tuits.... two wits
11:43 woz Nah, I've only got half of one of those
11:43 marcusr better than half
11:44 marcusr oh, I misread. Sorry.
11:44 marcusr /win 17
11:44 * marcusr runs away
11:45 dod joined #mojo
11:46 woz Crikey, what did I start in #p5p ?!
11:46 bakanov_da @batman I know. I have mentioned that I write/read to/from redis and do another short operations. There aren't any SQL requests... Only high load
11:48 batman marcusr: do you think you get time to look at convos this week?
11:56 marcusr batman: you mean your batcode branch?
11:56 batman yeah
11:57 mattastrophe joined #mojo
11:58 jberger woz: I don't know if you have another install to test in, but I'm curious if cpamn works with --uninst-shadows
11:59 woz Yeah, not had a chance to install on the MacBook yet, and that was broken, so will try
12:00 marcusr batman: I'll try. Brewing tomorrow, and driving to lillehammer to get my new car on friday.
12:00 batman ah. cool :)
12:00 batman no rush. just wanted to know... i've delayed this for a while, so i can't actually stress you on reviewing it ;)
12:01 batman this = making the "fork"
12:02 jberger marcusr: got 5 mins to push a new MountPSGI?
12:03 marcusr jberger: maybe once I'm home. Don't have anything set up for cpan at work
12:05 jberger Sorry, I know I'm being annoying about it :s
12:05 marcusr jberger: I'll get it done in 3-4 hours
12:06 marcusr or I can give you cpan perms and you do it?
12:06 bakanov_da Can anyone, please, answer, if I have two Mojolicious servers running in hypnotoad, what will be the best way to send messages from one to another. I need to send tons of messages
12:06 bakanov_da Or better will be to say "what is recommended way"
12:07 marcusr jberger: You're comaint now, good luck :)
12:11 bakanov_da Both servers works on one machine
12:28 bc547 bakanov_da: messages like?
12:31 bakanov_da @bc547 short information about client of first mojolicious. I mean... Cleint sends me info on first mojolicious and I resend part of it (about 4 short lines in json) to another
12:32 jberger marcusr: thanks
12:33 bakanov_da But I need to do it for every client. So it will be tons of messages. My application needs to have very high load ~4000 requests per min
12:33 jberger A few hours would have been ok too, I just needed it before yapc
12:33 jberger But I'm ok doing the legwork
12:35 bc547 bakanov_da: what does the receiving application do with the data? are there other apllications sending information to it?
12:37 nic joined #mojo
12:39 nic sri: The docn for url_for doesn't explicitly say that you can pass stash values
12:39 nic it mentions session params, but I read that as meaning you couldn't add new ones
12:41 bakanov_da @bc547 it does some work (analysis) to prepare data and then put it to database. It may need to communicate to different sources of information to analyse data. I don't wan't to do it in first Mojoliciois, because first mojolicious suppose to be less complicated, but have high load. First application need to handle 4-10 times more requests and 10-100 ...
12:41 nic hmm, I guess it's talking about session params of the target path
12:41 bakanov_da ... times more data than second but in less sophisticated way
12:41 nic sri: Does it take the params of the path you're on and overlay with given ones, all which get applied to the target path?
12:42 bakanov_da @bc547 second application needs to handle less data, but in more sophisticated way
12:43 abracadaniel Is it possible to add a group to the routes in mojolicious like its done in mojolicious lite: group { ... under '/something' => sub { ...}; get 'something' => {...} };  ?
12:43 nic lols, params inheritance pertains only to url_with, and it turns out url_for is all I need
12:43 nic Ignore me, it's probably deadline stress that's muddling my head
12:52 woz_ joined #mojo
12:55 zivester joined #mojo
12:55 woz_ joined #mojo
13:04 bakanov_da @bc547there aren't other applications. I mean... Second application can call to postgres to put data (small data) and then it will get async response that put was successful (by mojo::pg). But no other applications send anything to it
13:08 bc547 bakanov_da: seems more like a job for minion ( http://mojolicio.us/perldoc/Minion )
13:18 bakanov_da @bc547 do you mean to use Minion instead of second Mojolicious. Am I right?
13:29 woz @jberger --uninst-shadows didn't make any difference, but given that this was freshly brewed 5.22 and the module hadn't ever installed I didn't really expect it to.
13:34 bakanov_da @bc547 maybe it's a good idea, but I need to perform async requests to database. Will be it a good idea to have IOLoop inside Minion to work with Postgres non-blocking by Mojo::Pg?
13:42 kaare joined #mojo
14:03 jberger woz: oh, I meant use it to install EUMM
14:03 jberger cpanm --uninst-shadows ExtUtils::MakeMaker
14:15 mattastrophe joined #mojo
14:16 kyshtynbai joined #mojo
14:16 asarch joined #mojo
14:18 jasanj joined #mojo
14:23 jasanj left #mojo
14:23 jasanj joined #mojo
14:36 cpan_mojo Mojolicious-Plugin-MountPSGI-0.03 by JBERGER https://metacpan.org/release/JBERGER/Mojolicious-Plugin-MountPSGI-0.03
14:37 eseyman ms
14:37 jberger :o cpan_mojo is fast today!
14:37 jberger (meaning that metacpan is fast today)
14:43 fhelmber_ joined #mojo
14:45 woz @jberger from the chatter on #p5p it's something that needs to be fixed in the Protocol::Redis release - they need to repackage using Module::Install 1.05
14:45 jberger I was just curious because I had seen something similar a while back on EUMM
14:46 jberger it is very possible that they are right and that the similarities are just coincidence
14:46 woz ribasushi pinged me this - it's not a new problem http://paste.scsys.co.uk/485889
14:47 jberger ETOOMUCHTOREADNOW
14:47 jberger but I'm aware of the general problems with version.pm and the political problems in fixing it
14:48 woz It is worth reading though :)
14:49 disputin joined #mojo
14:49 woz Lesson I learned today - If stuff fails to install using cpanm (especially if it's around versions) then try cpan
14:49 jasanj left #mojo
14:53 nic Those version problems all disappear if everyone uses a number with 3 dec places: x.xxy where y is never 0
14:53 nic alpha releases are better handled in a git repo (eg github) rather than cpan
14:53 nicomen why not just semver
14:54 nicomen seems to work?
14:54 nic nicomen: I use semver with the the x.xxy pattern
14:54 nic (y is the packaging version: ie y - 1 = number of times I fucked up the packaging)
14:55 nic but you can use that pattern without semver
14:55 nic and if you prefer x.xx, just add a 1 to the end and presto
14:55 nicomen I thought the whole point of semver was to get rid of x.xxy ambiguities
14:55 nic ambiguities?
14:55 nicomen 1.04 vs. 1.4 vs 1.400
14:56 nicomen 1.004
14:56 nicomen are all those the same?
14:56 nic semver is to add semantics to versioning
14:56 nic eg people who attach semantics to the release of v1
14:57 nicomen SemVer then
14:57 nicomen rule 2 states the format
14:58 nic The three dec places pattern is a rule to avoid all the silliness we get in perl
14:58 nic whereas semver is lang-agnostic
14:59 nicomen which one is biggest? 1.4, 1.004, 1.040, 1.400 ?
14:59 pink_mist depends on if anything comes after or the thing you're comparing it to has anything that comes after
14:59 nicomen the problem in CPAN land for me has been to know wether the dot is a decimal sign or not
15:00 nic nicomen: If you follow the pattern above, that question disappears
15:01 pink_mist nicomen, nic: I suggest you read through this bugreport conversation: https://rt.cpan.org/Public/Bug/Display.html?id=54897 .. it'll let you know some dos and don'ts
15:01 gabiruh joined #mojo
15:01 nicomen pink_mist: I don't have any questions really
15:01 pink_mist I didn't say you did; still read through that
15:01 nicomen I already have been trying to do magic fixup of version numbers in cpan, and make them match debian world with our build system
15:02 nic pink_mist: no, don't invest more time on a problem that quite easily goes away
15:02 nic there are multiple ways to make it go away
15:02 nic I'm just pointing out that one v simple way avoids the need for strings and evals
15:04 nicomen pink_mist: I didn't really see the problem. Never using less decimals is of course nice
15:04 nicomen but too late
15:06 jabberwok just add "... for workgropes"
15:06 jabberwok *groups
15:06 Grinnz_ workgropes are how you end up with an involuntary retirement...
15:07 jabberwok +1 Grinnz_
15:08 nic Anyway, Blatter has gone, and my directors abs love Mojolicious, so I'm off to celebrate
15:08 nic I never ever ever thought I'd hear the php-heads saying positive things about perl
15:09 nic (referring to people I work with, not anyone outside)
15:10 jabberwok php folks everywhere seem to be looking for alternatives to php as-is and dreading php7, perl5 is in a good spot right now.
15:12 genio It's been my experience thus far that most of the PHP world has been looking to Node. :/
15:13 jabberwok yes. until they get to callback-hell...?
15:15 jberger Mojolicious is well placed to grab PHP and Node users IMO
15:15 genio I think so as well.  However, everytime I say "Perl", people say, "ewww, Perl"
15:16 Grinnz_ there is a lot of perl that rightfully invokes that response unfortunately.
15:16 jberger say Mojolicious
15:16 jberger say, written sanely from the ground up
15:16 jabberwok just don't say Matt's Script Archive
15:16 Grinnz_ lol
15:17 genio People are too stuck in the mindset that Perl is old and dead and only for quote-unquote legacy shit.
15:17 jberger remind them that ES6 is just Perl that runs in a browser, it turns out we got a lot of stuff right
15:18 Grinnz_ wheenver someone talks about ES6 i'm wondering why they sound so happy about elasticsearch
15:18 Grinnz_ then i remember
15:18 genio And that terrible mindset they have makes me glare evilly at a certain project that has not been completed in many, many moons.
15:31 mgrimes joined #mojo
15:46 jberger and here is part 2 of my cpan morning:
15:46 jberger https://metacpan.org/pod/release/JBERGER/Test-Mojo-Role-PSGI-0.01/lib/Test/Mojo/Role/PSGI.pm
15:47 jberger so now I can show off at YAPC::NA with this kind of thing
15:47 jberger my $t = Test::Mojo::WithRoles qw/PSGI Phantom/;
15:47 jberger oops
15:48 jberger use Test::Mojo::WithRoles qw/PSGI Phantom/; my $t = Test::Mojo::WithRoles->new('path/to/app.psgi'); $t->phatom_ok(...);
15:48 * jberger wipes brow
15:48 mattastrophe joined #mojo
15:52 nicomen hm that psgi part is that anything similar to: http://search.cpan.org/~nicomen/Test-Mojo-Plack-0.07/lib/Test/Mojo/Plack.pm
15:52 nicomen jberger: ?
15:52 jberger oh
15:53 jberger hmmmm
15:53 nicomen lol
15:53 jberger nicomen: I've been working on this crap for weeks! where were you!?
15:54 nicomen yeah, slightly different approach on finding the app ;)
15:54 nicomen hm mountpsgi, and that just works?
15:54 jberger there are some tiny reasons I prefer mine, but only slightly, that could have been worked around
15:55 jberger nicomen: at least in the micro examples
15:55 nicomen there is no point in having a stand alone module if it can be done with roles
15:55 jberger its basically the same idea though
15:56 jberger hehe, even your example is nearly identical
15:56 nicomen I wonder why I had to do all the extra shit preparing requests though
15:57 jberger that is all done in M::P::MountPSGI
15:57 jberger which stole the logic from M::P::PlackMiddleware
15:57 jberger and yes, its close to the same stuff
15:57 nicomen aha
15:57 nicomen aaaah you made that too ;)
15:58 jberger no marcus made that, I just pestered him until he gave me comaint to fix a bug
15:58 jberger earlier today
15:58 nicomen ah yeah the proxy class
15:58 nicomen aha
15:59 nicomen well if you add 'Module::Foo' support I guess I can just remove mine from CPAN ;)
16:00 jberger the internals SHOULD allow that, and if it doesn't it should an easy fix
16:00 jberger though I don't know how that works
16:00 jberger since a psgi app is a code reference by definition
16:00 nicomen it's my only CPAN module anyway, so it's not like I would end up hurt or really sad
16:00 nicomen and depressed
16:00 purl it has been said that depressed is the natural state of swedes
16:00 nicomen or anything
16:00 purl anything is probably easy if you read the source ;)
16:01 nicomen :-(
16:01 jberger nicomen: :(
16:01 * jberger feels ba
16:01 jberger bad
16:01 jberger and ba
16:01 nicomen luckily I have 5 modules from work I've been allowed to open source \o/
16:01 jberger \o/
16:02 nicomen seriously, tell me when it supports ->new('Foo::Bar') and I'll just made it point users to Test::Mojo::Role::PSGI
16:03 nicomen made=make
16:06 marty joined #mojo
16:32 PryMar56 joined #mojo
16:33 Dandre1 left #mojo
16:34 Dandre joined #mojo
16:43 nic joined #mojo
16:44 nic I have, in a template, <%= $a ? $b : $c %> where $a, $b, $c are quite lengthy expressions
16:44 nic however, $b needs to be not escaped, whereas $c needs to be escaped
16:46 nic Is a good route to nest <%= %> within <%== %> ?
16:46 nic It looks pretty horrible, but I can't think of another way
16:47 nic Well, another way is to have two separate replaces, using '' for the term that each one doesn't want
16:47 nic but that's getting pretty long and unreadable as well
16:49 * nic kills the dev who put escaped html into the db
16:51 Grinnz_ do the logic in the cotnroller and/or escape it there, with https://metacpan.org/pod/Mojo::Util#xml_escape
16:52 jberger nic: note that Mojo::ByteStream objects are exempted from <%= %> escaping
16:52 nicomen <%= $b if $a %><%== $c if $a> ?
16:53 jberger but then again, I would suggest you refactor somewhere else, <%= %> blocks should probably not be very lengthy generally
16:54 jberger use <% ... do stuff here ...; my $result = ... %> if you must, then render the result as <%= $result %>
16:54 jberger then again, probably most of what you need to do in <% %> could then be extracted into a controller method
16:55 jberger so you can just do <%= $c->get_big_ternary_result %>
17:05 nic Grinnz_, jberger, nicomen: Thanks for all those tips
17:05 nic That makes it way more readable
17:08 nic It's an intriguing tradeoff between having one template block with too much logic or twelve template blocks with too much duplication
17:08 nic (you can tell which pit I'm currently in :) )
17:10 nic I can't actually tell which way will be more prone to errors, hence any techniques for improving readability are high value
17:10 jberger nic: sounds like you need either helpers or template blocks depending on scope
17:10 nic I'm using both of those
17:11 jberger then why is there lots of duplication?
17:11 nic It's tricky to explain without being allowed to share code
17:12 jberger well, that doesn't matter, because you know what I would say :-)
17:12 nic Essentially there's one 'widget' that's reasonably 'rich' and currently has 12 different flavours
17:12 nic the flavours being driven by db data
17:13 lb there are no good solutions, pick your compromise
17:13 nic essatly
17:14 nic I'm still prototyping.  I am hoping once the UI is signed off I can improve some of the tangle using smarter js+css
17:14 dod joined #mojo
17:19 cpan_mojo Mojo-Snoo-0.02 by CURTIS https://metacpan.org/release/CURTIS/Mojo-Snoo-0.02
17:21 bwf joined #mojo
17:22 marty Any suggestions or advice on how to handle DB errors with MOJO::Pg
17:22 batman marty: die $err;
17:23 batman that would be my generic advice to a generic question
17:27 lb i like system "halt"
17:33 marty batman:  My bad, that was a generic question, sorry.   More specifically, how to handle exceptions or errors that are generated inside postgres via stored procedures or constraints.
17:33 marty For example, a simple 'INSERT' that returns a constraint error.
17:33 marty btw, I am using the blocking syntax
17:37 Dandre left #mojo
17:37 hernan604 whats the best way to tail a file using Mojo::IOLoop ?
17:39 batman marty: sorry. i have no idea how that works. if possible, make the procedures throw an exception so Mojo::Pg dies
17:40 batman hernan604: there's no official way. Mojo::IOLoop::Stream could watch the filehandle, but it's a *stream* and not Mojo::IOLoop::LineByLine, so it wouldn't work very well
17:41 batman marcusr: did you mean to add me as well to Mojolicious-Plugin-MountPSGI..?
17:51 trone joined #mojo
17:55 jberger POSIX::abort()
18:03 batman marty: maybe i can try to answer another way... so if there's an error, i want to die. i don't want to handle it.
18:03 batman the reason for that is that handling an error is very difficult.
18:04 batman there might be exceptions to that, but finding those exceptions only arise when you discover them. planning from them ahead is a very bad idea
18:04 batman very bad idea = my humble opinion, based on experience.
18:04 batman s/from them/for them/
18:05 marcus Nicomen: you replicated my module for your only public CPAN module? ;kr
18:05 marcus ;)
18:07 marcus Oh, you did a test thing. N/m
18:10 marty batman:  I'm trying to display meaningful message to the end users when an exception occurs.  My constraint message are making it into the mojo log so I know mojo is aware of them.  I'm just not sure how to access them.
18:11 batman marty: you need to sort the errors: is this something that happens frequent? if yes: fix it, so it doesn't occur. if no: show a 500 page, and tell the user you're sorry.
18:13 Grinnz marty, usually database errors are not something you want to display to the end user. if you have a good reason for doing so, then you'll have to catch the error and display it every time you do a query.
18:26 bin_005 joined #mojo
18:32 hahainternet so i hope it's not unreasonable to be soliciting contractors in here
18:32 hahainternet but should any of you live in the UK, preferably near manchester
18:32 hahainternet then i need ya
18:35 hahainternet i'm off out but PM me, if you work remotely then maybe but due to an emergency we need someone and we use mojo everywhere we can now :D
18:39 panshin joined #mojo
18:46 nicomen marcus: hm, no, I didn't make mountpsgi, I made a module that let anyone use Test::Mojo, but jberger closed the gap. Also I didn't know see your module at the time when searching for something ;)
18:46 nicomen I did find Test::Plack though and altered it
18:49 mattastrophe joined #mojo
18:50 Grinnz joined #mojo
18:55 mattastrophe joined #mojo
18:55 TheGrinnz joined #mojo
18:59 bin_005 joined #mojo
19:18 marcusr batman: yes, always
19:18 marcusr :)
19:25 Kogurr joined #mojo
19:38 Grinnz joined #mojo
19:42 berov joined #mojo
19:52 disputin joined #mojo
19:55 batman marcusr: <3
20:38 guru joined #mojo
20:47 frederic_ joined #mojo
20:49 guru joined #mojo
20:51 jberger marcus/batman: any objection? https://github.com/marcusramberg/Mojolicious-Plugin-MountPSGI/pull/3
20:52 batman jberger: count me out :P
20:52 batman i want as little as possible to do with psgi
20:52 jberger hehe, ok
20:53 jberger the original tests pass, I'm going to take the initiate :-)
20:56 jberger initiative
20:56 purl somebody said initiative was welcome then
20:56 * jberger kicks purl
20:56 * purl blocks!  Paint the fence!
20:57 cpan_mojo Mojolicious-Plugin-MountPSGI-0.04 by JBERGER https://metacpan.org/release/JBERGER/Mojolicious-Plugin-MountPSGI-0.04
21:00 mattastrophe joined #mojo
21:03 batman jberger: cpan_mojo is faster now, right?
21:04 jberger it is
21:04 jberger are you doing my old trick?
21:08 bin_005 joined #mojo
21:21 jberger nicomen: ok, pushed a new release of both modules
21:21 jberger nicomen: class names should also work
21:21 jberger wanna give it a try for me?
21:21 jberger (I have no idea what that would look like, but I think I have made it possible)
21:21 jberger also added using a subref or app instance
21:34 punter joined #mojo
21:34 bin_005 joined #mojo
21:41 bin_005 joined #mojo
21:46 jberger batman: it hasn't announced either of my Test::Mojo::Role::PSGI releases though
21:46 batman jberger: that's because it's not looking for ^Test
21:47 jberger it doesn't look at the dependencies anymore?
21:47 batman sure. but it also have to start with ^Mojo
21:47 jberger that seems silly
21:47 jberger if it starts with Mojo we can probably assume it depends on Mojo (MojoMojo being an exception)
21:48 jberger watching the dependencies is supposed to help see things that do not start with/include Mojo
21:48 jberger Galileo wouldn't be announced then either?
21:48 batman i thought *we* wanted to avoid posting all projects, just because they were dependent on mojo? should Convos get announced?
21:48 jberger :(
21:48 batman no. i thought that was the rule.
21:48 jberger That was what my old script did
21:49 jberger I wanted to be aware of modules which depended on Mojo, sri do you disagree?
21:50 batman where's your old script?
21:51 jberger batman: https://github.com/jberger/Mojo-FriendFeed/blob/master/ex/mojo.conf
21:51 jberger that was the config, this was the app
21:51 jberger https://github.com/jberger/Mojo-FriendFeed/blob/master/ex/cpan.pl
21:52 jberger this is and "or" operation essentially: https://github.com/jberger/Mojo-FriendFeed/blob/master/ex/cpan.pl#L80-L94
21:52 cpan_mojo Mojolicious-Plugin-MethodOverride-0.053 by GRAF https://metacpan.org/release/GRAF/Mojolicious-Plugin-MethodOverride-0.053
21:53 batman jberger: that's so weird. i'm sure i've had this discussion before.
21:53 jberger seems I recall it too
21:53 batman but the brain works in mysterious ways...
21:54 jberger especially when it has lots of Ethanol involved :D
21:55 jberger batman: argh why aren't you going to YAPC::NA
21:55 batman jberger: well... you know why.
21:57 jberger I know, but it would be so fun
21:57 bin_005 joined #mojo
21:57 batman hm... cpan_mojo doesn't announce Mojolicious :(
21:57 batman i'm too tired to look at that now.
21:58 jberger :o
21:58 batman https://github.com/jhthorsen/App-cpan_new/blob/master/script/cpan-new <-- please fix :)
21:58 batman it would have been a lot of fun.
22:00 batman i've been hacking too much on convos the last days...
22:00 batman brain is messed up
22:01 woz joined #mojo
22:05 jberger what filter do you run it with?
22:05 jberger ^Mojo ?
22:06 jberger oh!
22:07 jberger you search for recent release which have and AND filter restriction on dependency
22:07 batman yeah
22:07 jberger so Mojolicious doesn't get announced because it does not depend on Mojolicious@
22:07 jberger !
22:08 jberger batman: I'd change this to "or"
22:08 jberger https://github.com/jhthorsen/App-cpan_new/blob/master/script/cpan-new#L57
22:08 batman cpan-new --nick cpan_mojo --target '#mojo' --dependency Mojolicious --filter '^Mojo(licious|\b)
22:09 batman jberger: then i would get everything, which is the same as removing the filter completely
22:09 batman i could remove the filter in the query and just do it in perl
22:09 batman removing the filter completely = in the metacpan query
22:09 jberger hmmmm, I'll think about it
22:09 batman which i guess i need to... but you got commit bit, so just change it as you see fit :)
22:10 jberger my script did filter in perl space
22:10 jberger that was actually because it had to of course
22:11 jberger it was using essentially a twitter stream of releases
22:17 batman need sleep. back tomorrow
22:17 batman have fun :)
22:18 damaya_ I'm teaching someone Mojolicious. They are creating an app. They don't want to use a database at the moment because they want to focus on Mojolicious.
22:18 damaya_ So, they ask me how they can create/modify a data structure and have to accessible in every route.
22:18 damaya_ My solution is either has, or a helper that returns a state variable. Thoughts?
22:19 damaya_ What's the best approach to this? It's not something I've ever had to do.
22:26 jberger batman: nn
22:27 jberger damaya_: yes helper with state variable, at least in lite
22:27 jberger Note that you can get persistence using DBM::Deep
22:41 mattastrophe joined #mojo
23:11 Grinnz_ damaya_: if you want to use prefork you are going to need something external, even if its just redis
23:12 Grinnz_ if you want it shared, that is
23:20 zivester joined #mojo
23:34 mattastrophe joined #mojo
23:47 woz joined #mojo

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