Am 14.02.2008 um 00:11 schrieb Jay K:
Hi there Moritz,
The select by id that you are seeing is the retrieval of the user from
the database when first recovering the user from the session. I am
assuming that you are using the
Catalyst::Authentication::Store::DBIx::Class storage module. Any
access to $c->user will trigger this query. It is, however, only done
once per request.
In short - if you are going to be using $c->user in any way during the
request, that find by id will be done at some point. So going out of
your way to avoid it only makes sense if you are sure you will not use
any other user information during the request.
Jay
So why do I need to recovery the whole user row for every request?
I could use
$user_id = $c->session->{user_id};
@albums = $c->model('albums')->search({ user_id => $user_id });
as Mitchell suggested but I'd prefer to fetch the data by using $c-
>user because its the way one should do it.
might it be possible to store the user row in the session at login and
recover $c->user from the session on every request?
I know this might break if I change something in the user row.
moritz
_______________________________________________
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/