Re: [Catalyst] Accessing $c from Model

2007-03-06 Thread Scott Thomson
Excellent, that works - Thank you! On 3/5/07, Juan Miguel Paredes [EMAIL PROTECTED] wrote: On 3/5/07, Scott Thomson [EMAIL PROTECTED] wrote: Ok, I think I'm close... My main schema class: package DB; use base qw/DBIx::Class::Schema DBIx::Class::AccessorGroup/;

Re: [Catalyst] Accessing $c from Model

2007-03-06 Thread Jason Kohles
On Mar 5, 2007, at 7:02 AM, Scott Thomson wrote: Ok, I think I'm close... My main schema class: package DB; use base qw/DBIx::Class::Schema DBIx::Class::AccessorGroup/; __PACKAGE__-mk_group_accessors(simple = 'context'); __PACKAGE__-load_classes(qw//); 1; Very Bad Things are likely to

Re: [Catalyst] Accessing $c from Model

2007-03-06 Thread Scott Thomson
Noted and actioned, Cheers. Very Bad Things are likely to happen if you ever attempt to run your application under the debugger when you have a package named 'DB'. I'd recommend using a different name... -- Jason Kohles [EMAIL PROTECTED] http://www.jasonkohles.com/ A witty saying proves

Re: [Catalyst] Accessing $c from Model

2007-03-05 Thread Juan Miguel Paredes
On 3/5/07, Scott Thomson [EMAIL PROTECTED] wrote: Ok, I think I'm close... My main schema class: package DB; use base qw/DBIx::Class::Schema DBIx::Class::AccessorGroup/; __PACKAGE__-mk_group_accessors(simple = 'context'); __PACKAGE__-load_classes(qw//); 1; My model class... package

Re: [Catalyst] Accessing $c from Model

2007-02-27 Thread Scott Thomson
Hi, This is exactly what I want to do, however I can't seem to get my head round how to implement this solution, I've tried various incarnations but I don't seem to be getting anywhere. Annotations below, thanks for patience. Scott On 2/1/07, Juan Miguel Paredes [EMAIL PROTECTED] wrote: On

Re: [Catalyst] Accessing $c from Model

2007-02-01 Thread Matt S Trout
On 31 Jan 2007, at 19:27, Juan Miguel Paredes wrote: On 1/31/07, Matt S Trout [EMAIL PROTECTED] wrote: On 31 Jan 2007, at 15:23, Juan Miguel Paredes wrote: Hi, all! What if we have to overload ACCEPT_CONTEXT to do something like this, but using DBIC::Schema? What would be the

Re: [Catalyst] Accessing $c from Model

2007-02-01 Thread Juan Miguel Paredes
On 2/1/07, Matt S Trout [EMAIL PROTECTED] wrote: package MyApp::DataStore; # or whatever this is called use base qw/DBIx::Class::Schema/; __PACKAGE__-mk_group_accessors(simple = 'context'); then my $new = bless ... $new-schema(bless(...)); # same trick on the schema

Re: [Catalyst] Accessing $c from Model

2007-01-31 Thread Juan Miguel Paredes
On 12/27/06, Ash Berlin [EMAIL PROTECTED] wrote: Mark Zealey wrote: Hi there, I'm basically wanting to write a simple log function which logs hits on my website as entries in a database (automatically adding $c-user-{id} and $c-req-referrer etc), but to do so I want to use a model (I

Re: [Catalyst] Accessing $c from Model

2007-01-31 Thread Matt S Trout
On 31 Jan 2007, at 15:23, Juan Miguel Paredes wrote: On 12/27/06, Ash Berlin [EMAIL PROTECTED] wrote: Mark Zealey wrote: Hi there, I'm basically wanting to write a simple log function which logs hits on my website as entries in a database (automatically adding $c-user- {id} and

Re: [Catalyst] Accessing $c from Model

2007-01-31 Thread Juan Miguel Paredes
On 1/31/07, Matt S Trout [EMAIL PROTECTED] wrote: On 31 Jan 2007, at 15:23, Juan Miguel Paredes wrote: Hi, all! What if we have to overload ACCEPT_CONTEXT to do something like this, but using DBIC::Schema? What would be the recommended inheritance chain? Catalyst::Model::DBIC::Schema

[Catalyst] Accessing $c from Model

2006-12-27 Thread Mark Zealey
Hi there, I'm basically wanting to write a simple log function which logs hits on my website as entries in a database (automatically adding $c-user-{id} and $c-req-referrer etc), but to do so I want to use a model (I think). Any ideas how I can just say $c-model('Log')-info(foo) and

Re: [Catalyst] Accessing $c from Model

2006-12-27 Thread Lorn
you can passa the $c from controller to model $c-model(foo)-bar($c,$foobar); On 12/27/06, Mark Zealey [EMAIL PROTECTED] wrote: Hi there, I'm basically wanting to write a simple log function which logs hits on my website as entries in a database (automatically adding $c-user-{id} and

Re: [Catalyst] Accessing $c from Model

2006-12-27 Thread Ash Berlin
Mark Zealey wrote: Hi there, I'm basically wanting to write a simple log function which logs hits on my website as entries in a database (automatically adding $c-user-{id} and $c-req-referrer etc), but to do so I want to use a model (I think). Any ideas how I can just say

Re: [Catalyst] Accessing $c from Model

2006-12-27 Thread John Napiorkowski
--- Lorn [EMAIL PROTECTED] wrote: you can passa the $c from controller to model $c-model(foo)-bar($c,$foobar); I'd vote for this method over setting the context, since one of the goals of a model is to not care about how or when it's called, that way you are encouraging yourself to not build

Re: [Catalyst] Accessing $c from Model

2006-12-27 Thread Mark Zealey
On Wednesday 27 December 2006 1:01 pm, Ash Berlin wrote: Very very *VERY* bad idea. __PACKAGE__-mk_accessors(context); sub ACCEPT_CONTEXT { my ($self, $c, @args) = @_; my $new = bless({ %$self }, ref $self); $new-context($c); return $new; } Isn't that really really slow

Re: [Catalyst] Accessing $c from Model

2006-12-27 Thread Eden Cardim
On 12/27/06, Mark Zealey [EMAIL PROTECTED] wrote: Hi there, I'm basically wanting to write a simple log function which logs hits on my website as entries in a database (automatically adding $c-user-{id} and $c-req-referrer etc), but to do so I want to use a model (I think). Any ideas how I can

Re: [Catalyst] Accessing $c from Model

2006-12-27 Thread Jonathan Rockway
Isn't that really really slow though? Constructing a new object for each call? No, it's not. Creating an object in Perl amounts to setting a flag (the OBJECT flag in subclasses of SvPVMG, to be exact). See illguts: http://gisle.aas.no/perl/illguts/ -- package JAPH;use Catalyst

Re: [Catalyst] Accessing $c from Model

2006-12-27 Thread John Napiorkowski
--- Eden Cardim [EMAIL PROTECTED] wrote: On 12/27/06, Mark Zealey [EMAIL PROTECTED] wrote: Hi there, I'm basically wanting to write a simple log function which logs hits on my website as entries in a database (automatically adding $c-user-{id} and $c-req-referrer etc), but to do so