Re: [Catalyst] Reading Database At Startup
On Sun, Aug 16, 2009 at 12:09 PM, Ovidpubliustemp-catal...@yahoo.com wrote: Hi all, This should be painfully obvious, but I don't see it :) For a personal project, I want users to be able to click on a letter and get a list of countries starting with that letter. I can do this: my $letters = $c-model('DB')-storage-dbh-selectcol_arrayref( 'select distinct(substr(name,1,1)) as letter from country order by letter' ); $c-stash-{letters} = $letters; But the country list is static and I want this available at startup. 'sub begin' fails because that's called once per request, not once per app. What's the recommend way of handling this? (I'm using DBIx::Class for the model) package MyApp::Model::DB; extends 'Catalyst::Model::DBIC::Schema'; has country_letters = (isa = 'ArrayRef', is = 'ro', lazy_build = 1); sub _build_country_letters { my($self) = @_; return $self-storage-dbh-selectcol_arrayref( 'select distinct(substr(name,1,1)) as letter from country order by letter' ); }; sub BUILD { shift-country_letters } # optionally, force load-time construction # in a distant controller $c-stash-{letters} = $c-model('DB')-country_letters; -- Eden Cardim Need help with your Catalyst or DBIx::Class project? Code Monkeyhttp://www.shadowcat.co.uk/catalyst/ Shadowcat Systems Ltd. Want a managed development or deployment platform? http://edenc.vox.com/http://www.shadowcat.co.uk/servers/ ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Reading Database At Startup
On Wed, Aug 19, 2009 at 9:44 PM, Eden Cardim edencar...@gmail.com wrote: On Sun, Aug 16, 2009 at 12:09 PM, Ovidpubliustemp-catal...@yahoo.com wrote: Hi all, This should be painfully obvious, but I don't see it :) For a personal project, I want users to be able to click on a letter and get a list of countries starting with that letter. I can do this: my $letters = $c-model('DB')-storage-dbh-selectcol_arrayref( 'select distinct(substr(name,1,1)) as letter from country order by letter' ); $c-stash-{letters} = $letters; But the country list is static and I want this available at startup. 'sub begin' fails because that's called once per request, not once per app. What's the recommend way of handling this? (I'm using DBIx::Class for the model) package MyApp::Model::DB; extends 'Catalyst::Model::DBIC::Schema'; has country_letters = (isa = 'ArrayRef', is = 'ro', lazy_build = 1); sub _build_country_letters { my($self) = @_; return $self-storage-dbh-selectcol_arrayref( 'select distinct(substr(name,1,1)) as letter from country order by letter' ); }; sub BUILD { shift-country_letters } # optionally, force load-time construction # in a distant controller $c-stash-{letters} = $c-model('DB')-country_letters; -- Eden Cardim Need help with your Catalyst or DBIx::Class project? Code Monkeyhttp://www.shadowcat.co.uk/catalyst/ Shadowcat Systems Ltd. Want a managed development or deployment platform? http://edenc.vox.com/http://www.shadowcat.co.uk/servers/ Also FYI it's pretty easy to do something on startup, inside MyApp.pm: sub run { my $c = shift; $c-do_stuff(); $c-SUPER(@_); } ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Inconsistent hierarchy....
mrchips wrote: i have a working application which i'm installing on a fresh box, with a fresh build of everything. But i've run into this: Couldn't instantiate component threesixty::Model::CDBI, Inconsistent hierarchy during C3 merge of class 'Class::DBI::__::Base': current merge results [ Class::DBI::__::Base, Class::Accessor, ] merging failed on 'Class::Data::Inheritable' at /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Class/C3/XS.pm line 53.Compilation failed in require at ./script/threesixty_server.pl line 49. I have a similar situation with Catalyst::Controller:FormBuilder on a CentOS 5.3 box using my own perl5.10 with Catalyst 5.8007 from Task::Catalyst. Inconsistent hierarchy during C3 merge of class 'MyApp::Controller::Articles': merging failed on parent 'Catalyst::Controller' at /usr/local/lib/perl5/5.10.0/mro.pm line 23. I can recreate this from scratch with: catalyst.pl MyApp myapp_create.pl controller Articles and adding use base 'Catalyst::Controller::FormBuilder'; to MyApp/Controller/Articles.pm as suggested in the synopsis of the C::C::FormBuilder docs. Is there something I'm misunderstanding about how to use this? Or have I run across a problem? -- Duncan Hutty ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Reading Database At Startup
On 19 Aug 2009, at 15:35, Matt Koscica wrote: On Wed, Aug 19, 2009 at 9:44 PM, Eden Cardim edencar...@gmail.com wrote: Why did you feel that quoting Eden's entire post, including signature was a good idea? Bottom posting and including the _ENTIRE_ message is even worse that top posing IMO, as it forces the reader to scroll past the message _they just read already_... Also FYI it's pretty easy to do something on startup, inside MyApp.pm: sub run { my $c = shift; $c-do_stuff(); $c-SUPER(@_); } Nooo! NEVER, EVER CALL -SUPER in a Catalyst application, it will do the wrong thing as Catalyst relies on multiple inheritance, and SUPER is likely to call the wrong thing. You should be using -next::method. Also, even that is fairly fugly - I'd highly recommend using Moose's method modifiers, so you can write: before run = sub { my $c = shift; # Do stuff }; instead - no method redispatch to cock up the arguments on.. Cheers t0m ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Netiquette (was: Reading Database At Startup)
On Wed, 2009-08-19 at 19:40 +0100, Tomas Doran wrote: On 19 Aug 2009, at 15:35, Matt Koscica wrote: On Wed, Aug 19, 2009 at 9:44 PM, Eden Cardim edencar...@gmail.com wrote: Why did you feel that quoting Eden's entire post, including signature was a good idea? Bottom posting and including the _ENTIRE_ message is even worse that top posing IMO, as it forces the reader to scroll past the message _they just read already_... Yes, but. Didn't we have this discussion a few months ago, with zero result? Specifically, J. Shirley almost always does this (bottom posting after quoting entire message _with list sigs too_), and gave some other people a hard time for pointing out that it's actually really unhelpful, in reply to him pointing out quite stridently that he doesn't like top-posting. Apparently as long as you post at the bottom it doesn't matter if it's easy to read your reply or not. Digging through archives, that discussion seems to start around 1pm on 27 April 2009 (GMT/UTC), although the top posting discussion started prior to that. Regards, Denny signature.asc Description: This is a digitally signed message part ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Netiquette (was: Reading Database At Startup)
On Wed, 2009-08-19 at 20:13 +0100, Denny wrote: Specifically, J. Shirley almost always does this (bottom posting after quoting entire message _with list sigs too_) I retract that. Looking at the archives it seems he finally started trimming the list sigs off the bottom sometime around June/July. signature.asc Description: This is a digitally signed message part ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Netiquette (was: Reading Database At Startup)
On 19 Aug 2009, at 20:13, Denny wrote: Yes, but. Didn't we have this discussion a few months ago, with zero result? Yes, sorry - I should shut the fuck up, and should have just replied in the manor in which I preferred. Please lets not have the meta discussion again? Cheers t0m ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Netiquette (was: Reading Database At Startup)
On Aug 19, 2009, at 12:24 PM, Denny wrote: On Wed, 2009-08-19 at 20:13 +0100, Denny wrote: Specifically, J. Shirley almost always does this (bottom posting after quoting entire message _with list sigs too_) I retract that. Looking at the archives it seems he finally started trimming the list sigs off the bottom sometime around June/July. You should retract it, and then some. Look back further and you'll see my standard is trimming the list sigs. ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Netiquette (was: Reading Database At Startup)
Hello 1990 and silly arguments about quoting and top-posting v bottom- posting etc. That's not what I joined this list for. I know that 15-20 years ago it was the LAW that every email list or Usenet group went through this, but let's move on, eh? (BTW, top-posting is correct now. Ducks for cover). On 20 Aug 2009, at 01:18, J. Shirley wrote: On Aug 19, 2009, at 12:24 PM, Denny wrote: On Wed, 2009-08-19 at 20:13 +0100, Denny wrote: Specifically, J. Shirley almost always does this (bottom posting after quoting entire message _with list sigs too_) I retract that. Looking at the archives it seems he finally started trimming the list sigs off the bottom sometime around June/July. You should retract it, and then some. Look back further and you'll see my standard is trimming the list sigs. ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/ ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/
[Catalyst] DBI SQLite driver missing after Catalyst update.
I have recently updated my Catalyst installation from 5.71001 to version 5.80007 and have made one of my websites completely unusable. I followed the instructions in the tutorial ( http://search.cpan.org/~hkclark/Catalyst-Manual-5.8000/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod) to update the database to use load_components and have updated my schema files to match. However, when I go to my site I get the following error message: DBIx::Class::ResultSet::next(): DBI Connection failed: Can't connect to data source 'HASH(0x9e139e0)' because I can't work out what driver to use (it doesn't seem to contain a 'dbi:driver:' prefix and the DBI_DRIVER env var is not set) at /home/me/local/share/perl/5.8.4/DBIx/Class/Storage/DBI.pm line 840 My connection string looks OK and matches the tutorial's example code: __PACKAGE__-config( schema_class = 'wppig::Schema', connect_info = [ 'dbi:SQLite:wppig.db3', ], ); Debugging says the piece of code that it's hanging on looks like this: my $result = $c-model('DB::Result::Tag')-search( { }, { join = { 'items_tag' = 'tag' } } ); while ( my $tag = $result-next ) { # Hangs here $tag_count{ $tag-tag }++; } So it looks like the class is loading but I can't do anything with the ResultSet. Any idea of why this is failing? Did I miss a step somewhere in the conversion? I'd be happy to provide more information if needed. Thanks in advance for your help. Collin Condray @ccondray condray.net ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/