Hi,

I'm fairly new to Catalyst, so please excuse me if my questions are a bit... hmmm... basic.

My app is using the authentication and authorization features as described in Jonathan Rockway's book. So far so good. Now, I want the login procedure to load a list of items (I call them 'mandators') into the session data so that the list can be used in every template once the user has logged in. Loading one single item works well, but storing the whole list doesn't. Right now, I'm quite lost...

Here's my login function (from the Root.pm file):
---------------
sub login : Global Form {
    my ($self, $c) = @_;
    my $form = $self->formbuilder;

    return unless $form->submitted && $form->validate;

    if ($c->login($form->field('username'),
                  $form->field('password')))
    {
        $c->session->{mandator} = $c->model('MotsDB::Mandator')->find();
        $c->session->{mandators} = $c->model('MotsDB::Mandator');

        $c->flash->{message} = 'Login successful.';
        $c->res->redirect($c->uri_for('/'));
        $c->detach();

    } else {
        $c->stash->{error} = 'Login failed.';
    }
}
---------------


And here's the template:

---------------
<!-- BEGIN site/right_col -->
[% IF Catalyst.session.mandator %]
  [% Catalyst.session.mandator.code %]<br>
  [% Catalyst.session.mandator.name %]<br>
[% END %]

[% IF Catalyst.session.mandators %]
  [% FOR mandator = Catalyst.session.mandators %]
    - [% mandator.code %]: [% mandator.name %]<br>
  [% END %]
[% END %]
<!-- END site/right_col -->
---------------


The first part of the template correctly displays the first mandator stored in the table. But the FOR loop doesn't work: it goes once through, displays nothing and finishes.

I'm probably missing something very basic, but I really can't figure it out... Would appreciate some hints! ;-)

Greets
--Pierre

_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to