Camelia, the Perl 6 bug

IRC log for #mojo, 2013-07-08

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

All times shown according to UTC.

Time Nick Message
00:20 abra_ joined #mojo
00:45 shmuel joined #mojo
00:47 asarch joined #mojo
00:52 dvinciguerra_ joined #mojo
00:52 spacebat it seems my route problems on friday were caused in part by typos in filenames and setting template => 'home' instead of template => 'main/home' and so on
00:53 spacebat I thought that mojo printed out a nice somewhat tabulated breakdown of what's going on with each request on stderr in development mode
00:54 spacebat like catalyst does, but I haven't found a way to enable that, so that a general error saying no route matched can be easily debugged
00:58 jberger spacebat, it should, in dev mode
01:04 spacebat I'm starting it with MOJO_MODE=development morbo script/myapp --verbose
01:05 spacebat I get one line saying its listening, a line each time it restarts, warnings etc when they happen but that's it
01:10 spacebat the development_mode hook is called, but not so much useful output
01:11 crab MOJO_LOG_LEVEL=debug
01:11 jberger oh, you known what, the 404 screen wont probably help when the problem is the wrong template path
01:12 jberger because its routing correctly, just not rendering correctly
01:12 spacebat I wish it said that :)
01:14 spacebat MOJO_LOG_LEVEL=debug hasn't changed the output
01:15 spacebat oh that's because it defaults to debug and I hadn't changed it
01:15 spacebat so I'm in development mode with a log level of debug, no tabular output of what's going on on stderr
01:16 jberger is it logging to a log directory?
01:17 spacebat this is a freshly generated app from mojolicious 4.17 on friday, I haven't changed any logging config, where would it log to by default?
01:17 jberger if a directory named log exists, then it will log there
01:18 jberger if not it should log to one of STDOUT or STDERR (I can't remember which)
01:19 spacebat ok there's log/development.log, there's heaps of stuff in there, that's good
01:19 spacebat trying not to be annoying, but there's nothing tabular in there
01:23 spacebat this is the sort of thing I'm looking for - perhaps I'm remembering wrong that mojolicious used to do this http://www.perl.com/pub/2005/06​/02/graphics/log-screenshot.gif
01:25 spacebat its no biggie if it doesn't, with the development.log in hand I'll have a much better time debugging my app
01:30 zivester joined #mojo
01:55 d4rkie joined #mojo
01:56 d4rkie joined #mojo
01:56 Meiermann joined #mojo
02:30 crab spacebat: it doesn't do that.
02:30 crab unless there's some plugin i don't know about, it's never done that
02:31 crab it does log the equivalent output, just not with ascii boxes.
03:15 spacebat crab: my memory must be shot, yes the development log is sufficient thanks guys
03:23 crab i think space ghost once fought a swarm of space bats
03:24 crab huh. seems they were just called giant bats.
03:58 preflex_ joined #mojo
04:26 spacebat so long as they were in space
04:26 spacebat there was a space bat angel dragon in ted hughes' The Iron Man
04:27 spacebat what's the best way to implement a catch-all route - I have a route with :action in it which lets me go to any non-hidden action in a controller
04:28 spacebat but when I name an action that doesn't exist, I get the default template I specified in the stash, presumably rendered by some default action from the superclass
04:29 spacebat I'd like a simple controller to have just one route, and if you go to an illegal name, go to an error handler/action of some sort
05:00 crab i don't really understand the question. do you want a catch-all, or a catch-one?
05:12 spacebat catch anything that is not a valid action
05:20 crab where valid means?
05:21 marcus_ sri: I know it's only at compile time, but the second class that does use Mojo::Base qw/Mojo::Message/; will do that regex without needing to do the require it's for, no?
05:21 Meiermann joined #mojo
05:21 spacebat valid means there is an action by that name on the controller
05:22 spacebat say I have controller Main with methods foo and bar
05:23 spacebat I have a route that looks like /:action which lets me choose between them, and I populate the stash with template => 'main/default'
05:23 marcus_ sri: I meant that the regex should be wrapped into the ->can('new'), https://github.com/kraih/mojo/commit/af​05ad537a53e97c612f1d9bd0c604ef6315bc72 doesn't seem useful, as you say (since we always have a flag)
05:23 spacebat but if I go to /baz, I get the default template only no action has been run in the Main controller
05:24 spacebat I'd like to intercept the 'no action found' mechanism and go to main#whoops
05:27 marcus_ sri: something like https://gist.github.com/marcusramberg/5946393 - or even without the first condition.
05:27 crab there's no "no action found" mechanism. if you create a catch-all route, it catches all. you set a template, so it renders it even if it doesn't have an action.
05:27 crab if you don't want that, don't create a catch-all route.
05:28 crab you can add a restriction to your :action by adding action => [qw/foo bar baz/] or so to your route definition. (or maybe it has to be a regex, i forget. look at the routing guide.)
05:28 marcus_ o/ crab
05:29 crab or route everything to an action that does the checking for you.
05:29 crab hi marcus. how are you?
05:29 spacebat so, introspect the controller class to get the action names
05:30 spacebat I was hoping to avoid that but ok - I was abusing catch-all
05:31 crab i prefer to spell out my routes, rather than using wildcards.
05:32 spacebat I started not liking adding an action to the controller, then adding a template to the template tree, then remembering to go create a route for it
05:32 spacebat trying to be a bit more dry
05:33 crab *nod*
05:34 crab you could even add a routing shortcut that does something like if ($blah->can($action)) { ... } else { render_not_found (or whatever) }
05:35 spacebat that's a good idea
05:35 crab turn it into a plugin and put it on CPAN with a picture of a giant bat
05:35 spacebat roger that
05:42 Britzel joined #mojo
05:49 davido joined #mojo
05:51 Britzel_ joined #mojo
06:00 basiliscos joined #mojo
06:01 spacebat joined #mojo
06:04 bpmedley https://gist.github.com/brianmed/5946528  <-- Would this work as a catch-all route?
06:18 dpetrov_ joined #mojo
06:21 marcus_ crab: I am not so bad. A bit in summer mode
06:22 marcus_ crab: Was in the swedish archipelago this weekend. Great times were had =]
06:37 Vandal joined #mojo
06:42 crab marcus: good to hear. i'm waiting for the rains to start here. the monsoon was officially announced, and there was one heavy rain and then... nothing.
06:43 dod joined #mojo
06:59 dod joined #mojo
07:00 maxhq joined #mojo
07:07 iSlug joined #mojo
07:12 rihegher joined #mojo
07:19 basiliscos joined #mojo
07:23 Tiger joined #mojo
07:25 batman bpmedley: you could do just any '/*catch_all' => sub { ... };
07:25 marcus_ crab: sounds fun.
07:27 crab https://github.com/kraih/mojo/wiki/logrotate talks about using logrotate with mojo
07:28 crab but it doesn't say to send USR2 to hypnotoad. isn't that rather important?
07:32 batman crab: not when you have copytruncate
07:34 dod joined #mojo
07:38 crab ah. hm.
07:38 hrupp_ joined #mojo
07:39 trone joined #mojo
07:40 ver joined #mojo
07:41 Dandre joined #mojo
07:51 sri marcus_: ah, guess that makes sense
07:53 good_news_everyone joined #mojo
07:53 good_news_everyone [mojo] kraih pushed 1 new commit to master: http://git.io/IHJQ-w
07:53 good_news_everyone mojo/master c3e0ee2 Sebastian Riedel: small optimization
07:53 good_news_everyone left #mojo
08:05 iankent qq, is there a way to determine if a response has been rendered? currently got one controller delegating to another controller, but only want the first controller to render a response if the second doesn't - could use stash, but hoping mojo already knows!
08:06 marcus_ sri: found a nice iphone app that can download github repos to your phone and let you read the source while offline. Unfortunately the syntax highlighter does not support perl yet. :-/
08:07 sri (╯°□°)╯︵ ┻━┻
08:07 iankent nvm, think I want stash -> mojo.rendered
08:08 sri mojo.* stash values are internal
08:08 marcus_ they say it's on the roadmap, as well as private repos. Will be super neat then. NapCat
08:09 arthas joined #mojo
08:15 crab if i declare a route, say $secure = $r->bridge->to('auth#requi​re_https')->name('secure')
08:15 crab and then $auth = $secure->bridge->to('auth#r​equire_user')->name('auth')
08:15 crab and then do $secure->route('/somethingelse')->blah()
08:16 crab (note, $secure->, not $auth->)
08:16 batman iankent: maybe you can check length $c->res->body ?
08:16 crab am i missing some obvious reason why it should still go through auth#require_user? surely that shouldn't happen?
08:17 sri crab: that shouldn't happen
08:23 sri crab: does it really?
08:28 crab sri: i must be doing something wrong, but i can't figure out what.
08:28 crab in a minimal test with cb => sub ... for my bridges, it doesn't happen
08:28 sri i just tested it and couldn't find a bug
08:31 jzawodn joined #mojo
08:31 crab wonder how to debug. the ./myapp routes output looks sane, in that the 'auth' route is at the same indentation level as the last route.
08:32 crab oh, i bet something's adding a wildcard route under the first bridge somewhere.
08:32 arthas_ joined #mojo
08:33 sri you can always check the stack
08:33 sri $self->match->stack
08:34 sri and $self->match->endpoint->name
08:45 Dandre hello,
08:50 iankent batman: using mojo.rendered seems to work, half my code relies on mojo internals anyway so not too worried
08:51 batman ok. hope you got unit tests :)
09:02 sri iankent: i hate you
09:04 sri but seriously... if your code relies on internals you a) are doing things wrong or b) should be proposing new features
09:07 sri might be a valid reason to pull an mlehmann, and rename those stash values intentionally with every release
09:07 sri just to get folks to make feature proposals
09:07 iankent sri: thanks, I think ;)
09:07 iankent sri: we're just doing some weird and complex stuff
09:07 iankent sri: only one feature which comes out of it atm would be to 'forward' to other controllers internally, atm we're using mojo::loader and calling actions manually
09:08 sri you're doing it wrong
09:09 sri with the around_dispatch hook forward and/or detach could be implemented just like in catalyst
09:09 iankent sri: i'd be inclined to agree we're doing it wrong, but we're just spiking a new feature so its all throwaway code anyway
09:11 sri anyway... mango release time
09:11 iankent in summary, we have three chained bridges, and if the final bridge detects specific parameters and session/stash values, we call a named controller before continuing the route - not even sure around_dispatch helps there
09:13 sri absolutely trivial with around_action
09:14 iankent thanks, will have a look!
09:15 iSlug joined #mojo
09:16 good_news_everyone joined #mojo
09:16 good_news_everyone [mojo] kraih tagged v4.18 at 04c02a0: http://git.io/N0-QtA
09:16 good_news_everyone left #mojo
09:23 sri yay, first time releasing mojo and mango together \o/
09:28 dotan joined #mojo
09:32 Vandal joined #mojo
09:32 crab mojongo
09:33 sri mangolicious!
09:35 iSlug joined #mojo
09:38 mire__ joined #mojo
09:39 Dandre joined #mojo
09:40 sri btw.
09:41 sri still looking for feedback on the gridfs api
09:41 sri http://pastie.org/8118568
10:18 fhelmber_ joined #mojo
10:25 crab well, subject to my not knowing the first thing about gridfs, that looks very nice.
10:44 sri \o/
11:09 Tiger joined #mojo
11:19 bpmedley joined #mojo
11:42 libsysguy joined #mojo
12:00 batman sri: instead of having writer/reader, why not just have open($mode, $file) ?
12:01 batman the object returned could then be a tied filehandle
12:05 ChinaXing joined #mojo
12:08 sri batman: why?
12:08 sri tied filehandle sounds absolutely terrible
12:10 batman yeah, not a big fan of tie() either, but about open(): the file could then be opened in read/write mode
12:10 sri that's not how gridfs works
12:11 batman who cares? the api could still work like that.
12:11 batman not sure what sugary stuff you got planned on top, but i'm just thinking fewer methods and more convenience
12:12 sri it just doesn't work
12:13 sri the api i pasted is just the blocking version btw., as usual you can pass a callback to everything to make it non-blokcing
12:14 SmokeMachine joined #mojo
12:15 batman i don't get why "it just doesn't work"...
12:15 batman but i just wanted to give some feedback. not a big mongodb user anyway :)
12:15 SmokeMachine joined #mojo
12:16 sri yea, i guess my expectations were a little off, what i need is feedback from folks that have used gridfs already
12:17 batman right
12:17 * batman shuts up :)
12:18 sri and considering i need a non-blocking capable api... that leaves users of the node.js client :S
12:20 mire__ joined #mojo
12:21 sri i now need 6 blocking/non-blocking hybrid operations for the whole api, that's not too bad, everything else is just attributes
12:22 d4rkie joined #mojo
12:22 sri write: write(), close()... read: open(), read()... other: list(), unlink()
12:23 sri close() and open() handle metadata, write() and read() the chunks
12:34 dim joined #mojo
12:49 abra joined #mojo
12:51 levabalkin joined #mojo
13:25 espent joined #mojo
13:26 marcus_ sri: gridfs greatly excites me.
13:29 sri heh, just when i was starting to wonder if maybe i should leave out gridfs for now ;p
13:39 marcus_ my timing rocks.
13:55 dvinciguerra joined #mojo
13:56 btyler joined #mojo
14:18 doby joined #mojo
14:21 jamesw joined #mojo
14:23 abra_ joined #mojo
14:30 punter joined #mojo
14:46 rem_lex| joined #mojo
14:51 bluescreen joined #mojo
14:52 mire__ joined #mojo
14:55 * marty goes to download the latest version of mango.   :)
14:55 marty sri++
15:13 whitebook joined #mojo
15:22 sh4 joined #mojo
15:42 asarch joined #mojo
16:16 sri marcus: oh, almost forgot, what do you want to use gridfs for?
16:16 sri use cases would be rather interesting for the api design
16:17 sri marty: thoughts on the gidfs api? :)
16:19 sri http://pastie.org/8121588 # i've actually changed some things
16:20 sri (explicit open call)
16:20 laouji joined #mojo
16:24 sri open(), write(), read(), close(), list() and unlink() are blocking/non-blocking hybrid operations
16:24 marty sri:  I wish I could be more help however, I've not used gridfs much at all so I am quite clueless.  But from looking at your examples I do like $reader->open
16:25 sri open/close calls are for getting/setting metadata
16:25 sri that's why they are not required for both
16:26 marty interesting
16:27 sri seek() and tell() operations for example will not require any i/o, since we read the metadata on open() and keep block sizes/ids in memory
16:28 sri you can't change gridfs files once they are written, just store new versions, that's why i split it into reader/writer, there's really not much shared code
16:30 marty that will work really well for file versioning setups
16:33 sri hmm, maybe open and close are bad names
16:33 sri maybe something like load and store
16:43 dvinciguerra joined #mojo
16:44 espent joined #mojo
16:44 crab lda and sta!
16:58 tianon sri: I think your GridFS api looks smashing so far :)  (especially in the context of streaming these GridFS chunks straight through Mojo to the browser)
16:59 tianon sri: you're planning on some way of accessing or querying on arbitrary metadata, too, right?
16:59 sri tianon: got an example?
17:00 tianon sri: figured that would be your next question, so I'm looking for a good one online now :)
17:00 tianon if I can't find one, I'll write one and see if you agree or just puke on me :P
17:00 sri gridfs doesn't have much metadata
17:00 tianon doesn't the spec support arbitrary document data beyond filename?
17:01 tianon I thought content type itself was just a common convention
17:01 sri http://docs.mongodb.org/manual/refer​ence/gridfs/#gridfs-files-collection
17:01 sri that's about it
17:01 sri oh wait
17:01 tianon ah, it's just optional
17:01 sri metadata field ;p
17:01 tianon aha :)
17:02 tianon that's what I was thinking of :)
17:02 sri querying is trivial, but don't think any implementation does so far
17:02 tianon the 10gen driver isn't a shining example, but: https://metacpan.org/module/MongoD​B::GridFS#find_one-criteria-fields
17:03 sri hahahahahahaha
17:03 tianon here's a much better example: http://godoc.org/labix.org/v2/mgo#GridFS.Find
17:03 sri look at the code, it's beyond terrible
17:03 tianon oh, I try not to because it always makes me cry :P
17:03 sri it's just a normal find_one on the files collection
17:03 tianon haha, that's beautiful :)
17:04 tianon lol so it is
17:04 tianon that would explain why they didn't bother with ->find and only did find_one
17:04 tianon find_one is easy with such a backwards hack
17:15 abra joined #mojo
17:31 dod joined #mojo
17:40 bluescreen joined #mojo
17:53 laouji_ joined #mojo
18:06 abra_ joined #mojo
18:20 btyler_ joined #mojo
18:31 denisboyun_ joined #mojo
18:31 tianon sri: you're planning on some method to grab files directly by _id, especially since filename is optional, right?
18:38 sri tianon: yea
18:39 tianon sri: ok, then my concerns have been heard and I trust your judgement :)  sri++
18:39 trone joined #mojo
18:41 sri python driver does get($oid), get_last_version('foo.txt') and get_version('foo.txt', 2)
18:49 sri i'm already at the point where i can insert documents blocking, first version is going to be a little less nice... since i want to keep it minimal
18:49 sri it's actually oid based only atm
18:51 sri http://pastie.org/8121996 # very pragmatic
18:53 sri might actually leave out list() too at first
18:53 sri convenience can be added later
18:55 sri oh right, list() is just a shortcut :)
18:56 sri my $filesnames = $mango->db->gridfs->files->​find->distinct('filename');
18:56 sri \o/
18:58 sri i suppose everythign will be trivial once i have the writing and reading finished :)
18:59 sri doing it non-blocking is going to annoy the hell out of me
19:09 Jonis can you send a get request with custom headers?
19:18 batman Jonis: yes. https://metacpan.org/module/Mojo::UserAgent#start
19:18 tianon sri++ # <3
19:20 Jonis batman: oh nice, thanks, I read through that earlier but must've missed it
19:21 batman Jonis: np.
19:21 batman Jonis: you can also build a custom $tx, but i think it's easier to use the start event...
19:23 sri DNT is a custom header *cough*
19:23 mire__ joined #mojo
19:23 sri https://metacpan.org/module/Mojo::UserAgent#get
19:23 sri look closely
19:23 batman oh crap.
19:24 Jonis oh damn
19:24 batman Jonis: i will go back to fixing my computer. ignore me :P
19:24 Jonis batman: hey, got me further than I was. Then sri showed up and told us ;)
19:25 Jonis does custom header field allow for multiple custom headers?
19:26 Jonis { header1 => 'foo', header2 => 'bar' } ?
19:28 good_news_everyone joined #mojo
19:28 good_news_everyone [mojo] kraih pushed 1 new commit to master: http://git.io/YmLoRQ
19:28 good_news_everyone mojo/master 9592e9a Sebastian Riedel: mention that DNT is a header
19:28 good_news_everyone left #mojo
19:29 Jonis :D
19:29 sri (╯°□°)╯︵ ┻━┻
19:37 libsysguy left #mojo
19:38 sri i really don't like complex non-blocking operations
19:39 sri hope it's ok if i move the ensure_index call to close() in the writer
19:39 sri then there's just one potential insert in write() and 5 chained non-blocking operations in close()
19:41 sri oh no... there's multiple possible inserts in write()
19:41 sri since the chunk may exceed the maximu chunk_size
19:42 sri yea, i really wouldn't mind coroutines in perl right about now ;p
19:43 BeDa joined #mojo
19:48 punter joined #mojo
19:50 punter I saw on twitter that sri was the evil mastermind behind Catalyst. When should we use Catalyst instead of Mojolicious?
19:50 sri when you like catalyst
19:52 punter ok
19:57 jast joined #mojo
19:59 sri hmm, maybe if i commit the blocking api tonight... there will be a pull request with non-blocking support waiting for me tomorrow :)
20:02 mire_ joined #mojo
20:03 sri that's me, always the optimistic one!
20:04 bjoernfan sri: :)
20:14 espent joined #mojo
20:22 tm joined #mojo
20:23 sri well, my basic blocking reader is working too now \o/
20:29 sri http://pastie.org/8122252 # most minimal version i could come up with
20:31 espent joined #mojo
20:39 espent joined #mojo
20:40 mire_ joined #mojo
20:44 BeDa joined #mojo
20:59 mire_ joined #mojo
21:13 tba sri: re this http://irclog.perlgeek.de/​mojo/2013-07-08#i_7302338, if you've got a few minutes, could you have a look at use case https://gist.github.com/ian-kent/5952536 - can't quite see how either around_action or around_dispatch could help me, i'm probably wrong but I might have a use-case for delegating to routes internally!
21:39 bowtie_ joined #mojo
21:51 punter I'm writing mojo-tests for my new API service endpoints. I wish there was a way to output plaintext error messages in the response bodies, rather than fancy HTML w/ CSS, since all I have to work with is the TEXT CONSOLE
21:51 punter Is there a way?
21:52 punter just the confess output would do
21:52 punter $SIG{__DIE__} = confess, and then let us have the confess output in the body on error 500
21:53 punter (or something similar to that)
21:54 punter I think $ENV{error_mode} (=html or plaintext) should be used by mojolicious
21:54 punter (or something similar)
21:56 punter Because how else can an API programmer write his tests?
22:14 punter Has anyone succeeded to make use of the AccessLog plugin's set_username method in a Mojolicious webapp? (not Mojolicious::Lite)
22:15 punter I followed the instructions on the plugin's POD page precisely, and keep getting: Can't locate object method set_username via package <my-controller-module>
22:16 punter Can't solve it in any way
22:19 batman punter: define your own template https://metacpan.org/source/SRI/Moj​olicious-4.18/lib/Mojolicious/templ​ates/exception.development.html.ep
22:19 batman should do the trick...
22:19 punter I do: a
22:20 punter yes
22:20 punter ok
22:21 whitebook joined #mojo
22:21 punter Could be more automatic though (I mean, the template could already exist)
22:22 punter I'll try to make it, and then share with all
22:24 punter Seems like a hard job for a beginner
22:24 punter like me
22:26 punter The AccessLog plugin seems to be working, because it outputs access.log lines on the screen, but $c->set_username inside $app->hook(around_action => sub{...}) brings this error "method set_username not found"
22:27 * sri has committed what he has so far https://github.com/kraih/mango/commit/7​3b408142f2fecc88dd5c16b58ced45a1b78bafc
22:27 sri not usable at all, but you get the idea where things are heading :)
22:28 lukep joined #mojo
22:30 sri the plan is for 0.06 to have full support
22:31 sri kinda funny that it's already better than the official driver ;p
22:36 tianon \o/
22:38 tianon sri: fyi, lib/Mango/Database.pm line 138 -- my $gridf ... should be my $gridfs :)
22:38 sri OMG
22:38 tianon I'm stoked, Mango is way better than the 10gen driver :P
22:40 tianon sri ftw \o/
22:40 sri i just hope 10gen does the right thing... not selling out to oracle... and merging with tokumx
22:40 sri \o/
22:45 cfedde All Your Data Are Belong To Us -- Larry Ellison.
23:08 espent joined #mojo
23:15 batman sri: why isn't chunks() and files() attibutes?
23:15 batman *attributes
23:16 batman inside GridFS.pm
23:19 batman oh. it's way to late :/ *ttyl*
23:26 jberger sri+= 2
23:26 jberger big day!
23:27 marty I hope that 10gen does the right thing also, cuz the rethinkdb wire protocol is crazy complicated.
23:28 sri batman: dunno, guess they could be
23:29 sri not even sure i want those public though
23:30 jberger any thoughts on a name for (yet another) generator module on CPAN
23:30 jberger ?
23:30 sri yagm
23:30 * jberger has been reading too much Python and Coro lately
23:31 jberger hahah
23:31 jberger proof of concept: https://gist.github.com/jberger/5952868
23:32 sri oh, based on Coro... for a moment i was hoping it would be something entirely new
23:33 jberger nope sorry
23:33 jberger how else would one do it?
23:33 sri crushing my dreams
23:34 jberger also the few I see using Coro are not how I would do it
23:34 * jberger digs out the old "dreaming inflater"
23:41 jberger what about Generator::Object ?
23:41 jberger its an OO generator
23:42 whitebook joined #mojo
23:42 preaction sounds like it would work. or Generator::Object::Coro, with a future Generator::Object::Mojo or something
23:43 jberger preaction, something for thursday :-)
23:43 preaction indeed
23:43 * jberger steals from other languages

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