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

IRC log for #mojo, 2017-03-28

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

All times shown according to UTC.

Time Nick Message
00:01 _dave_ joined #mojo
00:48 dave joined #mojo
01:56 lluad joined #mojo
02:41 noganex_ joined #mojo
04:04 dboehmer joined #mojo
04:11 inokenty-w joined #mojo
04:15 maschine joined #mojo
05:14 aborazmeh joined #mojo
05:18 dod joined #mojo
05:24 dod joined #mojo
06:37 Vandal joined #mojo
06:49 dod joined #mojo
07:09 AndrewIsh joined #mojo
07:19 batman joined #mojo
07:38 * tempire sparkles
07:58 dso Hi, I've got a question about Minion: Is it possible to define a constraint that a specific task may be run only one at a time? An easy workaround would be to put them in a special queue and have only one worker dequeuing that queue.
08:06 osfabibisi joined #mojo
08:32 rshadow joined #mojo
08:35 ksmadsen joined #mojo
08:41 sri little odd we have no openid plugin
08:42 sri dso: no
08:43 sri dso: it has been proposed though https://github.com/kraih/minion/pull/22
08:44 sri but we have no good implementation yet
08:46 sri and things get more complicated when you have to consider job dependencies
08:46 sri like a lock around a group of jobs
08:46 mtj joined #mojo
08:48 mtj joined #mojo
08:51 mat mmm, is there a tutorial on how to write tests for mojo apps ?
08:57 dod joined #mojo
09:18 dod joined #mojo
09:33 irqq joined #mojo
09:33 batman mat: have you looked at the documentation for Test::Mojo? It's pretty straight forward...
09:33 batman ...or are you thinking more about the strategy instead of just the syntax?
09:38 cpan_mojo joined #mojo
09:38 cpan_mojo Test-Mojo-Role-Selenium-0.08 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/Test-Mojo-Role-Selenium-0.08
09:38 cpan_mojo Mojolicious-Che-0.031 by MCHE https://metacpan.org/release/MCHE/Mojolicious-Che-0.031
09:38 cpan_mojo Mojo-Log-Che-0.02 by MCHE https://metacpan.org/release/MCHE/Mojo-Log-Che-0.02
09:38 cpan_mojo Mojolicious-Plugin-SimpleSlides-0.06 by JBERGER https://metacpan.org/release/JBERGER/Mojolicious-Plugin-SimpleSlides-0.06
09:38 cpan_mojo Mojolicious-Plugin-RevealJS-0.08 by JBERGER https://metacpan.org/release/JBERGER/Mojolicious-Plugin-RevealJS-0.08
09:41 mat batman, bit of both, I used to write a lot of rails, using specs, I just don't know how and where to start :-)
09:44 cpan_mojo joined #mojo
09:44 cpan_mojo Test-Mojo-Role-Selenium-0.08 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/Test-Mojo-Role-Selenium-0.08
09:45 batman mat: does the synopsis make any sense? http://mojolicious.org/perldoc/Test/Mojo#SYNOPSIS
09:46 batman here is a short introduction: http://mojolicious.org/perldoc/Mojolicious/Guides/Tutorial#Testing
09:48 mat batman, well, it does, kind of, it is all very basic, it doesn't guide you to creating test databases, or how to mock up database calls
09:49 batman that's kind of out of scope, but i understand your question.
09:50 mat I know mojolicious is just the controllers and leaves the models to some other framework, but it's a bit rough around the edges
09:50 batman it depends a lot on what kind of library you use to talk with the database.
09:50 batman i know many people who use DBIx::Class use a sqlite database for unit tests and mysql/postgres for production
09:51 batman i wrote https://metacpan.org/pod/DBIx::TempDB because i want to use a real database and not mock anything
09:51 salva joined #mojo
09:52 batman my strategy is then to have a "sql dump" in a file which i inject in top of my test and then run requests against the application, which then again will query a real database and nothing is mocked.
09:54 batman you can read more about my argument here if you're interested: http://thorsen.pm/perl/2015/09/20/testing-with-a-real-database.html
09:54 mat I'll look at that after lunch, thanks :-)
09:56 batman it doesn't tell you how to write tests, but it tries to argue for why using a real database is a good idea
09:56 kes joined #mojo
10:01 sri sadly not even the Mojo::Pg blog example has tests yet :(
10:21 stryx` joined #mojo
10:34 dso sri: thanks for your answer, I will live with the workaround at first.
10:36 prg joined #mojo
11:04 tchaves joined #mojo
11:14 tchaves joined #mojo
11:53 * sri is still curious why nobody has made a Mojolicious::Plugin::OpenID yet
12:10 batman maybe most people think ::OAuth2 serve the same pupose...
12:10 rshadow joined #mojo
12:10 batman s/most//
12:18 rshadow joined #mojo
12:22 sri it doesn't though
12:23 sri authentication vs authorization
12:24 batman i know :)
12:24 coolo for whatever reason https://xkcd.com/1816/ comes into my mind :)
12:46 itaipu joined #mojo
12:50 Peppard joined #mojo
12:59 mat batman, mmm, how do you hook up DBIx::TempDB with Mojolicious?
13:00 batman mat: i use an environment variable. so let's say if you using DBI directly, then i do something like DBI->connect($ENV{DBIX_TEMP_DB_URL} || $app->config->{db_url});
13:10 mat Mmm, I use DBIx::Class, but same can be done
13:11 batman mat: i usually have $ENV{MYAPP_DB_URL} and then i set MYAPP_DB_URL in the unit test, but it all depends on how you want the app to be deployed... using environment variables might not be the strategy you want to use
13:12 mat well, as there is also no real way of deploying mojo apps… :-p
13:12 purl okay, mat.
13:12 batman huh?
13:15 mat I mean, unless I missed something, there are no tools that come with mojo that will deploy an app, like, automating going through the productions servers, fetching from the scm, and restarting the app
13:15 mat I've been told to use rex, but I still have not gone through the steps of learning how to use it
13:16 batman i'm using ansible for those steps.
13:17 mat maybe I've been spoiled with all the tools that evolved in the rails ecosystem
13:18 batman and systemd for managing the process: http://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook (search for "systemd")
13:18 batman could be... i cannot comment on that, since i have zero knowledge of rails
13:19 batman i do like that i know about ansible and systemd, since that knowledge is useful in so many other cases and not just deploying a web app
13:20 sri i need this as my next workstation :o https://arstechnica.co.uk/gadgets/2017/03/corsair-one-review/
13:20 cosimo don't fetch, push
13:21 cosimo @mat: I use git as deployment tool, with a simple script as post-receive hook
13:22 batman cosimo: not all servers are set up so you can push... might be behind firewalls and such :/
13:37 cosimo batman: of course
13:37 cosimo batman: git works with basic ssh access though, so that's usually not a problem
13:38 gryphon joined #mojo
13:44 foursixnine joined #mojo
14:02 zivester joined #mojo
14:23 sri i kinda like openid
14:23 jberger tempire o/
14:28 VVelox joined #mojo
14:33 Pyritic joined #mojo
14:47 foursixnine joined #mojo
14:55 disputin joined #mojo
14:57 genio sri: That thing's 'spensive
14:59 disputin joined #mojo
15:01 disputin joined #mojo
15:02 disputin joined #mojo
15:03 lluad joined #mojo
15:07 disputin joined #mojo
15:13 sri genio: i think it's like $200 more than buying the components individually, and for that you get support
15:38 sh14 joined #mojo
15:42 itaipu joined #mojo
15:45 PryMar56 joined #mojo
15:51 cpan_mojo Mojolicious-Plugin-ReplyTable-0.08 by JBERGER https://metacpan.org/release/JBERGER/Mojolicious-Plugin-ReplyTable-0.08
15:54 cfedde I'm going to get one. but only becasue there is a Luigi doll on the shelf behind.
16:01 jberger hmmmm, TFW the contributor put the doc in the readme and not in the module documentation
16:01 cpan_mojo Mojolicious-Plugin-ReplyTable-0.09 by JBERGER https://metacpan.org/release/JBERGER/Mojolicious-Plugin-ReplyTable-0.09
16:02 jberger (the comedic timing on that was perfect cpan_mojo!)
16:11 stephan48 sri: i would love a openid module too - especially one allowing a easy server side implementation. i did many small projects where i started implementing a openid client or server but never got far due to timer or other projects(as it was mostly for private stuff). possibly a hackweek project?
16:50 dod joined #mojo
17:46 oalders Is it possible to have Mojo throw an exception on startup if a route resolves to a class or method which can't be found?
17:47 mrallen1 Is http://blogs.perl.org/users/joel_berger/2012/10/a-simple-mojoliciousdbi-example.html still the best guidance for DBI interfacing into Mojo these days?
17:47 mrallen1 jberger: ^^
17:48 jberger mrallen1: probably not, that's quite old
17:48 itaipu joined #mojo
17:48 jberger give me a sec, I'll take a look
17:48 mrallen1 Is the #1 hit on $SEARCH_ENGINE
17:48 jberger eeep
17:48 jberger ok /me looks
17:49 mrallen1 search term "mojolicious database example"
17:49 mrallen1 thx :)
17:49 jberger mrallen1: which db are you going to use?
17:50 mrallen1 Planning to use SQLite :-)
17:50 mrallen1 I have modest DB needs
17:50 jberger in that case you might want to look at Mojo::SQLite
17:50 mrallen1 ooo
17:50 mrallen1 When did that become a thing?
17:50 jberger it is a more pleasant wrapper for it
17:51 jberger been a while
17:51 jberger not too long after Mojo::Pg
17:51 mrallen1 Haha I rolled my own but its a bit grotty
17:51 mrallen1 Would love to kill it with cleansing fire
17:51 jberger anyway, the biggest change I would make to the example that was posted is that I would recommend DBIx::Connector
17:51 mrallen1 nods
17:51 jberger though for sqlite that isn't a big deal
17:52 mrallen1 thx I will look at Mojo::SQLite - that sounds like just the thing
17:52 mrallen1 Is there also one for for MySQL now?
17:52 jberger the idea of storing the database connection (well, connector to it) in a helper is still a recommended approach, especially for Lite
17:52 mrallen1 ok
17:53 jberger re: mysql: yes, though its maintenance is a little more grudging IIUC
17:53 mrallen1 alright
17:53 Grinnz DBIx::Connector and Mojo::SQLite/Mojo::Pg sort of serve the same purposes
17:53 Grinnz connection pool, fork safety, and transaction management
17:54 mrallen1 Except D::C is kind of a generic thing and the others are more engine specific I gather
17:54 Grinnz yes
17:54 jberger yeah
17:54 mrallen1 ok, great
17:54 mrallen1 thank you
17:54 jberger I guess its time for a new blog post to hit those search terms though
17:54 mrallen1 wouldn't be a bad idea :)
17:54 jberger man, 5 years goes fast
17:55 mrallen1 lol
17:55 jberger I remember sitting down to write that
17:55 mrallen1 sort of amazing that your post has aged pretty well, all things considered
17:56 jberger heh, it would be pretty terrible without the edit!
17:56 mrallen1 :-)
17:56 jberger I walk the db result in the template!
17:56 jberger egads!
17:56 mrallen1 pfft its an example
17:56 mrallen1 Except I guess that's how you get Matt's Script Archive
17:56 mrallen1 so
17:56 mrallen1 whatevers :)
17:57 jberger once I or someone has a better post, hopefully I'll remember to go back and edit a big bold link into that one
17:57 mrallen1 +1 thank you again
18:10 rshadow joined #mojo
18:16 tchaves joined #mojo
18:33 dave sri: that price and only 16G of RAM?
18:36 miller joined #mojo
18:51 lluad joined #mojo
19:14 maschine joined #mojo
19:37 lluad joined #mojo
19:57 irqq joined #mojo
20:32 Pyritic joined #mojo
20:41 warble joined #mojo
20:42 rshadow joined #mojo
20:47 arcanez joined #mojo
20:50 itaipu joined #mojo
20:51 arcanez am I just being dense? how would I get Mojo::DOM to parse an XML file <config><foo><name>Foo!</name></foo><bar><name>!Bar</name></bar></config> and give me config => { foo => 'Foo!', bar => '!Bar' } or similar
20:52 disputin joined #mojo
20:53 warble I don't think you would
20:53 warble I think you'd just ask the DOM for those things
20:54 warble ->at ('foo')
20:54 jberger arcanez I think you are thinking of XML::Simple, which is as close to using it as you should come
20:55 arcanez warble: I don't know what foo and bar are, just that there are elements below <config>
20:55 jberger I think that's ->children
20:55 Grinnz also, don't use XML::Simple
20:56 arcanez jberger: currently using XML::Simple to parse it and would rather not.. and I realize that Mojo::DOM would look different
20:56 arcanez I was thinking some form of ->children with ->each
20:56 arcanez but I can only get the ->tag
20:56 arcanez no ->val
20:56 Grinnz yeah, any DOM parser will generally require a slightly different approach, which is a good thing
20:56 Grinnz avoids the issues of thinking of XML like a perl data structure, when it isn't anything like that
20:57 arcanez Grinnz: I'd prefer something other than XML for the config, but just dealing with what i have for now
20:57 arcanez YAML perhaps
20:57 Grinnz anyway, you can find the tags you're looking for and put them in a data structure, its just a matter of figuring out the right CSS and/or traversal
21:00 Grinnz like for your example i'd do something like, my $dom = Mojo::DOM->new->xml(1)->parse($str); my %config = map { ($_->tag => $_->at('name')->text) } @{$dom->at('config')->children}
21:01 jberger perl -Mojo -E 'my $dom = x("<config><foo><name>Foo!</name></foo><bar><name>!Bar</name></bar></config>"); my %names = $dom->at("config")->children->map(sub{ $_->tag, $_->at("name")->text })->each; print r \%names'
21:01 jberger ah, Grinnz beat me
21:02 Grinnz same thing, different order :P
21:03 warble Seems like using a DOM when you don't want a Document Object Model might make you sad.
21:03 Grinnz if you have XML, you don't have much of a choice
21:03 arcanez warble: currently using XML::Simple to parse it
21:03 jberger and when the data doesn't map to a consistent data structure you'll be happier
21:03 arcanez what Grinnz pasted works
21:04 warble so, get XML::Simple to parse it, and use some other thing to dump it out in anohter format
21:04 warble and then stop having xml
21:04 warble and start having, say, YAML
21:04 arcanez baby steps :)
21:04 warble and then wham, no more DOM
21:04 arcanez using Mojolicious instead of HTML::Mason is the initial goal
21:04 arcanez so I'm figuring out the templating etc
21:04 warble HTML::Mason is my jam.
21:04 Grinnz i'd use a DOM parser to parse it, so that you don't end up with a randomly weird looking data structure that doens't make any sense
21:04 arcanez I like it as a template system
21:04 arcanez but not as the MVC
21:04 warble you'll have more fun if you keep the mason and move your init blocks to controllers first
21:05 arcanez autohandler and various other *handlers too
21:05 warble owf.
21:05 arcanez I may just have everything respond with json and use a js frontend
21:05 arcanez angular or whatever the cool kids use
21:06 warble the cool kids are dicks.
21:06 Grinnz json <3
21:07 warble Grinnz: how do you feel about dates though?
21:07 arcanez warble: I can't ever keep up whether one should use angular or react
21:07 warble arcanez: also, it's auto and d... what's the other kind of handler?
21:08 warble arcanez: just spew html at the client, they'll know what to do with it
21:08 warble turning mason into json (though they sound similar) is more nightmarish than just turning it not mojo template
21:08 warble i mean, %= vs % ... easy
21:08 warble <%= vs <% ...
21:08 warble easy
21:09 warble I think autohandlers are ->via
21:10 Grinnz warble: like, the fruit?
21:10 warble umm, ->under
21:11 warble Grinnz: it's more stringy than that.
21:11 arcanez warble: we have autohandler inherit syshandler and maybe dbhandler *shrug*
21:12 warble wtf is as syshandler
21:12 warble are you <%attrs> inhert =>'ing from an extra thing?
21:13 arcanez <%flags> but yes
21:14 arcanez autohandler outputs the basic template, syshandler handles db connections and a few other non visual things
21:14 warble Yeah, i'm more of a "Just jam it in the autohandler" kind of guy.
21:15 arcanez yeah, I want a little more separation this time around
21:15 arcanez fewer one-off moments
21:16 warble that's a nice idea, but you wouldn't be talking about HTML::Mason if you didn't have an existing application =)
21:17 arcanez I still prefer it as a templating engine. screw Template::Toolkit
21:17 eseyman joined #mojo
21:17 arcanez mojos default is nice
21:17 arcanez but yes
21:17 warble I'm playing with HTML::Zoom
21:17 warble it's making me crazy
21:18 arcanez mst-ware
21:18 warble and my bullshit template shim is great at consuming exceptions, and just getting zoom to give me the un-tampered with html
21:18 warble but still.
21:18 warble a number of things on cpan are mstware
21:18 arcanez I don't mind it, but some people do :)
21:18 warble "some programmers are jerks"... and that's fine.
21:18 warble if the computer program is ok, it's likely fine.
21:19 arcanez perhaps if catalyst used Web::Simple as its underlying dispatcher, I'd use it instead of Mojo
21:19 arcanez but using Mojolicious::Lite for a simple API to return JSON was too easy
21:19 warble there's a thing for that, right?
21:19 warble like 3 or 4 ::rest things
21:20 arcanez for Catalyst?
21:20 warble or that.
21:20 warble but I meant for mojo
21:20 arcanez I think there is a module to do about anything you want in Catalyst, but it won't get you 100% of the way, in my experience
21:20 arcanez for Mojo, I don't know
21:21 arcanez it wasn't hard to have get '...' = sub { } with Mojo::Pg and ->render()
21:21 maschine Catalyst drove me insane - talk about dependency hell
21:21 Grinnz warble: take a look at Template::Pure, it's supposed to be HTML::Zoom's successor
21:21 maschine I wasted like 6 months fighting to make it work
21:22 arcanez and Dancer appears to have too many magic subs for me
21:23 maschine All of the documentation and examples are many years old too.  The official tutorial is completely broken past a certain point.
21:25 warble Dancers examples/docs?
21:25 warble friend<-user.friends' => [             '.' => '={friend}, #={i.index}',           ],
21:25 warble yeah, sounds pretty simple.
21:27 jberger arcanez: I feel your pain, I ported a mason site to mojo
21:27 jberger not terrible just tedious
21:27 warble I don't like ->select...->replace...but trading it for something would make me want something with less crazy {}'ing nonsense rather than more.
21:27 jberger I did have this nice thing that dispatched to mason and localized all the globals
21:29 jberger but it was basically purpose-built for the case I had
21:30 jberger was dead-handy for porting though, it basically meant I could keep the rest of the site mason-y and port as I went
21:35 warble sounds like an interesting blog post.
21:41 arcanez jberger: I'd like to remove some of the 'globals'.. ie: right now, we have $DBH->{KEY}, which I plan to use the Mojo helpers and Mojo::Pg for
21:42 arcanez HTML::Mason as mvc works, but it is a PITA to change something low in the chain and is showing age in terms of speed
21:43 Grinnz warble: don't have much idea how either of them work, just know that's what they've been working on
21:44 arcanez jnap would be more than happpy to talk about it
21:44 arcanez (Template::Pure)
21:48 warble Yeah, the "your whole template syntax is in unvalidated strings" seems like it would be unhelpful
21:49 warble arcanez: i'm sure an HTML::Mason::XS could speed things up, if someone were to sit down and hammer it out
21:49 warble after all, it's all just string concat.
21:50 Grinnz the number of capable XS coders releasing CPAN modules has never been very high unfortunately
21:51 warble Well, you gotta start out as a shitty XS coder first
21:52 Grinnz you need 1) an understanding of C, 2) an understanding of perl, and 3) extensive knowledge of the guts of perl, sadly
21:52 warble there is that.
21:53 Grinnz i happily avoid 1 and 3 myself :P
21:53 preaction it's not so bad, really. i suspect the text parsing in C bit would be the worst part
21:54 Grinnz "parsing text in C? this is why they wrote perl!"
21:55 preaction indeed
21:55 warble meh, state machine.
21:56 warble i'm sure there's some kind of parser-generator thingy that generates C
21:56 Grinnz if you write it as a standalone library, you could always use something like https://metacpan.org/pod/FFI::Platypus
21:56 preaction i mean, that's what yacc/flex/bison/etc... are, yes
21:56 arcanez do people actually use FFI?
21:57 warble Sure.
21:57 preaction yes, FFI is great
21:57 arcanez I "replaced" PLICEASE at $last_job
21:57 rshadow joined #mojo
21:57 warble I mean it's a knee jerk, but that guy said "slow", so I said "XS"
21:58 arcanez warble: I want to blame apache2 and mod_perl too :D
21:58 arcanez starman+nginx ftw
21:58 arcanez or maybe there is something better than starman now
21:59 warble all glory to ...
21:59 Grinnz people seem to like gazelle
21:59 Grinnz and for mojo stuff, of course hypnotoad
22:54 ksmadsen joined #mojo
23:23 dikim joined #mojo
23:38 jnap arcanez: I stepped back from the 'port pure.js DSL' a bit because I was finding it hard to optimize and the DSL provokes strong feelings.
23:39 jnap I'm actually working on a different approach, trying to build an API O don't hate and make the stringy DSL an optional role.  So you can skip of you don't like it.
23:41 jnap https://github.com/jjn1056/Template-Lace  the tests are all in Catalyst but the intention is for it to be stand alone.  I'm intending to use that as an excuse to get to see how hard it is to make a template adaptor for Mojolicious
23:42 jnap that's a working name only.  but the code is cleaning that Template::Pure and I'm getting something I hate a lot less for non trivial bits.
23:43 jnap the Mojolicous template would swap Mojo::DOM in of course
23:44 Grinnz i based https://metacpan.org/source/Mojolicious::Plugin::TemplateToolkit mostly on https://metacpan.org/source/Mojolicious::Plugin::EPLRenderer (though Template::Provider::Mojo is of course some wonky Template::Toolkit internals stuff)
23:46 jnap yeah it seem straightforward.  The main thing is figuring out the component stuff, but I'll need to pull that down out of the Catalyst side of the code anyway if I want it good for Web::Simple.
23:46 irqq_ joined #mojo

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