[Catalyst] Some "How Do I ..." questions

Chisel Wright chisel at herlpacker.co.uk
Sat Apr 23 21:58:03 CEST 2005

Primarily I'm asking these for purely selfish reasons, but maybe the
answers will be of use to other potential Catalyst users in a similar

I realise that there are numberous possible ways that some of these
could be solved, but MVC, Class::DBI, etc are still fairly new to me -
so I'm just looking to find suggestions for the 'recommended' ways of
solving what are likely to be common areas of functionality.

1. Login Required

This is when someone hits your site at something like /restricted/foo/X
- where they need to be logged-in/authenticated to view the page.

I'm fine using session_login() and C::P::Authentication::CDBI to log
people in.

My question is: what's the best way to send some-one through login, then
once successfully logged in continue their journey onto the original
request (in this case, /restricted/foo/X).

If I remember correctly, $c->req->path gives the requested URL - the
thing I'm not sure about is where and when to store it so it can be
forwarded to once authenticated.

2. Add/Edit Records

Kinda fundamental really, but I don't know "the Catalyst way" of doing
this. I've always been stuck with in-house solutions that usually use a
lot of if/else statements to validate the parameters, then jump through
a couple of hoops to build my own sql inserts .... you get the picture.

I started looking at Catalyst::Plugin::FormValidator for part of it, but
the docs are too terse for me to deduce real-world usage.

Basically, I want to:
 - know i've got a form submit (deduce add/edit from URL I guess)
 - validate form data
 - insert/update record accordingly.

This one's pretty open-ended, because if I'm being honest, I have no
idea where to start.

Perhaps after this, I can be a bit quieter, learn more myself, and if
the planets align, I might even work out a more functional example to
throw into the pot. [the current ones don't seem to be very helpful in
my experience]

Thanks in advance,

Chisel Wright
e: chisel at herlpacker.co.uk
w: http://www.herlpacker.co.uk/

"This is not the greatest sig in the world, no, this is just a tribute."

More information about the Catalyst mailing list