List Info

Thread: Re: Audit logs: model or controller?




Re: Audit logs: model or controller?
country flaguser name
United States
2007-09-17 08:37:03
Charlie Garrison wrote:
> You're looking for ACCEPT_CONTEXT. Took me a while to
get the right
> setup so that it did what I needed but works great now.
I couldn't
> find *one* complete example that showed me how to best
implement it,
> but after looking at various examples I was able to
pick out the bits
> that worked for my app. I ended up with something very
close to this
> <http://article.gmane.org/gmane.comp.web.catal
yst.general/11887>.
>
> Best practices say to only store the info from $context
that you need
> in your model rather than a reference to $context
itself. IOW, if you
> just need the current user object, then just store
that. I don't
> recall the reasoning for it though.

You can try mixing in Catalyst::Component::ACCEPT_CONTEXT. 
It will
handle the ACCEPT_CONTEXT magic and provide $c as
$self->context for
you.  The reason for not storing $context in your model is
because it
will create a circular reference if you're not careful. 
Catalyst::Component::ACCEPT_CONTEXT is careful, so you don't
need to
worry about that. 

Regards,
Jonathan Rockway


_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

Re: Audit logs: model or controller?
country flaguser name
Australia
2007-09-17 21:10:00
Good morning,

On 17/9/07 at 8:37 AM -0500, Jonathan Rockway <jonjrock.us> wrote:

>> Best practices say to only store the info from
$context that you need
>> in your model rather than a reference to $context
itself. IOW, if you
>> just need the current user object, then just store
that. I don't
>> recall the reasoning for it though.
>
>You can try mixing in
Catalyst::Component::ACCEPT_CONTEXT.  It will
>handle the ACCEPT_CONTEXT magic and provide $c as
$self->context for
>you.  The reason for not storing $context in your model
is because it
>will create a circular reference if you're not careful.

>Catalyst::Component::ACCEPT_CONTEXT is careful, so you
don't 
>need to
>worry about that. 

Thanks for that reference. That was one of the sources I
looked 
at, but I needed slightly different behaviour. I missed the

'weaken' stuff though. Reading up on that now.


Charlie

-- 
    Charlie Garrison  <garrisonzeta.org.au>
    PO Box 141, Windsor, NSW 2756, Australia

O< ascii ribbon campaign - stop html mail -
www.asciiribbon.org
http://www.ietf.o
rg/rfc/rfc1855.txt

_______________________________________________
List: Catalystlists.rawmode.org
Listinfo: ht
tp://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-
archive.com/catalystlists.rawmode.org/
Dev site: http://dev.catalyst.per
l.org/

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )