Mojolicious: what works and what doesn't
Upcoming SlideShare
Loading in...5
×
 

Mojolicious: what works and what doesn't

on

  • 4,238 views

A brief summary of our first month experience using Mojolicious: what worked and what didn't work.

A brief summary of our first month experience using Mojolicious: what worked and what didn't work.

Taken from the Oslo Perl Mongers talk given October 5th, 2011

Statistics

Views

Total Views
4,238
Views on SlideShare
4,238
Embed Views
0

Actions

Likes
2
Downloads
11
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Mojolicious: what works and what doesn't Mojolicious: what works and what doesn't Presentation Transcript

  • Mojolicious: what works and what doesnt v1 - october 2011 cosimo@opera.com
  • What is Mojolicious? http://lmgtfy.org/?q=Mojolicious
  • What is Mojolicious?• Web framework• “New wave” of light-weight Ruby-inspired f.• WSGI -> PSGI• Includes Plack, Dancer, Mojolicious, ...
  • How to define a framework?• Request lifecycle• Features? ORM, Templating, I18N, Forms, Layout, ...• Testing?• Deployment: deps? Stand-alone servers? (starman, hypnotoad, ...)• Documentation?• ... what else?
  • Lets look at Dancer• Excellent documentation https://metacpan.org/module/Dancer::Introduction• DSL and script oriented use Dancer; get /login => sub { # do something }; any [get, post] => /login/verify => sub { # do something }
  • Lets look at Dancer / 2Too much DSL oriented?before sub { if (!session(user) && request->path_info !~m{^/login}) { # Pass the original path along to the handler: var requested_path => request->path_info; request->path_info(/login); }};
  • Compare with Mojolicioususe base Mojolicious;sub startup { my $self = shift; $self->hook(before_dispatch => sub { my $c = shift; if(!$c->session(user) && $c->stash(action)!~/^login/) { $c->stash(action) = login; } });}... except whole example would be pointless in Mojolicious because of named routes
  • Compare with Mojolicioususe base Mojolicious;sub startup { my $self = shift; $self->sessions->cookie_name(auth_session); $self->sessions->default_expiration(7200); $self->plugin(I18N => (namespace => Auth::Locale)); $self->renderer->default_handler(tt); my $r = $self->routes; $r->route(/login)->to(login#index); $r->route(/login/verify)->to(login#verify); $self->hook(before_dispatch => sub { do($something) });}
  • Differences, Mojo vs Dancer• Application is a class, not a script• Code is “natural”. No magic. Obvious.• Mojo Routes are awesome. Really.• Hooks are similar, but PLA/POLS rules• ... what else?
  • What works?• Good docs. Need more meaningful examples.• Fast feedback on IRC #mojo (irc.perl.org)• Routes! Best of Perl and non-Perl frameworks• Extensive test suite• Clear no deps policy
  • What doesnt work?or rather, the most annoying problems I found• No deps policy (cookie parsing)• Tons of tests, but are they relevant? (cookie parsing and generations tests again)• Template Toolkit renderer (c.* prefix)
  • Thanks! Questions?