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

IRC log for #mojo, 2015-08-09

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

All times shown according to UTC.

Time Nick Message
00:00 Lee joined #mojo
01:01 sh4|2 joined #mojo
01:09 Kundun_ joined #mojo
01:10 Kundun joined #mojo
01:14 meshl joined #mojo
01:27 Kundun joined #mojo
02:07 Grinnz hey sri, do you know why you used $_[0]{sth} here and not $_[0]->sth? is it because of global destruction? https://github.com/kraih/mojo-pg/blob/master/lib/Mojo/Pg/Results.pm#L10
02:07 Grinnz or DESTROY in general?
02:11 mst Grinnz: because subclasses might provide a builder for the $sth
02:11 mst Grinnz: so the direct lookup is the only safe way to kill it if it exists without triggering its construction during GD when that'll fail
02:11 Grinnz hm, ok
02:12 mst Grinnz: the Moo idiom would be '$self->_has_sth and defined $_ = $self->sth and $_->finish'
02:39 noganex joined #mojo
02:39 Grinnz alright i think i have a satisfactory solution for this without killing prepare_cached
02:41 Grinnz https://github.com/Grinnz/Mojo-SQLite/commit/36bd11a05a83e4587d0d7b97c494ffb1fc6cbad7
02:42 Grinnz also, apparently ++ doesn't work too well on the tied hash fuckery that DBI does
02:52 cpan_mojo Mojo-SQLite-0.010 by DBOOK https://metacpan.org/release/DBOOK/Mojo-SQLite-0.010
03:09 frudas joined #mojo
03:09 frudas hello there
03:10 frudas i have a little problem with mojo, mojo repeat the query to my db
03:10 frudas :(
03:12 Grinnz uh...what?
03:12 frudas http://pastecode.org/index.php/view/11246923
03:13 frudas it repeat the query to db 2 or 3 times
03:13 Grinnz i don't see any db queries there
03:14 frudas something like resending the data
03:14 frudas the web browser
03:14 frudas :(
03:15 frudas everthing work well in mojolicious 5
03:15 frudas and i had the idea to upgrade to the latest 6.2
03:16 frudas is freaking me out
03:16 frudas is not allways
03:16 frudas but .....
03:16 Grinnz https://github.com/kraih/mojo/wiki/Upgrading
03:17 Grinnz if you need more help, you're going to have to paste all of the code, i have no idea what your helpers do
03:18 frudas sorry
03:18 frudas Mojolicious (6.14, Clinking Beer Mugs)
03:18 Grinnz read that upgrading document, if the issue occurred after upgrading from 5
03:19 marty I'm using 6.02 with Mojo::Pg and Mojo::Mango and I have no issues.
03:20 frudas im using sqlite
03:20 frudas and DBI
03:21 frudas http://pastecode.org/index.php/view/61138395
03:21 frudas this is the portion
03:21 frudas with the helpers
03:22 Grinnz first of all, use parameter binding
03:24 Grinnz also, Mojo::SQLite exists now, may be a nicer syntax and has a migrations module which can simplify things like that table create you're doing there
03:25 frudas well, i will try it
03:25 Grinnz anyway, i dont see anything off in what you've pasted so far, but there is a lot to this program that isn't here
03:25 frudas but by the way is no normal
03:25 frudas that over reply
03:26 frudas well is just a /post
03:26 Grinnz the only reason a post would run twice is if the browser or javascript requests it twice
03:27 frudas the other reason could be the resent version of chrome
03:27 Grinnz is the actual route being requested multiple times? the debug output in the log will tell you what requests it receives
03:27 frudas when the conection is not stable google try to resend the data
03:27 Grinnz it won't resend a POST
03:27 Grinnz a GET, maybe
03:28 frudas ?
03:28 frudas is possible?
03:28 Grinnz if you try to resend a POST the browser will prompt you first
03:28 frudas for example when you lost the conection in chrome
03:29 frudas by hisfelf if you wait sometime he resend the data thinkso
03:29 Grinnz for a GET, yes
03:29 frudas my producction log
03:29 Grinnz GET routes are supposed to be resendable, if not then you should make it a post route
03:30 frudas show something wear
03:30 Grinnz it won't show it in production mode unless you turn on debug logging
03:30 frudas how force debug mode in production?
03:31 Grinnz $self->log->level('debug')
03:31 Grinnz or MOJO_LOG_LEVEL=debug
03:31 frudas please check this log
03:32 frudas http://pastecode.org/index.php/view/23431424
03:33 frudas i make a log of every query to the sql
03:33 Grinnz the code you pasted before, why do you have app->log in a controller action?
03:33 frudas and record the origin of the ip, and what kind of info
03:34 frudas for debugin
03:34 Grinnz should be $self->app->log
03:34 frudas mmm thankx will fix this one
03:34 frudas but it work
03:34 Grinnz is this a Lite app?
03:35 frudas is a mix
03:35 Grinnz a "mix"?
03:35 frudas jejejeje
03:35 Grinnz don't do that, make it a full app or a lite app not both
03:35 frudas i mount other app lite
03:35 frudas to a route
03:36 Grinnz oh
03:36 frudas so is a mix
03:36 frudas think so
03:37 frudas is not clear how to use full app
03:37 Grinnz what's not clear?
03:37 frudas is hard for people that learn perl
03:37 frudas recently
03:38 frudas or for me
03:38 frudas the mojo help is like a ocean
03:38 frudas :)
03:39 Grinnz https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides/Growing.pod
03:40 frudas there is no mojo book?
03:40 Grinnz no one has written one
03:40 zivester joined #mojo
03:41 frudas well im reading how to make a full mojo app
04:14 frudas joined #mojo
04:36 davido_ joined #mojo
05:01 dotandimet joined #mojo
05:13 dotandimet joined #mojo
05:18 dotandimet1 joined #mojo
05:28 kaare joined #mojo
06:17 asm35 joined #mojo
06:35 stephen joined #mojo
07:17 deserted joined #mojo
07:24 Vandal joined #mojo
07:33 buu joined #mojo
07:59 batman can someone tell me what the difference between "save", "store" and "persist" is?
07:59 batman are they synonyms or is there a difference?
07:59 batman i'm struggling with naming my methods :)
08:09 deserted batman, quick answer - it's subjective
08:10 deserted for myself - save is creating/updating a variable value in persistent cross-session storage (ie DB write)
08:11 deserted store is immutable, store once for later retrieval - can be persistent across sessions or not
08:11 deserted persist is the most subjective - it could be persist in terms of current session, or permanence.  I prefer to consider it in terms of "persist until reboot/restart"
08:14 deserted batman, so long as you document how each should be used in said project, you can define them however you like really :)
08:16 batman deserted: so "store" is like "insert" (in sql terms) ?
08:21 buu joined #mojo
08:22 deserted no, more like a file upload
08:23 deserted something that's either stored or retrieved, not something that could be updated or manipulated
08:23 deserted ie you store an image, you save a url
08:23 deserted batman, as in, save a URL to the db to reference the image stored on the file system
08:24 deserted I'd think more of store as an HTTP 'put'
08:24 batman thanks :) makes it easier for me to figure out what to call the method :)
08:27 amon joined #mojo
08:50 trone joined #mojo
09:36 cpan_mojo Mojolicious-Plugin-AssetPack-0.57 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/Mojolicious-Plugin-AssetPack-0.57
10:04 meshl joined #mojo
10:16 damaya_ joined #mojo
10:17 damaya_ What's the best way to tell if someone is viewing the home (index) page?
10:18 damaya_ In the default template that is.
10:26 batman damaya_: i don't understand the question
10:30 buu damaya_: Surely your controller knows
10:32 damaya_ batman: In my default template, if I am rendering index (main page), I want default template not to show something; for all else, show it.
10:36 damaya_ I'm setting a variable in the controller for index, and checking if it is defined in my default template; but when I load other pages (controllers/actions), I get global symbol undefined, which means I'd have to set it in every action.
10:37 damaya_ % if ( $index = 'yes' ) and set $index to yes for index (root), and $index to something else everywhere else.
10:41 buu Ahh, poorly designed templating systems.
10:41 damaya_ sweet
10:41 damaya_ % if ( url_for('current') ne '/' ) {
10:42 damaya_ buu: What do you mean?
10:43 buu damaya_: The 'undefined variable' is a common error when attempting to reuse templates and obnoxious to solve
10:43 buu You run into a bunch when templating languages try to go 'strict'
10:47 asm35 joined #mojo
10:48 batman damaya_: $r->get("/", {is_default => 1}); # and then % if (stash 'is_default') { ...
10:48 batman damaya_: you can also do $app->defaults(is_default_template => 0); # which makes $is_default_template variable available in all templates
10:49 damaya_ Ah ha! I was passing the variable correctly, just not checking stash. Thanks for providing two ways to do this by the way.
10:49 batman ...and then overwrite it using $c->stash(is_default_template => 1);
10:49 damaya_ Is there anything wrong with my solution?
10:49 batman damaya_: hard to tell. you're not telling us _why_ your're doing it
10:50 damaya_ Ah, a search form is displayed in the navbar on every page other than index, because the index has a huge search bar right in the middle of the page :D
10:50 batman my instinct says it's wrong, but i can't tell for sure
10:50 damaya_ So, in the default template I am saying, if it's the main page (home page, root, index) then don't display search in the navbar.
10:50 batman oh. i would just have a "landing page" template with a different layout than then rest
10:51 batman or simply have a landing page without a layout at all
10:51 batman this could be accomplished if you refactor the layout into parts you can %= include
10:52 batman i try to avoid if/else as much as possible in my templates.
10:53 batman buu: are you saying "use string" should't be the default..?
10:55 buu batman: Possibly. Ideally it should be smarter and know if you're checking for the existence of a variable.
10:57 batman buu: so if($foo) shouldn't be strict, but %= $foo should?
10:58 mattastrophe joined #mojo
10:58 buu Probably.
10:59 buu It'd be nice to check if a variable exists or not
10:59 batman % if (exists stash->{foo}) {
11:01 buu That's how I solved it
11:02 batman i do this: %= if (my $foo = stash "foo") {
11:02 batman often i just need to check if it contains a true value.
11:02 buu yeah
11:46 hummeleBop joined #mojo
12:02 berov joined #mojo
12:09 batman damaya_: what did you think about the %= include idea?
12:17 sri http://mojolicio.us/perldoc/Mojolicious/Plugin/DefaultHelpers#current_route
12:20 disputin joined #mojo
12:25 dotandimet joined #mojo
12:26 meshl joined #mojo
12:30 cpan_mojo Mojolicious-Plugin-AssetPack-0.58 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/Mojolicious-Plugin-AssetPack-0.58
12:51 sh4 joined #mojo
12:56 batman anyone got a moment to look at this? https://github.com/jhthorsen/mojolicious-plugin-assetpack/issues/59
12:56 batman "Make AssetPack modules optional in production"
12:57 cpan_mojo Mojolicious-Plugin-Bootstrap3-3.3501 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/Mojolicious-Plugin-Bootstrap3-3.3501
12:58 disputin joined #mojo
13:15 * sri likes the design of the new t-shirt shop https://shop.spreadshirt.com/kraih/
13:20 * jberger remembers that he hasn't bought the beer mug yet
13:23 batman sri: got anywhere i can buy stickers?
13:25 crab hmm.
13:26 sri batman: sadly not
13:27 batman ok
13:27 * sri wants stickers too
13:32 sri they have flip flops... but no stickers...
13:36 sri damn, crazy how web scraping with python is the bestselling oreilly book
13:36 sri mojolicious could do most of it so much better
13:40 asm35 left #mojo
13:42 * jberger is trying to port a server-side js library to perl and wants to die
13:42 * jberger could use some stickers
13:42 batman haha. why do you port it?
13:42 jberger cause I want it to work on my server (without node)
13:43 jberger this is part of a future GalieoNG
13:44 batman ok
13:44 batman which lib is it?
13:44 jberger https://github.com/Operational-Transformation/ot.js/blob/master/lib/text-operation.js
13:44 jberger that gives away my killer feature though
13:45 jberger so nobody go copy me
13:45 jberger or do and put me out of my misery
13:45 * sri copies
13:47 batman i don't get what it does :/
13:47 sri oh, and this is your daily reminder to get familiar with form validation
13:47 jberger sri: that actually sounds preferable
13:48 batman sri: too bad i don't ever post fields with the same name :(
13:48 sri in retrospect, the whole same name topic seems silly
13:49 batman what do you mean?
13:49 sri there is just no way it could work properly
13:49 jberger batman: http://operational-transformation.github.io/visualization.html
13:49 sri tag helpers are name based for example
13:49 sri if you make multiple fields with the same name, stuff just can't work
13:50 batman you mean stuff like automatic form filling by mojo?
13:50 sri yes
13:51 sri there is just one good case, and that's multiple file uploads
13:51 batman haven't thought about that :(
13:51 sri which works fine
13:51 sri (since there is no filling out required)
13:52 sri i'd still like to find the correct behavior for ->optional(), but for multiple input elements with the same name, it's meh
13:53 * sri would rather mention in the docs that it's a silly idea
13:53 batman right... i wonder when someone need forms with the same name.
13:53 batman s/forms/fields/
13:53 sri legacy api perhaps
13:54 batman i think there must be a better usecase than that :(
13:55 sri yea, the patch i removed was 2 additional lines, hard to justify without a half way decent use case
13:56 sri i mean, ->optional() ignoring all values if one value is empty is not a terrible default
13:57 batman i agree on that
13:57 kaare joined #mojo
13:58 batman i'm also not sure if it's a great idea to change that default.
14:03 sri all comes down to a use case
14:04 sri if there is one, it might make sense
14:05 batman i almost want to ask for a usecase for forms with same names in the google group...
14:06 sri sure
14:06 batman need to figure out how to ask the question...
14:07 sri <input type=file multiple> is the only sensible one i know (and that one works fine already)
14:30 jberger so the nuisance about this library is that it uses the type int vs string as an important thing
14:30 jberger and then exchanges data via JSON to the server
14:30 jberger and it makes it tricky for me
14:31 jberger maybe I need to hack that bit of the client-side code to make is something nicer
14:31 gryphon joined #mojo
15:18 zivester joined #mojo
15:21 jontaylor I normally use capistrano for deploying my mojo apps, but does the hivemind have any better alternatives?
15:25 preaction from a cursory glance at Capistrano, it looks like Rex
15:25 preaction http://www.rexify.org
15:26 preaction my release and deployment is wildly customized, but i'm trying to move what parts i can to Rex
15:31 jontaylor thanks preaction i’ll do this one in rex then just to see whats different
15:33 mst ansible's also worth a look, perhaps
16:06 lluad joined #mojo
16:12 cpan_mojo App-proxyforurl-0.01 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/App-proxyforurl-0.01
16:28 disputin joined #mojo
16:32 cpan_mojo App-proxyforurl-0.02 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/App-proxyforurl-0.02
16:35 disputin joined #mojo
16:43 PryMar56 joined #mojo
16:49 dave joined #mojo
17:14 jberger argh, I think I'm giving up again for a while
17:15 jberger the documentation on ot.js is practically non-existent and the workflow is inscrutible
17:15 jberger I can get the client and server talking to each other enough to throw tantilizing errors but no more
17:16 jberger (server using ot.py via Inline::Python for now :s)
17:17 preaction what's that for? the homepage isn't responding for me
17:18 jberger preaction: collaborative editing
17:18 preaction oh, huh
17:18 jberger this is supposed to be the simplest implementation possible
17:18 jberger I'm having a hard time believing that
17:18 mst from the docs, it's pretty much obviously the simplest implementation possible
17:19 jberger of the actual operational transform yes, but their architecture around using it is certainly not
17:19 jberger or at least it doesn't seem so without documentation
17:19 mst remind of the the URL ?
17:20 jberger https://github.com/Operational-Transformation/ot.js
17:20 jberger even if I use the python tranformational backend bits
17:20 jberger I still need to reimplement this (and parent class) in Perl/Mojo: https://github.com/Operational-Transformation/ot.js/blob/master/lib/editor-socketio-server.js
17:21 jberger and it just gets really confusing without docs
17:24 dod joined #mojo
17:25 mst I'm not entirely sure why you're trying to reproduce their particular client/server example
17:26 mst I'd probably try the CodeMirrorAdapter with a listener that just prints to the console
17:26 mst get that bit working
17:26 mst then replace the listener with something that sends to the server
17:26 mst THEN start going towards trying to broadcast back and forth
17:27 jberger yeah, maybe that's smart
17:27 jberger deconstruct a little bit more
17:27 mst since https://github.com/Operational-Transformation/ot.js/blob/master/lib/codemirror-adapter.js is not *that* complicated to read
17:27 mst and then you're just dealing with that, plus the actually-simple transform classes
17:28 jberger yeah, the transform classes aren't bad, and now that I've punted on that by using Inline::Python for the backend for now its not even an issue
17:30 jberger meantime, lunch
17:30 Grinnz man it's been.. 14 hours and still no cpantesters results
17:30 Grinnz wtf
17:31 disputin joined #mojo
17:46 disputin joined #mojo
17:50 marcusr o-
17:50 marcusr -o
17:50 * marcusr is in riga.
17:52 ajr_ joined #mojo
18:03 disputin joined #mojo
18:03 ryanc joined #mojo
18:31 juikuen joined #mojo
18:39 buu joined #mojo
20:10 meshl joined #mojo
20:27 Grinnz sri, as mentioned in f#perl, https://metacpan.org/pod/Protocol::PostgreSQL though a bit low-level may be something to try for Mojo::Pg wrt async queries
20:27 Grinnz i dont really play with postgres much or id try a proof of concept
20:46 Adura joined #mojo
20:53 sri Grinnz: not interested
20:59 sri (for many reasons)
21:00 Grinnz k
21:03 sri has anyone here actually had perfomance/scalability problems with Mojo::Pg?
21:05 sri i doubt very much that non-blocking reads and writes would be measurable unless your database is in a data center half way across the globe
21:06 sri honestly, i would bet money on DBD::Pg being faster with any sensible database setup
21:10 sri perhaps "measurable" in a bad way ;p
21:24 sri Grinnz: if you want to work with protocols... this is still open! https://github.com/kraih/mojo/issues/423
21:28 disputin joined #mojo
21:40 berov joined #mojo
21:47 Grinnz hehe
21:47 PryMar56 joined #mojo
21:48 Martin90 joined #mojo
21:50 Martin90 Hello, I haven't touched mojolicious for more than a year, what are the biggest changes since ?
21:52 Grinnz https://github.com/kraih/mojo/wiki/Upgrading
21:53 Martin90 exactly, thank you, by the way, do you think mojo is a way to go for file host ?
21:54 Martin90 I see it hasn't got too many utilities for this particular task
21:54 Grinnz sure, there is a simple file serving module, cant remember the name
21:55 Grinnz https://metacpan.org/release/App-SimpleHTTPServer
21:56 Martin90 mhm, but this is not the part of core mojo
21:57 Grinnz no, but you can serve static files in several ways with core mojo
21:57 Grinnz this is just a simple wrapper that also includes directory indexes
21:58 Grinnz https://metacpan.org/pod/Mojolicious::Guides::Rendering#Serving-static-files
21:58 Martin90 :)
22:00 Martin90 just curious, how much knowledge about networking is necessary to fully work with mojo ?
22:00 Grinnz you should have a basic overview understanding of HTTP, such as GET and POST
22:01 Grinnz and listening ports, and such
22:01 Martin90 only this, really ?
22:01 Grinnz other than that, not much
22:01 Grinnz https://metacpan.org/pod/distribution/Mojolicious/lib/Mojolicious/Guides.pod#BASICS
22:03 Martin90 I see mojolicious uses features that are new to me like preforking in web, IOLOOPs etc
22:03 Grinnz yes, if you want to do async request handling then you will want to learn about event loops; however, things should "just work" if you stick to synchronous programming
22:04 Grinnz the preforking works transparently if you use the prefork or hypnotoad daemons, you only need to worry about that if you are trying to share variables globally
22:08 Martin90 mhm, so for stuff like event/delay loops and low level side of mojo app decent knowladge about HTTP 1 should be enough ?
22:08 Grinnz async programming has nothing to do with HTTP
22:09 Martin90 so I should just see how it works and it is only soft related ?
22:09 Grinnz if you want to use delays and non-blocking code then you can read about that, but as far as HTTP is concerned it just waits for a response
22:10 Martin90 ok thank you, I think I will be back with more specific problems soon... thank you ;)
22:11 Grinnz until you use something non-blocking, you don't need to use the event loop at all
22:12 Martin90 yes but since I have never used it I first have to get the feeling when to use non-blocking stuff and when it is better to not using it
22:12 sri when you need it you'll know
22:14 Martin90 heh, non-blocking sounds quite obvious so I hope so
22:35 nic joined #mojo
23:59 jontaylor joined #mojo

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