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

IRC log for #mojo, 2015-03-31

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

All times shown according to UTC.

Time Nick Message
00:00 cpan_mojo Mojo-Pg 2.02 by Sebastian Riedel - http://metacpan.org/release/SRI/Mojo-Pg-2.02
00:01 sri not happy with how pubsub works now, but don't think i can do much more with the DBD::Pg api
00:02 sri there is still a small possibility of notifications not being delivered correctly after fork
00:03 sri if you call ->listen in the parent, then fork a few processes and then start the event loops right away
00:03 Phil21 joined #mojo
00:03 sri old subscriptions only get cleared on the first ->notify, ->listen or ->unlisten call
00:03 tianon joined #mojo
00:03 sri (and old dbh)
00:04 sri *but* failures should be very obvious now
00:06 mgrimes joined #mojo
00:10 _dave_ Does anyone know offhand if Poly1305 exists in any CPAN module?
00:36 mattastrophe joined #mojo
01:03 k-man in the mojo templating, how do i output $text's value as html?
01:05 Zoffix <%== $text %>
01:05 Zoffix Use double '=' to not encode the value
01:05 Zoffix k-man, http://mojolicio.us/perldoc/Mojolicious/Guides/Rendering#Embedded-Perl
01:06 k-man ah thanks Zoffix
01:17 k-man ok, i managed to hack the HTML::Table::FromDatabase to work but I think I'm doing it in a less than good way
01:18 k-man $table = HTML::Table::FromDatabase->new( -sth => $sth );  seems to "consume" the data in $sth
01:22 cfedde Sea uchins, sharp rocks, shallower than expected,  beaned by boom,
01:23 cfedde motion sickness, broken glass.  All are more common than sharks.odd.
01:23 cfedde ww
01:23 cfedde sorry
01:23 k-man ah i see, its a cursor
01:24 k-man do you have a pefered pastebin here?
01:25 tianon joined #mojo
01:27 k-man so here is how i did it, output the table to a global $table variable http://fpaste.scsys.co.uk/470834
01:30 basic6 joined #mojo
01:30 Grinnz global? why?
01:30 Zoffix It's not global.
01:30 Grinnz either return the html you want or the data you want
01:31 Zoffix Oh
01:31 Zoffix k-man, that code made me wonder why you weren't returning the html :)
01:31 k-man Zoffix, well, I just hacked my $table into the original dbi example
01:32 k-man sorry, i'm very novice with mvc
01:32 Grinnz well this helper could be used by many controllers at once, you can't depend on a globally stored variable
01:32 Grinnz return the data you want to use
01:33 k-man right, so make a different helper to return the table i guess?
01:33 k-man i'll try that
01:33 Grinnz you could make two helpers, and have them both call a third helper to do the common functionality
01:34 Grinnz but it depends on whether you're going to use both outputs from the same query? or only one or the other
01:34 k-man just one
01:34 purl It's the loneliest number, you know.
01:34 jberger cfedde: shark kits were required on the Chicago to Mackinac race for many many years
01:35 cfedde heh
01:35 cfedde one per crew member?
01:35 asarch joined #mojo
01:35 k-man i want to make an app that my staff can use for taking customer orders and pushing them direct to the database, so the idea is to produce a table and let them fill in the qty field then submit it, this is my first steps
01:37 frederico joined #mojo
01:37 Grinnz k-man, it would be easier if you could take the output of selectall_arrayref and just pass it to that function to generate the table, then you'd only need one helper
01:38 Grinnz but i'm not sure how that all works
01:38 Grinnz i suppose it probably needs the $sth to generate headers?
01:39 jberger cfedde: any number was silly given that there are no sharks in the great lakes
01:39 cfedde jberger: of course. But regulations are often silly.
01:46 cpan_mojo Mojolicious-Plugin-ServerInfo 0.006 by Helmut Wollmersdorfer - http://metacpan.org/release/WOLLMERS/Mojolicious-Plugin-ServerInfo-0.006
01:46 * sri starts releasing sharks into the great lakes
01:47 sri http://img3.wikia.nocookie.net/__cb20140805055410/super-villain/images/9/91/3998596-dr-evil.jpg
01:50 basic6 joined #mojo
01:51 k-man so if I put somefile.js in myapp/public  how do i get it served? the doco says it gets served automatically but I don't see it in the dom inspector
01:52 k-man ah i have to put ti in the html i guess
01:52 Grinnz yes, it gets served but only if it gets requested
01:53 tianon joined #mojo
01:55 Zoffix k-man, there's also the marvelous Mojolicious::Plugin::AssetPack
01:56 k-man ooh
01:56 k-man got it working, I now have a sortable table from my database
01:56 klapperl joined #mojo
01:56 Zoffix \o/
01:57 k-man and i have to say, its 'kin cool
02:01 k-man AssetPack looks good. should i use it now or later?
02:01 Zoffix Are you using SASS/SCSS?
02:01 k-man no
02:02 k-man but I'll use css at some point for sure,so i could those
02:02 Zoffix Then use it :)
02:02 k-man ok
02:02 Zoffix It automatically calls scss preprocessor and minifies and does all the things :)
02:03 k-man very cute
02:05 Zoffix and merges multiple files into one
02:07 k-man very very nice
02:07 k-man i added it
02:07 k-man works
02:07 Zoffix \o/
02:10 cpan_mojo Mojolicious-Plugin-ServerInfo 0.007 by Helmut Wollmersdorfer - http://metacpan.org/release/WOLLMERS/Mojolicious-Plugin-ServerInfo-0.007
02:12 k-man what would an appropriate layout method be to present the user with a list of product codes, desriptions and prices and a column next to it to allow qty to order to be input? i was thinking html table at first but now i'm not sure
02:12 k-man maybe theres some better html approach to that?
02:12 Grinnz you could easily organize that as a list of divs
02:12 Zoffix Yes, HTML table
02:12 purl i guess HTML table is a great idea
02:12 Grinnz then it's just down to CSS ;)
02:12 Zoffix Why?
02:13 Zoffix I'd definitely say semantically, it's a table
02:13 Zoffix purl, divitis!
02:13 purl Zoffix: excuse me?
02:13 Zoffix :(
02:13 k-man it does feel like a table to me
02:14 Grinnz then there you go
02:16 hshong joined #mojo
02:17 jberger sri: don't forget the friken laser beams
02:18 jberger nn all, drug induced sleep arrives
02:18 Zoffix night
02:18 noganex_ joined #mojo
02:21 k-man night Zoffix, thanks for your guidance!
02:21 k-man ooh jberger was going, not you, sorry
02:23 cpan_mojo Mojolicious-Plugin-ServerInfo 0.008 by Helmut Wollmersdorfer - http://metacpan.org/release/WOLLMERS/Mojolicious-Plugin-ServerInfo-0.008
02:38 cpan_mojo Mojolicious-Plugin-ServerInfo 0.009 by Helmut Wollmersdorfer - http://metacpan.org/release/WOLLMERS/Mojolicious-Plugin-ServerInfo-0.009
02:38 sri this is getting a bit silly
02:39 sri another release of that plugin and the bot gets kicked ;p
02:39 Grinnz i still win until he does a 5th release in one day
02:39 Grinnz https://metacpan.org/source/DBOOK/Math-Calc-Parser-0.016/Changes
02:41 Grinnz oh, 6th! cpan just didnt index my 5th in time
02:41 Zoffix No you don't: https://metacpan.org/source/REEDFISH/Net-FullAuto-0.999999999992/ChangeLog
02:41 Zoffix :D
02:41 Zoffix 2278 lines
02:42 serentiy joined #mojo
02:43 serentiy I am a bit new, and struggling with something.  I continue to get "Odd number of elements in anonymous hash" when trying to query open websockets.
02:43 Grinnz haha
02:43 serentiy I am trying to keep a hash of established sessions, but keep ending up with no value being assigned
02:44 Grinnz serentiy, sounds like a syntax issue, can you paste your code somewhere? like http://paste.scsys.co.uk/mojo
02:45 Zoffix He's done 13 releases on 2013-11-29
02:46 Grinnz lol
02:46 serentiy http://paste.scsys.co.uk/470841
02:47 Zoffix That  {{row => $html} }} looks iffy
02:47 Zoffix Why so many curlies?
02:48 Zoffix ->send({json => { row => $html }});
02:48 Grinnz yeah, that's why; you made a hash reference that only consists of a hash reference
02:48 Grinnz 1 is an odd number
02:49 serentiy it's copy and paste code, I started with an example that loosely did what I wanted, and now I am trying to adapt
02:49 Grinnz see examples here: https://metacpan.org/pod/Mojolicious::Controller#send
02:50 Grinnz also sprintf "%s", $ip; doesn't do anything, particularly since it's already a string
02:52 serentiy agree on sprintf() call.  original use was doing something else
02:52 Grinnz how are you running this? if you use a prefork server or hypnotoad it's not going to work as expected
02:52 serentiy morbo
02:52 Grinnz a single process daemon it could work though
02:53 Grinnz to run it prefork, you're going to want to use something like Mojo::Pg or Mojo::Redis2 with pubsub to send those notifications
02:53 Grinnz since they'll all potentially be in different processes
02:53 sri like https://metacpan.org/source/SRI/Mojo-Pg-2.02/examples/chat.pl
02:54 Grinnz ^^ it's deceptively easy :)
02:54 serentiy the commented out line "#$ws->send({ json => {row => $html} });"  works, but only updates the browser instance that sends the update.
02:55 serentiy I want to be able to iterate through all open websockets and perform a json send to update tables dynamically
02:55 Grinnz to use pubsub all you do is subscribe on websockets when they open, and publish when you want to send to those websockets
02:55 Grinnz you don't have to worry about how to find the open ones or anything
02:56 serentiy thank you, going to read
02:56 Grinnz i set it up with redis for my project, redis and pg both just act as a relay used like this
02:57 sri for completeness sake (you're prolly not there yet), i would not store all controller instances in a global hash
02:57 sri but use a Mojo::EventEmitter to deliver messages
02:57 Grinnz yeah, thats the other reason pubsub is probably a better idea
02:57 sri if i had to do it without a database
02:57 Grinnz thats a good idea too
02:57 sri it would work the same as the Mojo::Pg example
02:58 Grinnz just not across preforked processes
02:58 sri yea
03:00 Grinnz haha, all of those releases for that plugin were to add these badges to the pod https://metacpan.org/pod/release/WOLLMERS/Mojolicious-Plugin-ServerInfo-0.009/lib/Mojolicious/Plugin/ServerInfo.pm
03:01 kaare joined #mojo
03:02 sri like this actually https://gist.github.com/kraih/db0c7e3b632e7c804fa3
03:02 Grinnz a chat example for mojo! :P
03:02 sri tempted to put it into core
03:03 sri current examples are a bit boring... all just for profiling
03:03 Grinnz i like it
03:03 Grinnz shows off websocket usage
03:03 basic6_ joined #mojo
03:15 sri i guess it could replace examples/websocket.pl
03:16 sri have not used that for browser testing in ages
03:16 k-man any idea how i can set a column heading in an html table using HTML::Table?
03:19 k-man setSectionCell maybe
03:21 good_news_everyon joined #mojo
03:21 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/jMql
03:21 good_news_everyon mojo/master 3b83c2c Sebastian Riedel: use a better WebSocket example application
03:21 good_news_everyon left #mojo
03:21 sri i also like the relation to the Mojo::Pg example
03:27 Grinnz http://grinnz.com:3000/ # it works!
03:27 Grinnz no setup required is always nice
03:27 Grinnz even though redis setup is pretty nonexistant :P
03:35 good_news_everyon joined #mojo
03:35 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/jM3n
03:35 good_news_everyon mojo/master a6cef6b Sebastian Riedel: make entities example a little more readable
03:35 good_news_everyon left #mojo
03:38 serentiy do you have the code for http://grinnz.com:3000/  ?
03:38 Grinnz serentiy, it is the example sri just committed: https://github.com/kraih/mojo/blob/master/examples/chat.pl
03:39 Grinnz as compared with https://metacpan.org/source/SRI/Mojo-Pg-2.02/examples/chat.pl and https://metacpan.org/source/JHTHORSEN/Mojo-Redis2-0.18/examples/chat.pl for Pg and Redis versions
03:40 k-man the accounting software we use is so shit, they don't trim the fields when they write them to the db
03:40 k-man so all the fields are padded with spaces
03:40 Grinnz heh
03:41 k-man its a wonder it even works
03:41 Grinnz things like that are usually also a case of garbage in, garbage out
03:43 k-man yeah
03:44 good_news_everyon joined #mojo
03:44 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/jMsD
03:44 good_news_everyon mojo/master d1b5553 Sebastian Riedel: there is actually no need to trim anymore
03:44 good_news_everyon left #mojo
03:44 sri good you mention it :)
03:44 k-man they used this 4gl to write it called uniface
03:44 k-man which has to be the most awefule 4gl known to man
03:46 k-man anyway, gtr, ttyl
03:48 serentiy I must be missing something stupid..  the send on( json => sub, does not appear to send to the subscribed websockets..
03:50 Grinnz you mean ->send({json => {} }) ?
03:51 Grinnz did you fix your extra hashref?
03:52 Grinnz that wouldnt prevent it sending, though, but really you should use either EventEmitter or pubsub, not store controllers globally, that could be the problem
03:55 serentiy agreed, I changed to pubsub, still not working as expect.  here is new code:  http://paste.scsys.co.uk/470845
03:59 sri very wrong
03:59 sri the logic is all messed up
04:00 sri a "shift" in the middle of the closure, a useless $cb, and nested subscriptions to events
04:01 serentiy I want to subscribe the websocket on connect, unsubscribe on socket close, and when data is fired, send updates to all subscribed clients
04:03 sri perhaps you should start fresh with the tutorial http://mojolicio.us/perldoc/Mojolicious/Guides/Tutorial#WebSockets
04:03 sri make it work with one websocket, and then move on to multiple
04:12 KCL_ joined #mojo
04:41 inokenty-w joined #mojo
04:46 Oleg joined #mojo
04:48 Oleg Grinnz_: "needs a Mojo::Email with non-blocking SMTP". Did you see Mojo::SMTP::Client?
04:51 Grinnz no i didn't, nice; but the problem i found shortly after is i actually need sendmail, not SMTP
04:55 Oleg hm, with sendmail i think you can do smth like open $fh, '/usr/bin/sendmail', '|-'. And use $fh pipe in non-blocking way
05:59 punter joined #mojo
06:03 melo joined #mojo
06:29 diegok joined #mojo
06:33 hahainternet joined #mojo
06:44 dod joined #mojo
06:48 tianon joined #mojo
06:48 dod joined #mojo
06:59 dotandimet joined #mojo
07:08 eseyman joined #mojo
07:08 marcusr joined #mojo
07:10 marcusr joined #mojo
07:37 marcusr joined #mojo
07:47 trone joined #mojo
07:51 berov joined #mojo
08:08 Lee joined #mojo
08:15 arpadszasz joined #mojo
08:23 Vandal joined #mojo
08:27 denny joined #mojo
09:14 stl joined #mojo
09:44 kopekru joined #mojo
09:45 meshl joined #mojo
10:05 amon joined #mojo
10:11 tianon joined #mojo
10:27 fhelmber_ joined #mojo
10:56 bpmedley joined #mojo
11:04 ashimema_ Morning.. just..
11:05 ashimema_ I'm looking for some advice on loading files in mojo..
11:05 ashimema_ Mojo::Asset::File with slurp seems perfect.. but I'm wondering the most sensible aproach to calling it.
11:05 ashimema_ I've got a series of json schema files, and want to use JSON::Schema to validate incoming requests in my api..
11:06 ashimema_ any advice on when/how best to load the schema files.. at the minute I've got a working example with the code in the controller.. but it feels sorta ikky having it in there..
11:07 yourname joined #mojo
11:07 tianon joined #mojo
11:13 Kripton joined #mojo
11:24 KCL joined #mojo
11:31 mattastrophe joined #mojo
11:39 cpan_mojo Mojolicious-Plugin-DBInfo 0.001 by Helmut Wollmersdorfer - http://metacpan.org/release/WOLLMERS/Mojolicious-Plugin-DBInfo-0.001
11:40 mattastrophe joined #mojo
11:42 batman ashimema_: have you considered Swagger2 for validation?
11:43 batman it's not obvious, but it should be able to do the validation.
11:43 batman https://metacpan.org/pod/Swagger2::SchemaValidator
11:44 batman hm... it actually just occurred to me that the module name is all wrong :/
11:45 batman not all wrong, but it's more generic
11:56 frederico joined #mojo
12:00 neilhwatson joined #mojo
12:01 ashimema_ I've had a brief look at swagger2..
12:01 ashimema_ not an in depth one though
12:03 ashimema_ do you think the swagger implimentation of validation has something over JSON::Schema?
12:03 ashimema_ in either case.. you have to get the schema's in there somehow.. it's the loading of schema files advice I'm interested in at the minute ;)
12:04 ashimema_ wondering what the best method for getting these into mojo in the first place is..  a load in the controller itself.. thus I 'think' a load of the file with every call to the routine.. unless I'm missing somthing fundamental?
12:23 batman ashimema_: JSON::Schema did not support the JSON schema definitions i needed.
12:23 tianon joined #mojo
12:23 batman it seems very in complete
12:23 batman *incomplete
12:24 batman that's why i wrote Swagger2::SchemaValidator which is actually just a generic json schema validator
12:24 ashimema_ coolios.. I'll have a play with it then ;)
12:25 ashimema_ so far JSON::Schema has ticked the boxes for me so far.. But.. i've not taxed it at all with any particularly challenging schema's yet ;)
12:26 ashimema_ I started my api documentation using RAML.. need to have a play with swagger at some point..
12:26 ashimema_ I take it your a big fan of swagger then ;)
12:27 batman you could say that... i haven't really looked around though, but also i haven't had any excuse to find something else
12:27 batman raml looks similar
12:29 ashimema_ got a demonstration of your plugin in use per chance.. I've got another project who are keen to use it too.. so I'm temtped by the switch.. but, so far they're still experimenting allot.. would be nice to see a more advanced one in action ;)
12:29 batman ashimema_: where is the raml spec? i can find a html page, not the actual data structure
12:30 cpan_mojo AproJo 0.009-TRIAL by Helmut Wollmersdorfer - http://metacpan.org/release/WOLLMERS/AproJo-0.009-TRIAL (depends on Mojolicious)
12:30 ashimema_ http://raml.org/spec.html
12:30 ashimema_ is that what you mean?
12:30 batman that's the human readable version... i need the spec in json/yaml format
12:31 batman https://metacpan.org/pod/Mojolicious::Plugin::Swagger2 <--- this is how i use swagger2 in my mojolicious application
12:32 ashimema_ hmm.. come to think of it.. i can't find a json/yaml spec for it either
12:34 batman so how can you use it? :)
12:35 ashimema_ right.. I'm confused
12:35 ashimema_ I've been writing a spec using raml markup for my app..  all you need to learn raml markup is the docs..
12:36 ashimema_ as i said.. I'm not fully aware of the difference between swagger and raml yet ;)
12:38 ashimema_ so.. where the swagger alternative of what your looking for.. i've got a feeling my wires are crossed ;)
12:38 riche joined #mojo
12:39 ashimema_ you mean this: https://github.com/swagger-api/swagger-spec/blob/master/schemas/v2.0/schema.json
12:39 ashimema_ hmm.. I've not found one for raml
12:44 batman ok
12:44 batman then i can't help you with an example on how to use Swagger2 module for RAML :/
12:49 ashimema_ oh.. i wasn't meaning using RAML.. I was meaning just a developed app that's already using your swagger2 plugin..
12:49 ashimema_ so i could take a look.. see how someone who knows what their doing uses it ;)
12:50 tianon joined #mojo
12:50 ashimema_ sorry.. I obviosly confused
13:01 batman ashimema_: have you looked at https://metacpan.org/pod/Mojolicious::Plugin::Swagger2 ?
13:01 ashimema_ currently reading it..
13:01 riche help out MojoConf by following and RT @mojoconf
13:02 frederico joined #mojo
13:02 batman ashimema_: ok. let me know if something doesn't make sense there...
13:28 riche joined #mojo
13:29 gryphon joined #mojo
13:29 denny- joined #mojo
13:32 bpmedley_ joined #mojo
13:33 cpan_mojo AproJo 0.010-TRIAL by Helmut Wollmersdorfer - http://metacpan.org/release/WOLLMERS/AproJo-0.010-TRIAL (depends on Mojolicious)
13:54 martin joined #mojo
13:57 zackiv31 joined #mojo
14:14 denny joined #mojo
14:14 tianon joined #mojo
14:16 OmarOthman joined #mojo
14:22 OmarOthman I have a question regarding classes that inherit from Mojolicious::Controller... when are these instantiated? Can I put a constructor in one of these classes? When will it be called?
14:25 GabrielVieira joined #mojo
14:28 nicomen OmarOthman: in your class, add sub new { my ($class) = shift; Carp::cluck("Stacktrace following:"); $class::SUPER->new(@_); } to print out a stacktrace of where it is called?
14:37 frederico joined #mojo
14:38 tempire So
14:38 tempire There's consensus
14:38 tempire Among people not in tech, \o seems to read as a penis
14:38 jberger :o
14:39 tempire and \o/ as the...opposite
14:39 jberger I'm inclined to say that those people are wrong
14:39 tempire SRSLY
14:39 tempire They read too much maxim.
14:39 Grinnz_ tempire: ... thats a new one
14:39 nicomen (o)(o)
14:39 nicomen (big eyes)
14:39 Grinnz_ or two, as it were
14:39 jberger does anyone still read maxim
14:39 jberger ?
14:39 tempire It's all about the articles.
14:40 Grinnz_ clearly.
14:40 purl clearly is, like, learning his shell in the wrong place ^^
14:40 tianon joined #mojo
14:40 jberger I thought that the internet pretty much killed dead-trees covered with scantily clad women
14:40 jberger now its web pages with barely clad women
14:42 preaction what's the coverage difference between scantily and barely?
14:42 Grinnz_ the point is, not much clothing
14:43 jabberwok "ya gotta have a gimmick" - Gypsy Rose Lee
14:48 tempire I've just heard another interpretation
14:49 tempire \o/ = metal hand symbol
14:49 Grinnz_ lol
14:49 Grinnz_ that's \m/
14:49 Grinnz_ unless you have a 3-fingered hand
14:49 tempire o/ = daintily holding a cup of tea with a pinky up
14:49 Grinnz_ lol
14:51 tempire I'm inclined to accept the dainty tea interpretation.
15:05 jabberwok doodling a little website engine that i want for several clients... "multi-tenant" the buzzword i think... i would like my mojolicious 'app' in one place, and each client's config, client-specific templates, images and other static files all in separate subdirectories... is there a writeup on best practices for this, or am i on my own
15:09 tianon joined #mojo
15:10 OmarOthman nicomen: Thanks for your answer. It seems that a controller's constructor is invoked on every request that needs its services!
15:10 OmarOthman I'm intrigued to ask about the reason...
15:11 OmarOthman Why does Mojolicious::Routes not cache those classes, instead of creating a class instance on every request?
15:11 OmarOthman https://metacpan.org/source/SRI/Mojolicious-6.05/lib/Mojolicious/Routes.pm => Line 132
15:12 Grinnz_ OmarOthman: that's the point; each request has a controller instance with its own stash
15:12 jberger and its own transaction
15:12 Grinnz_ OmarOthman: that prevents requests from messing with each other
15:13 OmarOthman OK, so I can think of it as a representative for the request.
15:13 Grinnz_ in a manner of speaking
15:15 sri we only cache stuff when there is an actul performance gain
15:15 sri in the greater scheme of things, instantiating an object is dirt cheap
15:16 Grinnz_ it's also easy to maintain ;)
15:17 OmarOthman sri: I completely agree, but what Grinnz_ and jberger mentioned is what I seek... the design decision... just (as a beginner) to understand the bigger picture better
15:20 meshl joined #mojo
15:20 jabberwok the best thing about Mojo is every time I dig into the source, it turns out to be Not Magic.
15:22 nicomen OmarOthman: I think what you might wonder about is, where to put things that should last over several requests? (Having a new fresh class per request is a very natural decision)
15:23 OmarOthman jabberwok: I agree, I usually am afraid when it comes to actually investigate the source code after failing with documentation, but the source code here is quite friendly, and I've started to start reading it before the documentation actually for resolving some questions.
15:23 Grinnz_ for any multiple-request consideration, you have to take into account whether you're using a prefork server, because that forces you to use something external like a database for communication
15:23 Grinnz_ if you're not, then either global or static variables can work for certain use cases
15:23 OmarOthman Grinnz_: Makes perfect sense.
15:24 nicomen that's true, in general you are restricted to a process for shared content. If you want to go further you should consider external storages
15:24 OmarOthman We are using helpers for that actually...
15:25 OmarOthman Since we are using daemon for both development and production, but thanks, that was very insightful for me!
15:25 Grinnz_ and yeah, reading the source code is usually pretty straightforward, just keep in mind that anything starting with _ or stash values starting with mojo. are intended to be internal, anything thats not public API can be changed without deprecation
15:33 sh4 joined #mojo
15:39 mattastrophe joined #mojo
16:01 risugg joined #mojo
16:03 risugg I'm sending json (with content-type=application/json), but when I call $c->req->body in my controller, it still has header info in it. So the body begins with "Host: 127.0.0.1\n{ ...}" instead of simply "{...}". I thought I could just call $c->req->body and get only the body without the headers.
16:05 batman risugg: sending json from where?
16:05 tianon joined #mojo
16:05 Grinnz_ if it's content-type application/json, you can just use $c->req->json to decode the json immediately (but you're looking for something like $c->req->text)
16:05 batman seems like you're using \n instead of \r\n
16:05 risugg $t->post_ok("/url" => json => {  a : 1 });
16:06 Grinnz_ actually yeah, it sounds like the headers are being parsed as the body
16:06 batman risugg: also \r\n\r\n need to come from the sender before the body
16:06 risugg if I do $c->req->json, it returns undef -- guess it's getting the headers as well and silently failing
16:06 batman risugg: are you absolutely sure that's what you're doing?
16:07 batman i doubt it, because {a:1} is invalid.
16:07 Grinnz_ yeah that's not valid perl syntax; the json generator takes a perl structure
16:08 risugg so my params are done before the post with $params = { a => 1, b => 2, ...};
16:08 risugg then $t->post_ok("/url" => json => $params);
16:08 mattastrophe joined #mojo
16:09 Grinnz_ use MOJO_USERAGENT_DEBUG=1 when running the test file to see what's actually being sent
16:09 risugg before this I do $t->ua->on(start => sub { ... } ) and on the request do headers->accept("application/json", headers->content-type("application/json") and authorization("basic " . encode_base64(...))
16:09 hshong joined #mojo
16:11 batman risugg: use a pastebin if you want more help.
16:12 batman you got so much missing information and typos in what you supposily do, that it's impossible to make sense of it. (at least to me)
16:12 batman ^^ "i would suggest"
16:13 risugg hopefully this will help: https://gist.github.com/rsperl/1b75f836e3c748b75b7a
16:14 batman risugg: i don't think it helps, but do you have more of those $t->ua->on(...) statements in your test?
16:14 arpadszasz joined #mojo
16:14 risugg no, that's the only one
16:15 batman got any funky plugins loaded?
16:15 batman or hooks defined?
16:15 Grinnz_ risugg: fyi you don't need to set Content-type manually if you use the json generator
16:16 Grinnz_ however i don't think that's the issue
16:16 batman also, try doing what Grinnz_ suggested: MOJO_USERAGENT_DEBUG=1 prove -vl t/yourtest.t
16:16 risugg will try debug - plugins: yaml_config and then some custom ones, but the custom ones just let me aggregate db queries
16:18 risugg Grinnz_ thanks - that nailed it!
16:18 batman risugg: where does encode_base64() come from?
16:19 Grinnz_ risugg: what's that?
16:19 purl i heard that was a much more rare case
16:19 risugg I was doing the MIME::Base64::encode_base64(...) and assiging the results directly to the the auth header, but encode_base64 puts a new line on the end.
16:19 risugg I did it outside the on(start => sub ) which I should have done anyway, did a chomp on the result, and assigned that to the auth header
16:19 Grinnz_ risugg: you use it as encode_base64($str, '') to avoid the newline
16:19 Grinnz_ risugg: Mojo::Util::b64_encode is used the same way
16:20 risugg I had an extra new line in hthe headers, and that's what hosed the parsing
16:20 risugg thanks!
16:20 Grinnz_ yeah that would do it :)
16:21 Oleg joined #mojo
16:45 martin joined #mojo
16:51 frederico joined #mojo
16:58 mattastrophe joined #mojo
17:07 dod joined #mojo
17:15 riche_ joined #mojo
17:21 disputin joined #mojo
17:41 riche joined #mojo
17:43 jabberwok joined #mojo
17:59 juikuen joined #mojo
18:13 trone joined #mojo
19:11 punter joined #mojo
19:19 disputin joined #mojo
19:19 denny left #mojo
19:19 dotandimet joined #mojo
19:46 asarch joined #mojo
20:03 cpan_mojo Mojolicious-Plugin-AssetPack 0.45 by Jan Henning Thorsen - http://metacpan.org/release/JHTHORSEN/Mojolicious-Plugin-AssetPack-0.45
20:12 ivanwills joined #mojo
20:18 genio Anyone feel like buying me a new MBP?
20:21 sri and me! ;p
20:22 pink_mist if people are buying stuff for others, throw one in for me too (I don't even know what an MBP is :P)
20:23 genio buy sri one and sri can give me his current one.  I just need a working machine
20:23 stephan48 me too please, i would resell i then ;)
20:23 genio pink_mist: macbook pro
20:23 purl i heard macbook pro was the worst name ever
20:23 Grinnz_ lol
20:23 pink_mist oh I see ... then never mind :P I'd rathe                    spacecraft about a star or planet"
20:23 pink_mist err, that was an odd paste
20:24 pink_mist ... I'd rather not have any mac stuff :P
20:24 mattastrophe joined #mojo
20:24 Adura I'd take one for free, I'd not pay with those prices.
20:25 jabberwok Apple: Embrace, Smother.  (Bypassing the "Extend" as unnecessary.)
20:25 genio Adura: meh.  I'll probably be able to sell my broken, old MBP for $800.  so... they're not as expensive as people make them out to be.  resale value is niiiiice
20:30 Grinnz_ honestly it's laptops that are expensive, not MBPs
20:30 Grinnz_ same with phones... but any other apple device ill agree is crazy overpriced
20:44 hernan604 joined #mojo
20:47 disputin joined #mojo
21:02 Grinnz_ sri: i know it's "untestable" but just ran into an issue with the "group" option for hypnotoad; our process needs multiple groups, the one that user has by default; would be ok with assigning each group manually but currently there's no way to do something like that
21:02 Grinnz_ for now i'm just running it as that user, but that would be inadequate if it needed to be on port 80
21:08 marty joined #mojo
21:09 Grinnz_ i could make a PR to either modify the usage of the "group" attr or add a "groups" attr, but i don't know if i should bother without being testable
21:13 batman joined #mojo
21:17 sri Grinnz_: yea, chances of it getting accepted are very very very very very small
21:17 sri the code would have to get simpler, or it would have to fix a serious security issue
21:21 Kripton joined #mojo
21:29 Grinnz_ sri: yeah it is not a security issue, it is a usability issue
21:29 _dave_ Newbie question: once I do $self->plugin('Config') in my mojolicious application, how do I get at the config hash directly? (e.g. merging more config data)
21:29 _dave_ or e.g. validating config data
21:30 Grinnz_ well, i suppose forcing people to run hypnotoad as root to bind to port 80 could be a security issue :P
21:31 Grinnz_ _dave_: ->config helper from DefaultHelpers, e.g. $c->config
21:31 Grinnz_ or $app->config
21:33 _dave_ So doing $self->plugin('Config') adds a method to app?
21:34 _dave_ AUTOLOAD magic?
21:34 Grinnz_ no, https://metacpan.org/pod/Mojolicious::Plugin::DefaultHelpers#config does
21:34 _dave_ ah :) thanks...I'll take a look
21:34 Grinnz_ app has a configuration already, Config plugin just interfaces with that
21:34 _dave_ It does?
21:34 purl if you say so...
21:34 Grinnz_ https://metacpan.org/pod/Mojo#config
21:35 _dave_ ah ha! That's what I was looking for. Thanks.
21:37 sri http://mojolicio.us/perldoc/Mojolicious/Guides/Cookbook#Adding-a-configuration-file
21:37 _dave_ So I could do something like $self->config->{'foo'} = bar  before $self->plugin('Config') and that would provide a default for foo
21:38 _dave_ Thanks sri, I have that page open but I really have to look at source too so I understand properly.
21:38 Grinnz_ well, the config plugin takes defaults already, https://metacpan.org/pod/Mojolicious::Plugin::Config#default
21:39 Grinnz_ and it actually replaces the app config it seems, so you wouldnt be able to set defaults before
21:39 sri what exactly is missing in this sentence? "Configuration files themselves are just Perl scripts that return a hash reference, all settings are available through the method "config" in Mojo and the helper "config" in Mojolicious::Plugin::DefaultHelpers."
21:39 _dave_ For mojo lite it was obvious where to put defaults, but I'm in your other idea Mojolicious
21:40 Grinnz_ there isnt much difference between the two
21:40 Grinnz_ Lite is just a wrapper
21:41 _dave_ Well if you really want... :)
21:41 good_news_everyon joined #mojo
21:41 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/j7sq
21:41 good_news_everyon mojo/master 3bad77c Sebastian Riedel: just a missing dot
21:41 good_news_everyon left #mojo
21:41 _dave_ Exactly what settings are available?
21:41 _dave_ Do you mean "settings in the config hash" (which are keys) or "settings for the config plugin" (which are methods)
21:42 sri wat?
21:42 purl Watt?  Watt?  I can't hear you, there's this buzzing noise where my brain should be. or https://www.destroyallsoftware.com/talks/wat
21:42 _dave_ lol
21:42 _dave_ I'm just explaining my confusion. If this is inappropriate for you guys, I'll vanish. :)
21:42 sri you're making assumptions
21:43 sri assumptions that make no sense to me
21:44 Grinnz_ _dave_: "settings in the config hash"
21:45 sri anyway, i'm out
21:45 _dave_ Right. So I parsed sri's sentence above but was unable to find a clear reference to the direct object referred to by "settings". :)
21:45 _dave_ Now I know.
21:46 Grinnz_ its a bit of a disjointed sentence perhaps
21:47 riche_ joined #mojo
21:55 good_news_everyon joined #mojo
21:55 good_news_everyon [mojo] kraih pushed 1 new commit to master: http://git.io/j7Cc
21:55 good_news_everyon mojo/master 4ba4e46 Sebastian Riedel: use two sentences
21:55 good_news_everyon left #mojo
21:56 Grinnz_ +1
21:56 purl 1
21:57 sri Grinnz_: btw. my biggest worry about adding support for multiple groups would be new security flaws i guess
21:57 alnewkirk joined #mojo
21:57 _dave_ Nice!
21:58 Grinnz_ sri: yeah, i would need to play with these $( and $) a bit
21:58 sri in fact, i already forgot how those two work exactly
21:59 sri and what portability problems they had...
22:00 sri just talking about it makes me want to get rid of that method again :)
22:00 Grinnz_ hehe
22:00 _dave_ one is the real gid and one is the effective gid
22:01 _dave_ but you likely knew that, wrong tab lol
22:06 Grinnz_ it's kind of awkward that the only core way to set groups properly is through special variables
22:11 Grinnz_ hmm, how does apache and nginx solve this problem? you don't have to manually set a user's groups for them
22:11 Grinnz_ and yet, they get all groups assigned to that user
22:12 Grinnz_ (apache or nginx user)
22:27 Grinnz_ huh... "If the master process is run as root, then nginx will setuid()/setgid() to USER/GROUP." implies that it does the same
22:32 Grinnz_ that makes me wonder how we're avoiding this problem in apache
22:32 Grinnz_ because apache is setting user/group to apache/apache in its config
22:33 Grinnz_ but it definitely has had access to these other groups
22:35 _dave_ serious synchronicity, three tabs now talking about this subject
22:35 Grinnz_ oh? heh
22:36 _dave_ I'm not sure of your outer context, but typically this kind of setuid thing happens for priv sep reasons
22:36 Grinnz_ the reasons here (and for apache/nginx) are because the manager needs to run as root to bind to port 80, but the workers should not run as root
22:37 _dave_ right ... I should have explained that is what I meant by priv set
22:37 _dave_ er sep
22:38 Grinnz_ and i just verified, that apache is getting all of the groups assigned to apache
22:38 _dave_ there's some ancilliary reasons for munging your privs, having to do with things like (e.g) running multiple wordpress sites
22:39 _dave_ for your case, if you wanted a mojo controller/action to become a specific userid when executing (not that you'd actually do that...wat)
22:39 _dave_ but it's usually that port < 1024 thing
22:40 Grinnz_ i wonder...
22:41 sri and things get more complicated with secondary groups of the root user that need to get removed too
22:41 _dave_ secondary groups?
22:42 Grinnz_ the secondary groups are the problem i'm trying to solve
22:49 sri this was a security issue https://github.com/kraih/mojo/commit/37cf15fb23139bc76731dc5b59de570a99981ec9
22:49 sri setgid() only changes the primary group, but does not get rid of secondary groups
22:50 Grinnz_ right
22:50 _dave_ ahhh
22:50 _dave_ "added groups"
22:50 sri so your process might retain privileges you're unaware of
22:50 _dave_ that is why I never switch to more than one group at a time ever ... and it's also why that group priv model is a bit weak
22:50 Grinnz_ the problem is the user's normal secondary groups are not used, which somehow apache seems to be using
22:51 _dave_ split( /\s+/, $( )
22:51 _dave_ I guess
22:51 _dave_ you guys are framework devs, so you have to be anal about this
22:51 Grinnz_ they're never even seen by the process
22:52 Grinnz_ setuid does not affect any groups
22:52 Grinnz_ so it retains root's groups
22:53 sri apache is not exactly a good example ;p
22:53 _dave_ nginx tends to be sufficiently anal about these things tho
22:53 sri i'd rather trust nginx, it's closer to our architecture
22:53 _dave_ I only support apache these days, never a fresh install of it (unless they twist my arm with economics)
22:54 Grinnz_ i dont know if nginx does the same, id have to test
22:54 Grinnz_ the documentation for either does not specify
22:54 sri i bet apache also has special windows code
22:55 sri gotta consider portability...yay...
22:56 sri (daemon command actually has --group and --user flags)
22:59 _dave_ ah crap
22:59 _dave_ since I am wheel on this machine, mojo has wheel permissions when I execute something as me
22:59 Grinnz_ yeah, don't do that :P
23:00 _dave_ can you remove group perms with system calls on FreeBSD even?
23:02 _dave_ when you aren't the superuser I mean
23:03 Grinnz_ sri: the only way i can find is to get the groups with getgrnam or getgrid, and map them through getgrnam to turn them into ids, and then use that for assignment
23:03 Grinnz_ hmm... i think i did something wrong there
23:04 Grinnz_ yeah i dont think it actually goes in that direction
23:05 Grinnz_ it basically needs to do what /usr/bin/groups does, but i dont think any of these really do that directly
23:06 Grinnz_ the getgrnam will only look up users by group, not the other way around
23:07 Grinnz_ i will play with it another time
23:20 mattastrophe joined #mojo
23:24 KCL_ joined #mojo
23:32 Grinnz clearly, what we need is a new ACL system supported by all OSes!
23:42 pink_mist Grinnz: https://xkcd.com/927/
23:43 Grinnz hehe
23:46 atom123 joined #mojo
23:47 atom12 joined #mojo

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