Re: [Catalyst] getting the db connection used by catalyst
I assume you have considered adding this to your dbic-schema? If it is all to deal with the same DB, and the same structures, you might benefit from that. andreas On 4. okt. 2006, at 04.27, Daniel McBrearty wrote: > basically it does some fancy processing on the db and caches the > results. initially, that will be it. It will present a number of > convenience methods, which can be used to access either the db or > cached data. There will likely be some methods to write to the db, > again convenience stuff. > > > > On 10/4/06, Brandon Black <[EMAIL PROTECTED]> wrote: >> >> >> On 10/3/06, Daniel McBrearty <[EMAIL PROTECTED]> wrote: >>> if you have a (dbix) database, and use it as a model, you generally >>> end up doing this : >>> >>> $c->model-> >>> >>> and the database connection is handled internally. >>> >>> I now want to write another model which uses the db. It would be >>> better to use the existing connection that cat has created, rather >>> than create another one. >>> >>> If I write a new() method for this model, does it have access to the >>> context? what is a good way to do this? >> >> >> What kind of model is your new model, and how will it use/store/ >> whatever the >> $dbh? There are a lot of ways to do what you're talking about in >> general, >> it all depends on what's right for your design. Be aware that >> once you take >> the raw $dbh from DBIC and start using it yourself, you lose all >> of its >> fancy connection management. >> >> -- Brandon >> >> >> ___ >> List: Catalyst@lists.rawmode.org >> Listinfo: >> http://lists.rawmode.org/mailman/listinfo/catalyst >> Searchable archive: >> http://www.mail-archive.com/catalyst@lists.rawmode.org/ >> Dev site: http://dev.catalyst.perl.org/ >> >> >> > > > -- > Daniel McBrearty > email : danielmcbrearty at gmail.com > www.engoi.com : the multi - language vocab trainer > BTW : 0873928131 > > ___ > List: Catalyst@lists.rawmode.org > Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst > Searchable archive: http://www.mail-archive.com/ > catalyst@lists.rawmode.org/ > Dev site: http://dev.catalyst.perl.org/ ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] getting the db connection used by catalyst
basically it does some fancy processing on the db and caches the results. initially, that will be it. It will present a number of convenience methods, which can be used to access either the db or cached data. There will likely be some methods to write to the db, again convenience stuff. On 10/4/06, Brandon Black <[EMAIL PROTECTED]> wrote: > > > On 10/3/06, Daniel McBrearty <[EMAIL PROTECTED]> wrote: > > if you have a (dbix) database, and use it as a model, you generally > > end up doing this : > > > > $c->model-> > > > > and the database connection is handled internally. > > > > I now want to write another model which uses the db. It would be > > better to use the existing connection that cat has created, rather > > than create another one. > > > > If I write a new() method for this model, does it have access to the > > context? what is a good way to do this? > > > What kind of model is your new model, and how will it use/store/whatever the > $dbh? There are a lot of ways to do what you're talking about in general, > it all depends on what's right for your design. Be aware that once you take > the raw $dbh from DBIC and start using it yourself, you lose all of its > fancy connection management. > > -- Brandon > > > ___ > List: Catalyst@lists.rawmode.org > Listinfo: > http://lists.rawmode.org/mailman/listinfo/catalyst > Searchable archive: > http://www.mail-archive.com/catalyst@lists.rawmode.org/ > Dev site: http://dev.catalyst.perl.org/ > > > -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] getting the db connection used by catalyst
On 10/3/06, Daniel McBrearty <[EMAIL PROTECTED]> wrote: if you have a (dbix) database, and use it as a model, you generallyend up doing this :$c->model-> and the database connection is handled internally.I now want to write another model which uses the db. It would be better to use the existing connection that cat has created, ratherthan create another one.If I write a new() method for this model, does it have access to thecontext? what is a good way to do this? What kind of model is your new model, and how will it use/store/whatever the $dbh? There are a lot of ways to do what you're talking about in general, it all depends on what's right for your design. Be aware that once you take the raw $dbh from DBIC and start using it yourself, you lose all of its fancy connection management. -- Brandon ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
[Catalyst] getting the db connection used by catalyst
if you have a (dbix) database, and use it as a model, you generally end up doing this : $c->model-> and the database connection is handled internally. I now want to write another model which uses the db. It would be better to use the existing connection that cat has created, rather than create another one. If I write a new() method for this model, does it have access to the context? what is a good way to do this? -- Daniel McBrearty email : danielmcbrearty at gmail.com www.engoi.com : the multi - language vocab trainer BTW : 0873928131 ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Spending time with Catalyst (slightly OT)
> http://cms.wikia.com/wiki/JavaScript_Libraries > Please fill in the other libraries that I missed. Perhaps this can be of help to some people: http://www.infoworld.com/article/06/07/31/31FEajax_1.html?s=feature -- Med venlig hilsen Kaare Rasmussen, Jasonic Jasonic Telefon: +45 3816 2582 Nordre Fasanvej 12 2000 Frederiksberg Email: [EMAIL PROTECTED] ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Configuring Catalyst::Model::DBIC::Schema from YAML
On 03/10/06, Jon Warbrick <[EMAIL PROTECTED]> wrote: > On Mon, 2 Oct 2006, Matt S Trout wrote: > > > Jon Warbrick wrote: > > > But for some reason my Catalyst::View::MicroMason > > > view, called Lookup::View::MicroMason _isn't_ successfully configured - it > > > behaves as if the extra mixins are not present. Anyone any idea why? > > > > Yes. Because it's broken. > > > > my @Mixins = @{ $self->config->{Mixins} || [] }; > > > > should be > > > > my @Mixins = @{ $self->{Mixins} || [] }; > > > > and similarly throughout the module. > > > > I've cc'ed the author on this message in the hopes he'll fix it :) > > Here's a patch, in effect a rewrite of new() based on > Catalyst::View::TT::new(), which _appears_ to resolve the problem though I > still don't feel I entirely understand what should be happening here... > > Jon. Hi, I can apply the patch, but i don't use the MicroMason view anymore. Someone want to maintain it? -- Jonas ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Testserver dies under IE - patch
Jesper Krogh wrote: >> On Tue, Oct 03, 2006 at 12:04:15PM +0200, Jesper Krogh wrote: This is a small patch that makes the testserver survive Internet Explorer.. >> I don't use IE enough to know for sure, but lately I've fired up an >> ssh tunnel (on the same machine) to the test server and that seemed to >> also help with this problem. > > I dont know why but looking at the problem it seems that the socket has > been taken down by the time the server asks fo the connention information. > It just seems quite strange that this should change with which client is > at the other end. Could you build a dist of 7002 with that patch applied and put it up for download somewhere please? Given it's a little difficult to test in an automated manner I'd like a chance for people to dogfood it before it hits trunk. -- Matt S Trout Offering custom development, consultancy and support Technical Directorcontracts for Catalyst, DBIx::Class and BAST. Contact Shadowcat Systems Ltd. mst (at) shadowcatsystems.co.uk for more information + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ + ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Testserver dies under IE - patch
> On Tue, Oct 03, 2006 at 12:04:15PM +0200, Jesper Krogh wrote: >>> This is a small patch that makes the testserver survive Internet >>> Explorer.. >>> > > I don't use IE enough to know for sure, but lately I've fired up an > ssh tunnel (on the same machine) to the test server and that seemed to > also help with this problem. I dont know why but looking at the problem it seems that the socket has been taken down by the time the server asks fo the connention information. It just seems quite strange that this should change with which client is at the other end. Jesper -- Jesper Krogh ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Testserver dies under IE - patch
On Tue, Oct 03, 2006 at 12:04:15PM +0200, Jesper Krogh wrote: > > > Hi all. > > > > > > This is a small patch that makes the testserver survive Internet > > Explorer.. I don't use IE enough to know for sure, but lately I've fired up an ssh tunnel (on the same machine) to the test server and that seemed to also help with this problem. -- Bill Moseley [EMAIL PROTECTED] ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Configuring Catalyst::Model::DBIC::Schema from YAML
On Mon, 2 Oct 2006, Matt S Trout wrote: > Jon Warbrick wrote: > > But for some reason my Catalyst::View::MicroMason > > view, called Lookup::View::MicroMason _isn't_ successfully configured - it > > behaves as if the extra mixins are not present. Anyone any idea why? > > Yes. Because it's broken. > > my @Mixins = @{ $self->config->{Mixins} || [] }; > > should be > > my @Mixins = @{ $self->{Mixins} || [] }; > > and similarly throughout the module. > > I've cc'ed the author on this message in the hopes he'll fix it :) Here's a patch, in effect a rewrite of new() based on Catalyst::View::TT::new(), which _appears_ to resolve the problem though I still don't feel I entirely understand what should be happening here... Jon. --- MicroMason.pm.orig 2006-10-03 09:59:40.0 +0100 +++ MicroMason.pm 2006-10-03 11:49:48.0 +0100 @@ -5,7 +5,7 @@ use Text::MicroMason; use NEXT; -our $VERSION = '0.03'; +our $VERSION = '0.03_001'; __PACKAGE__->mk_accessors('template'); @@ -53,17 +53,25 @@ =cut sub new { -my $self = shift; -my $c= shift; -$self = $self->NEXT::new(@_); +my ( $class, $c, $arguments ) = @_; my $root = $c->config->{root}; -my @Mixins = @{ $self->config->{Mixins} || [] }; +my $config = { +template_root => "$root", +%{ $class->config }, +%{ $arguments }, +}; + +my $self = $class->NEXT::new( +$c, { %$config }, +); + +$self->config($config); + +my @Mixins = @{ $config->{Mixins} || [] }; push @Mixins, qw(-TemplateDir -AllowGlobals); -my %attribs = %{ $self->config }; -$self->template( Text::MicroMason->new( @Mixins, - template_root => "$root", - #allow_globals => [qw($c $base $name)], - %attribs ) ); +delete ($config->{Mixins}); + +$self->template( Text::MicroMason->new( @Mixins, %$config )); return $self; } -- Jon Warbrick Web/News Development, Computing Service, University of Cambridge ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Testserver dies under IE - patch
> Hi all. > > > This is a small patch that makes the testserver survive Internet > Explorer.. This one even works.. --- /usr/share/perl5/Catalyst/Engine/HTTP.pm2006-07-19 23:45:16.0 +0200 +++ lib/Catalyst/Engine/HTTP.pm 2006-10-03 12:02:25.0 +0200 @@ -305,13 +305,14 @@ my ( $self, $handle ) = @_; my $remote_sockaddr = getpeername($handle); -my ( undef, $iaddr ) = sockaddr_in($remote_sockaddr); +my $iaddr; +( undef, $iaddr ) = sockaddr_in($remote_sockaddr) if $remote_sockaddr; my $local_sockaddr = getsockname($handle); my ( undef, $localiaddr ) = sockaddr_in($local_sockaddr); my $data = { -peername => gethostbyaddr( $iaddr, AF_INET ) || "localhost", -peeraddr => inet_ntoa($iaddr) || "127.0.0.1", + peername => $iaddr ? gethostbyaddr( $iaddr, AF_INET ) : "localhost/Unknown", + peeraddr => $iaddr ? inet_ntoa($iaddr) : "127.0.0.1/Unknown", localname => gethostbyaddr( $localiaddr, AF_INET ) || "localhost", localaddr => inet_ntoa($localiaddr) || "127.0.0.1", }; Jesper -- Jesper Krogh ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/
[Catalyst] Testserver dies under IE - patch
Hi all. This is a small patch that makes the testserver survive Internet Explorer.. This is probably not the correct fix.. since that would be to find out what the problem is.. Somehow it seems that the socket dissapears earlier when IE it in the other end. patch --- /usr/share/perl5/Catalyst/Engine/HTTP.pm2006-07-19 23:45:16.0 +0200 +++ lib/Catalyst/Engine/HTTP.pm 2006-10-03 11:43:42.0 +0200 @@ -305,13 +305,14 @@ my ( $self, $handle ) = @_; my $remote_sockaddr = getpeername($handle); -my ( undef, $iaddr ) = sockaddr_in($remote_sockaddr); +my $iaddr; + ( undef, $iaddr ) = sockaddr_in($remote_sockaddr) if $remote_sockaddr; my $local_sockaddr = getsockname($handle); my ( undef, $localiaddr ) = sockaddr_in($local_sockaddr); my $data = { -peername => gethostbyaddr( $iaddr, AF_INET ) || "localhost", -peeraddr => inet_ntoa($iaddr) || "127.0.0.1", +peername => $iaddr ? gethostbyaddr( $iaddr, AF_INET ) || "localhost/Uknown", +peeraddr => $iaddr ? inet_ntoa($iaddr) : "127.0.0.1/Unknown", localname => gethostbyaddr( $localiaddr, AF_INET ) || "localhost", localaddr => inet_ntoa($localiaddr) || "127.0.0.1", }; Stacktrace: Use of uninitialized value in subroutine entry at Socket::sockaddr_in(/usr/lib/perl/5.8/Socket.pm:198) at Catalyst::Engine::HTTP::_socket_data(/usr/share/perl5/Catalyst/Engine/HTTP.pm:308) at Catalyst::Engine::HTTP::_handler(/usr/share/perl5/Catalyst/Engine/HTTP.pm:220) at Catalyst::Engine::HTTP::run(/usr/share/perl5/Catalyst/Engine/HTTP.pm:172) at Catalyst::run(/usr/share/perl5/Catalyst.pm:1754) at main::(./script/nzdb_server.pl:54) Bad arg length for Socket::unpack_sockaddr_in, length is 0, should be 16 at Socket::sockaddr_in(/usr/lib/perl/5.8/Socket.pm:198) at Catalyst::Engine::HTTP::_socket_data(/usr/share/perl5/Catalyst/Engine/HTTP.pm:308) at Catalyst::Engine::HTTP::_handler(/usr/share/perl5/Catalyst/Engine/HTTP.pm:220) at Catalyst::Engine::HTTP::run(/usr/share/perl5/Catalyst/Engine/HTTP.pm:172) at Catalyst::run(/usr/share/perl5/Catalyst.pm:1754) at main::(./script/nzdb_server.pl:54) -- Jesper Krogh ___ List: Catalyst@lists.rawmode.org Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/ Dev site: http://dev.catalyst.perl.org/