Camelia, the Perl 6 bug

IRC log for #mojo, 2012-04-12

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

All times shown according to UTC.

Time Nick Message
00:19 John code in plugin: $app->helper(lang => sub { my $self = shift; $self->app->log->debug($self->r​eq->headers->accept_language); });
00:20 John code in controller: $self->app->lang();
00:20 John i see empty string in debug logfile
00:22 athenot_ joined #mojo
00:23 xaka1 joined #mojo
00:23 perlite joined #mojo
00:25 jwang joined #mojo
00:39 Liam If a user follows a certain bridge, I want to declare a "$user" object and make it accessible on every page. I do not want the object to be declared when the user is signed out. What's the best way of doing this?
00:39 Liam right now I have a helper that just "return undef;" if the user is logged out.
00:58 scott joined #mojo
01:31 mattastrophe joined #mojo
01:42 abbe joined #mojo
01:44 sven^ joined #mojo
01:45 SmokeMachine joined #mojo
01:48 sri joined #mojo
01:49 augensalat joined #mojo
01:50 al joined #mojo
01:50 plu joined #mojo
01:55 zivester joined #mojo
01:56 keedi joined #mojo
01:58 jp joined #mojo
01:58 jp is it possible to get the unprocessed query string out of mojolicious?
01:59 d4rkie joined #mojo
01:59 perlite joined #mojo
01:59 John jp: $ENV ?
01:59 purl $ENV is a var
01:59 jp i have a url with a ? on the end of it (http://example.com/one/two/three? and i would like to have the ? available when i process the request url
02:00 jp John: i tried dumpering $ENV from within mojolicious, but i got nothing
02:02 jp does mojolicious provide a method to see the raw, unprocessed, query string?
02:06 jp it would seem that $req->env is only availabe in a CGI or PSGI setup
02:06 John mb http://search.cpan.org/~sri/Mojo​licious-2.80/lib/Mojo/Headers.pm to help u
02:06 jp im running this in hypnotoad
02:07 zivester joined #mojo
02:09 scott_ joined #mojo
02:09 sshaw jp: AFAIK there isn't a universal way to get this
02:10 sshaw doing so will be dependant on the server
02:10 sshaw i.e., something like REQUEST_URI
02:12 jp sshaw: there isn't a universal way to get this out of mojolicious?
02:12 jp i just need mojo to spit it out, its gotta be in there somewhere :)
02:13 buu I wonder what the http rfc says about a single quote
02:13 buu er, single question mark
02:13 buu jp: What does $tx->req->url give you?
02:15 jp request i made: /ss/hi?
02:16 buu welp?
02:17 jp $tx->req->url: [Wed Apr 11 22:14:55 2012] [debug] /ss/hi
02:17 jp if i put two ?
02:17 jp i get both of them back
02:17 jp in fact
02:17 jp if i put anything after ?
02:17 jp i get the ?
02:17 jp but i won't get it if its at the end
02:17 sshaw jp: well, yes: $self->req->url->query
02:18 sshaw but as you see, it can be quirky
02:18 jp apparently :(
02:20 jp i know mojo sees it though
02:21 jp it populates "query" in the Mojo::URL object
02:21 jp it populates it with nothing, but its not undef
02:22 sshaw jp: i seem to remember that when using CGI under Apache:
02:23 sshaw http://localhost?a
02:23 sshaw $self->req->url->query = '?a='
02:24 sshaw jp: nevertheless, why not just add '?' if it's not there?
02:24 jp mmmm
02:24 jp its a long story
02:25 jp but here's the short version
02:25 jp i making something that accepts the text to shown from the url
02:25 sshaw purl: $_?
02:25 purl hmmm... $_ is The best way to pronounce $_ is usually "it" or a bit like a default invocant
02:25 jp so now im having a problem when people write out a sentence ending in a ?
02:29 zivester joined #mojo
02:34 sshaw jp: so a url with a query string of "bad?" shows up as "bad"
02:37 buu I thought you just said req->url showed you the query string
02:46 zivester joined #mojo
02:50 jp mmmm
02:50 buu jp: Anyway the point is that whatever you're going to get is going to be in ->req someplace
02:51 jp sshaw, yes, it shows up as bad
02:51 jp buu, its there, but the raw query isn't
02:51 jp by the time i look in ->req, its already been parsed
02:52 buu jp: print Dumper ->req; it's probably in there someplace.
02:52 jp tried that
02:52 buu Or go read the source code to see how Req is created
02:52 jp buu: yes, that seems like my last option
02:52 zivester joined #mojo
03:08 sshaw jp, buu: let me know if you find it, but I don't think it's possible
03:08 sshaw the request path is passed off to Mojo::URL, which is where the problems are
03:08 sshaw (or were)
03:09 sshaw (i looked into this last year for digest auth)
03:10 sshaw jp: i'd like to think that your problem isn't with mojo... can you create a test case that shows your problem?
03:28 jp sshaw: will do
03:43 abbe joined #mojo
03:54 al joined #mojo
03:54 sri jp: $self->req->env
03:54 xaka1 joined #mojo
04:02 sri oh Hypnotoad
04:02 purl ALL GLORY TO THE HYPNOTOAD!!!
04:02 sri jp: then it makes no sense and is not available
04:22 jp sri: i don't think evn i available
04:22 jp unless im runnng it under cgi or psgi
04:23 jp sri: i don't think env i available
04:23 sri i thought your question was psgi/cgi specific
04:23 sri but even then a single ? makes no sense
04:32 Leandr joined #mojo
04:33 jp i agree
04:51 Gedge joined #mojo
05:02 ask joined #mojo
05:10 ask Hi, shouldn't sub foo { ... }; $r->bridge('/')->to(action => 'foo'); be the same as $r->bridge('/')->to(cb => sub { ... });   ?
05:10 ask When I use the first version my code just hangs; when I use the cb => ... syntax it works.
05:11 ask (the bridge is doing basic authentication with Plugin::BasicAuth)
05:24 sshaw joined #mojo
05:28 sshaw turns out the CGI problem I mentioned earlier is normal behavior
05:28 sshaw say Mojo::Parameters->new->parse('x');
05:28 sshaw x=
05:29 sshaw well, not normal, but expected...
05:31 ask (I confused my app class with the controller one; converting a Dancer app)
05:31 ask sshaw: what else should it do?
05:36 sshaw mistakenly use it to get the query string via $self->req->url
05:36 sshaw
05:38 sshaw err... help return the query string
05:43 sshaw well, it makes sense that it returns what it does, but with req->url->to_string its a surprise
05:59 tabbi joined #mojo
05:59 tabbi left #mojo
06:22 GitHub33 joined #mojo
06:22 GitHub33 [mojo] kraih pushed 1 new commit to master: http://git.io/NgvWYQ
06:22 GitHub33 [mojo/master] removed a few debug messages - Sebastian Riedel
06:22 GitHub33 left #mojo
06:33 dbr joined #mojo
07:00 GitHub50 joined #mojo
07:00 GitHub50 [mojo] kraih pushed 1 new commit to master: http://git.io/8SgwPA
07:00 GitHub50 [mojo/master] made WebSocket debug messages less verbose - Sebastian Riedel
07:00 GitHub50 left #mojo
07:07 fhelmber_ joined #mojo
07:07 spleenjack joined #mojo
07:08 ver joined #mojo
07:11 batman joined #mojo
07:28 vifo joined #mojo
07:29 batman i'm trying to set accept header in $.ajax() to application/json, but it still sends "application/json, */*; q=0.01" to the server
07:29 batman any idea how to fix this in jquery?
07:32 vifo either  $.ajaxSetup() or override beforeSend in $.ajax
07:33 batman i think i will give beforeSend a try...
07:33 batman i don't see how ajaxSetup() can fix this?
07:37 vifo you might check for $.ajax({ accepts: '...' }) or $.ajaxSetup({ accepts: '...' }) whichever might work
07:38 batman doesn't work. but what did work is this: { headers: { Accept: "application/json" } }
07:42 vifo hmmmmm, thought this was for additional headers only, and Accept was already set
07:47 cosmincx joined #mojo
07:52 ask batman: did you mean something else?  "application/json, */*; q=0.01" sounds like a reasonable header if you want "application/json".
07:54 batman ask: respond_to() does not seem to understand it.
07:54 Vandal joined #mojo
07:54 ask batman: weird.
07:55 batman :)
07:55 ask Is it possible to disable the format stuff in a route?  I want to match /foo/:placeholder where placeholder is a domain name; having to concatenate the TLD back on is pretty goofy.
07:55 ask I tried format=>0, but that just makes it not match anything with a .
07:56 * ask &  # will read replies later.
07:56 batman *placeholder maybe?
07:56 batman isntead of :placeholder
07:56 ask batman: yup, that's it.  thanks!
07:56 ask how do I make 'placeholder' optional then?
07:56 ask do I need a second route?
07:57 batman add a default
07:57 batman route('foo/*bar', bar => ''); iirc
07:58 batman or is it in to()... can't remember :/
07:58 hugh joined #mojo
07:58 ask batman: in to() ... brilliant, thanks!
07:58 * ask & # ZzZ for real.
07:59 batman :)
08:21 batman is there a way to prevent a route() from matching an extension?
08:21 batman as in route("foo/bar") not matching "foo/bar.html" ?
08:23 sri batman: http://mojolicio.us/perldoc/Moj​olicious/Guides/Routing#Formats
08:24 batman ah. of course!
08:24 batman thanks
08:26 batman or... wait a sec. will this fix it: route('foo/bar', format => 0)->to('foo#bar', format => 'html') ?
08:39 batman http://www.websequencediagrams.com/ # cool :)
08:52 azawawi joined #mojo
10:28 daxim joined #mojo
11:08 daxim http://stackoverflow.com/questions/10113267/is-​there-only-one-transport-type-for-mojoxsession
11:13 sri batman: at some point (4.0?) we will make formats opt-in i think
11:16 sri still one big design problem i've not yet solved though
11:16 sri how to capture an optional format with a placeholder
11:17 sri ->route("/foo.:format")->to(format => 'html')
11:17 sri how to get rid of the dot?
11:18 sri that route would only match "/foo.", "/foo.html" and "foo.whatever", but not "/foo"
11:19 sri if anyone here has an idea i'm very interested in it ;)
11:30 batman couldn't you add a different capture? instead of : and * i mean...
11:30 batman s/instead of/in addition to/
11:31 sri please elaborate
11:34 batman like route("foo&placeholder") or something, where &placeholder match the extension
11:34 sri oh, a placeholder that removes the . at the beginning?
11:34 batman or what about just "foo(*placeholder)" ?
11:34 batman yes
11:35 batman so it matches "(?:\.(\w+))? or something
11:35 sri (*placeholder) is the quoted version of wildcard, which we already use
11:36 batman ok. guess i missed out on that from https://metacpan.org/module/​Mojolicious::Guides::Routing :/
11:36 sri picking a prefix character would be very hard though
11:36 batman what does "quoted version" mean?
11:36 batman yes. it would be very hard :(
11:36 sri /foo(*whatever)bar/lalala
11:37 batman ah.
11:37 sri currently i think there are only two characters available
11:37 batman what about "foo**placeholder" ?
11:37 sri # and ?
11:37 batman "foo#format" ... not too bad
11:38 sri ->get("/foo/bar#format")->to(...) looks a little weird
11:40 batman :)
11:45 hugh joined #mojo
11:48 batman what does "opt-in" mean btw..?
11:49 sri only enabled when you ask for it
11:49 sri like with a special placeholder
11:50 sri currently it's opt-out, because you have to ask for it being disabled with format => 0
11:50 batman ok
11:51 batman so it will be a major api change?
11:51 sri yes
11:51 batman i see
12:00 azawawi hi
12:03 batman hello
12:04 sri ideally i would like to find a backcompat solution, but i'm not sure that's possible
12:07 d4rkie joined #mojo
12:08 batman don't think so, without a config option or plugin...
12:09 azawawi is there some command to launch the default browser at http://127.0.0.1/something in linux?
12:10 batman azawawi: depends on which flavour your running
12:10 azawawi gnome for example
12:10 batman xdg-open http://127.1/something
12:11 batman xdg-open is shipped with ubuntu iirc
12:11 batman don't think i've installed it manually
12:11 daxim xdg is the standard.
12:12 azawawi so xdg-open is a standard command?
12:12 azawawi daxim: and hi :)
12:13 batman azawawi: i think "standard" in linux is the same as "most common" :)
12:13 daxim see http://portland.freedesktop.org/
12:13 d4rkie joined #mojo
12:14 batman azawawi: step back and explain what you're trying to achieve ...
12:14 * azawawi tries Browser::Open
12:14 azawawi http://code.google.com/p/mojolicious-plugin-pedro/   # third step
12:14 daxim I'm interested in extending B::O
12:14 azawawi pedro daemon && xdg-open http://127.0.0.1:3000/pedro
12:15 batman azawawi: which javascript library do you use?
12:16 azawawi ace editor atm ...
12:16 azawawi and override its tokenizer to use PPI via ajax
12:17 batman cool
12:17 azawawi it is slow at the moment since ace tokenizer is basically line by line tokens...
12:17 azawawi next releases will feature a cached PPI document for faster access
12:20 azawawi Browser::Open does the job
12:20 azawawi interesting on win32 ... it is q{start}
12:20 azawawi and on ubuntu it used {/usr/bin/sensible-browser}
12:21 azawawi http://manpages.ubuntu.com/manpages​/gutsy/man1/sensible-browser.1.html
12:21 azawawi "...Programs in Debian can use these scripts as their default editor, pager, or web browser or emulate their behavior..."
12:22 azawawi it handles a big list... not bad https://metacpan.org/source/CFRANKS/Bro​wser-Open-0.04/lib/Browser/Open.pm#L19
12:31 azawawi how do i execute something after application startup? is there an event for that in Mojo?
12:37 azawawi is there an after-startup event in Mojo?
12:41 asarch joined #mojo
12:53 sri azawawi: what would you need that for?
12:53 azawawi after startup { Browser::Open->open_browser(l​istening_address_for_pedro); }
12:55 sri you want to hook into the web server, that has nothing to do with the application
12:56 sri application can't touch the web server, you need a custom start script
12:57 sri or a timer
12:57 sri Mojo::IOLoop->timer(0 => sub {...});
12:57 sri that will fire on the first tick
12:58 azawawi cool
12:58 azawawi it is basically for script/pedro not plugin mode
12:59 * sri nods
13:14 sri hmm, maybe a simpler way to opt-out of automatic format handling could work too
13:16 sri something simple like a prefix ->get("!/foo/bar")
13:17 sri ->get("~/foo/bar")
13:18 sri ->get("//foo/bar")
13:24 sri ->get("./foo/bar")
13:25 sri we also currently ignore a trailing slash
13:25 sri maybe ->get("/foo/bar/")
13:27 sri the thought that we could break every single app out there in 4.0 is a little scary
13:27 kanishka joined #mojo
13:28 azawawi sri: fyi Message::IOLoop->timer( 0 => sub { } );   works on win32
13:28 azawawi sri: but on linux i had to put 1 instead of 0
13:28 azawawi sri: otherwise launching the browser is done before starting of the daemon
13:32 azawawi my bad Browser::Open->launch_browser seems to block
13:33 azawawi s/launch_browser/open_browser
13:46 jnap joined #mojo
13:48 * azawawi pedro browser launching works now on win32/linux
13:48 azawawi sri++
13:49 sri :)
14:08 mattastrophe joined #mojo
14:27 lammel2 joined #mojo
14:28 lammel2 joined #mojo
14:29 lammel2 joined #mojo
14:30 azawawi cpanm -v http://cpan.metacpan.org/authors/id/A/AZ/AZ​AWAWI/Mojolicious-Plugin-Pedro-0.02.tar.gz
14:30 azawawi # and then pedro ! :)
15:23 inokenty joined #mojo
15:40 mercutioviz joined #mojo
15:47 Psyche^ joined #mojo
15:57 mercutioviz joined #mojo
16:03 batman joined #mojo
16:10 xaka joined #mojo
16:26 d4rkie joined #mojo
16:38 tempire shalom!
16:40 kanishka using hook how to change the server name ?
16:41 kanishka hook before_dispatch => sub {
16:41 kanishka my $c = shift;
16:41 kanishka $c->tx->res->headers->server;
16:41 kanishka print Dump $c;
16:41 kanishka };
16:42 mercutioviz joined #mojo
16:45 tempire kanishka: please don't paste in the channel - use gist.github.com
16:50 kanishka https://gist.github.com/2369039
16:56 sri tempire: what are your thoughts on the routes situation?
17:29 fhelmbe__ joined #mojo
17:30 fhelmber_ joined #mojo
17:49 ask Hi everyone, I have another route question:
17:49 ask https://gist.github.com/29b7d75676b2ac8650f5
17:49 ask this sends PUT requests to get_domain; is there another way I can "abbreviate" some of the common constraints?
17:51 ask sri: look to regular expressions for how using special characters for lots of meanings just ends up being crazy. :-)
17:57 mercutioviz_ joined #mojo
18:06 tempire sri: maybe I missed something - I thought it was decided to leave it until the routes were re-worked
18:09 tempire ask: what do you mean by abbreviate?
18:09 tempire if you mean include an expected get/put/post/etc with single command...
18:09 tempire you can create a helper or plugin that creates them all
18:10 tempire I think there's a mojolicious plugin on cpan that provides a "resource" directive
18:10 tempire but it's easy enough to create your own
18:19 preflex_ joined #mojo
18:30 asarch joined #mojo
18:33 ask sri: https://github.com/kraih/mojo/w​iki/IPv6-support-in-Mojolicious is out of date, no?
18:34 ask tempire: I have a dozen routes, all needing ~4 different via()'s going to different handlers; I'm changing the code to just have a data structure for me to configure them and a loop that turns it into Mojo statements.
18:35 ask tempire: I started out thinking that with enough bridges and clones of the route object I could have a very short line for each new route.
18:52 mercutioviz_ joined #mojo
18:55 ask how do I get $ua->post() to send data?  Is it $ua->post(url => {} => { query => 123 });
18:56 ask the documentation says "takes the same parameters as X", looking up X says "takes the same parameters as Y" and Y is so generic it doesn't really say what it does.
19:02 buu joined #mojo
19:12 tempire you probably want ->post_form
19:12 tempire post is for sending raw posts
19:16 ask tempire: ah, really it's on Test::Mojo, so I guess I have to format the queries "by hand"?
19:17 ask (there is post_form_ok, but no put_form_ok)
19:20 tempire put_form_ok wouldn't make sense
19:20 tempire post_form is handy for emulating how a browser works
19:21 tempire and by hand isn't so bad.  a=b&c=d and such
19:21 tempire for post at least
19:21 tempire since there's no convention for put, the formatting is up to you anyway
19:25 ask I don't see how put_form would be different from post_form in serializing as application/x-www-form-urlencoded.  That has to do with the 'form' part of the name, not the http method.
19:56 black joined #mojo
20:27 tabbi joined #mojo
20:31 tabbi joined #mojo
20:31 tabbi left #mojo
21:14 Dani joined #mojo
21:16 tempire hmm
21:16 tempire I guess it is the x-www-form-urlencoded that specifies the post format.
21:16 tempire I never thought about it separate from the browser post convention
21:18 tempire I can't imagine it's used often outside of post, though.
21:18 tempire wow: http://www.meteor.com/screencast
21:19 tempire meteor makes it harder to justify using a separate language for backend web dev.
21:19 * tempire wishes javascript were more functional
21:21 xaka joined #mojo
21:24 perlite_ joined #mojo
21:25 vel joined #mojo
21:26 batman joined #mojo
21:47 lukep joined #mojo
23:08 mmajchrzak joined #mojo
23:09 mmajchrzak Hi . Do you know any places where I can host my mojo project ? (it must be free).
23:10 buu mmajchrzak: sure, amazon ec2
23:11 mmajchrzak Is it free or only trial is for free ?

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