[Catalyst] [Beginner] C::V::Email::Template does not render

Devin Austin devin.austin at gmail.com
Sun Sep 12 20:36:59 GMT 2010


On Sun, Sep 12, 2010 at 2:14 PM, Ekki Plicht (DF4OR) <ep at plicht.de> wrote:

> Hi.
>
> Following the example in THE BOOK (cookbook part) I try to get my user
> registration process to work. I use C::V::Email::Template, and all seems =
to
> work fine, according to the debug output [1], see below.
>
> The mail does get sent, but it is not rendered proprly. The very simple
> mail
> template looks like this:
>
>        [% c.localize('mm_reghello') %]
>        [% c.localize('mm_regsent') %]
>        [% c.uri_for('/user/registration') %]/[% c.digest %]
>        [% c.localize('mm_regfinal') %]
>        [% PROCESS mailsig.tt %]
>
> What I receive as mail is:
>        mm_reghello
>        mm_regsent
>        http://localhost:3000/user/registration/
>        mm_regfinal
>        --
>        The mail signature as intended.
>
> I.e. the localization does not work (it does fine on the web templates) a=
nd
> the digest code is missing after the URI. The placeholders 'mm_*' are all
> defined and available in various .po files. Other stash variables, which I
> put
> into the mail template for testing pruposes, are also missing in the
> rendered
> output.
>
> My registration action looks like this:
> sub register :Local {
>    my ( $self, $c ) =3D @_;
>
>    if ( exists($c->req->params->{'email'}) ) {
>        my $newuser;
>        eval {
>            $newuser=3D $c->model('WSDB::register')->create({
>                email =3D> $c->req->params->{'email'}
>            })
>        };
>
>        if ($@) {
>            $c->log->debug( "Email::Valid failed" );
>            $c->stash( errors =3D> { email =3D> 'ee_invalid' }, err =3D> $=
@ );
>            return; # redraw
>        }
>        else {
>            # Mail ok, send mail
>            $c->stash->{digest}   =3D $newuser->get_column('digest');
>            $c->stash->{mailto}   =3D $c->req->params->{'email'};
>            $c->stash->{mailsubj} =3D 'mm_registersubject';
>            $c->stash->{mailtemplate} =3D 'registermail.tt';
>            $c->forward( '/email' );
>            return $c->res->redirect( $c->uri_for('/user/registerdone') );
>        }
>    }
> }
>
>
> I.e. the successful (mail is valid) register request is answered with a
> forward to sending the mail, then the user/registerdone action is kicking
> in.
> That all works, but as I said, the mail is not rendered correctly.
>
> The /email action is in the root controller like this:
> sub email : Private {
>    my ( $self, $c ) =3D @_;
>
>    $c->stash->{email} =3D {
>        to       =3D> $c->stash->{mailto},
>        from     =3D> $c->config->{mailfrom},
>        subject  =3D> $c->stash->{mailsubj},
>        template =3D> $c->stash->{mailtemplate}
>    };
>    $c->forward( $c->view('Email::Template') );
> }
>
>
> Probably this could all be done better, but I followed the cookbook examp=
le
> so
> far.
>
> What am I missing? Thanks for any hints where I can continue looking.
>
>
> Cheers,
> Ekki
>
>
>
>
> [1] Debug output from dev server
> --------------------------------
> [info] *** Request 15 (0.001/s) [12344] [Sun Sep 12 21:56:22 2010] ***
> [debug] "POST" request for "user/register" from "127.0.0.1"
> [debug] Body Parameters are:
>
> .-------------------------------------+----------------------------------=
----.
> | Parameter                           | Value
>  |
>
> +-------------------------------------+----------------------------------=
----+
> | email                               | ekki at plicht.de
>   |
>
> '-------------------------------------+----------------------------------=
----'
> [debug] Path is "user/register"
> [debug] C::V::Email::Template uses Catalysts default view
> wshop::View::Web=3DHASH(0x94b41f8) for rendering.
> [debug] C::V::Email uses default content_type text/plain.
> [debug] Rendering template "registermail.tt"
> [debug] C::V::Email uses specified content_type text/plain.
> [debug] Redirecting to "http://localhost:3000/user/registerdone"
> [debug] Response Code: 302; Content-Type: text/html; charset=3Dutf-8;
> Content-
> Length: unknown
> [info] Request took 1.981418s (0.505/s)
> .------------------------------------------------------------+-----------.
> | Action                                                     | Time      |
> +------------------------------------------------------------+-----------+
> | /user/register                                             | 1.952326s |
> |  -> /email                                                 | 1.194451s |
> |   -> wshop::View::Email::Template->process                 | 1.193180s |
> | /end                                                       | 0.000637s |
> '------------------------------------------------------------+-----------'
>
> [info] *** Request 16 (0.001/s) [12344] [Sun Sep 12 21:56:24 2010] ***
> [debug] "GET" request for "user/registerdone" from "127.0.0.1"
> [debug] Path is "user/registerdone"
> [debug] Rendering template "user/registerdone.tt"
> [debug] Response Code: 200; Content-Type: text/html; charset=3Dutf-8;
> Content-
> Length: 5656
> [info] Request took 0.051840s (19.290/s)
> .------------------------------------------------------------+-----------.
> | Action                                                     | Time      |
> +------------------------------------------------------------+-----------+
> | /user/registerdone                                         | 0.000238s |
> | /end                                                       | 0.036513s |
> |  -> wshop::View::Web->process                              | 0.035203s |
> '------------------------------------------------------------+-----------'
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>

I.e. the localization does not work (it does fine on the web templates) and

the digest code is missing after the URI. The placeholders 'mm_*' are all

defined and available in various .po files. Other stash variables, which I
put

into the mail template for testing pruposes, are also missing in the
rendered

output.

What do your web templates look like?

-- =

Devin Austin
http://www.codedright.net
9702906669 - Cell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100912/4e705=
05c/attachment.htm


More information about the Catalyst mailing list