Re: [Catalyst] Access custom TT filters outside of catalyst context
This doesn't exactly solve my problem, because I'm not in need of the context object in my view, rather I'm trying to use my view where no context object exists. I solved my issue last night by factoring out my custom filters into a separate module that I could use Template Toolkit proper (rather than the catalyst view). Thanks for the advice! --Hugh On Thu, Dec 11, 2008 at 6:23 PM, Kieren Diment dim...@gmail.com wrote: On 12/12/2008, at 10:04 AM, Hugh Hunter wrote: In an effort to create a sitemap, I want to iterate over all the objects in my database and construct urls (which I will write to a file) to view all of those objects. Most of the URLs on my site are constructed using custom TT filters that I have written. My question is this: how do I use these filters in an outside script where there is no catalyst context object? I regularly use models in outside scripts using the MyApp-model('Model::Class')-methodname syntax (rather than $c-model('Model::Class')-methodname). I'm not having much luck figuring out how to do this with my TT View. Anyone tackled this one before? Use either of these techniques in your TT View: http://www.catalystframework.org/calendar/2008/8 ___ 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] http://www.catalystframework.org/calendar/2008/8
sub ACCEPT_CONTEXT { my ($self, $c ) = @_; $self = bless({ %$self, path_to = $c-path_to(''), }, ref($self)); return $self; } Sorry, I'm a bit curious about that code. Why is that done that way instead of simply: sub ACCEPT_CONTEXT { my ($self, $c ) = @_; $self-path_to( $c-path_to('') ); return $self; } Which would also avoid calling DESTROY every request. -- Bill Moseley mose...@hank.org Sent from my iMutt ___ 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] http://www.catalystframework.org/calendar/2008/8
On Fri, Dec 12, 2008 at 08:37:25AM -0800, Bill Moseley wrote: sub ACCEPT_CONTEXT { my ($self, $c ) = @_; $self = bless({ %$self, path_to = $c-path_to(''), }, ref($self)); return $self; } Sorry, I'm a bit curious about that code. Why is that done that way instead of simply: Well, looking at the Moose example I can see that it's to clone the object. And DESTROY won't get called, obviously because the ref count. Never mind. ;) -- Bill Moseley mose...@hank.org Sent from my iMutt ___ 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] Duplicate entries with C::P::Session::Store::DBIC and MySQL - new findings
On Thu, Dec 11, 2008 at 12:04 PM, Sergio Salvi sergio.li...@salvi.ca wrote: On Thu, Nov 20, 2008 at 4:49 PM, Tobias Kremer l...@funkreich.de wrote: On 20.11.2008, at 21:16, Sergio Salvi wrote: I still think the final solution (besides finding a way to make find_or_create() atomic), is to store flash data the session row (either on the same column of session or on a new, dedicated column). Sergio++ FWIW, I rolled my own flash mechanism which does exactly that (store the flash value in the session) and haven't looked back since. I've seen about 3 duplicate entry errors in the last 3 months opposed to several hundreds a week with C::P::Session's flash method. I've committed the flash in session patch, please try it out: http://lists.scsys.co.uk/pipermail/catalyst-dev/2008-December/001573.html I've applied both patches into this branch: http://dev.catalyst.perl.org/svnweb/Catalyst/browse/branches/Catalyst-Plugin-Session/both/ This is supposed to fix: - duplicate key issue when using flash() - session finalization order race condition Please try it out :) Sergio Salvi ___ 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] Access custom TT filters outside of catalyst context
That's the only place to have $c in the entire code, and you only copy over the bits that you want: $self = bless({ %$self, model_accessor = $c-model('MyModel')-whatever, }, ref($self)); return $self; then in view::TT: sub whatever { my $self = @_; $self-model_accessor-do_stuff; ... } On 13/12/2008, at 1:59 AM, Hugh Hunter wrote: This doesn't exactly solve my problem, because I'm not in need of the context object in my view, rather I'm trying to use my view where no context object exists. I solved my issue last night by factoring out my custom filters into a separate module that I could use Template Toolkit proper (rather than the catalyst view). Thanks for the advice! --Hugh On Thu, Dec 11, 2008 at 6:23 PM, Kieren Diment dim...@gmail.com wrote: On 12/12/2008, at 10:04 AM, Hugh Hunter wrote: In an effort to create a sitemap, I want to iterate over all the objects in my database and construct urls (which I will write to a file) to view all of those objects. Most of the URLs on my site are constructed using custom TT filters that I have written. My question is this: how do I use these filters in an outside script where there is no catalyst context object? I regularly use models in outside scripts using the MyApp-model('Model::Class')-methodname syntax (rather than $c-model('Model::Class')-methodname). I'm not having much luck figuring out how to do this with my TT View. Anyone tackled this one before? Use either of these techniques in your TT View: http://www.catalystframework.org/calendar/2008/8 ___ 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/ ___ 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] Access custom TT filters outside of catalyst context
On Fri, Dec 12, 2008 at 4:01 PM, Kieren Diment dim...@gmail.com wrote: That's the only place to have $c in the entire code, and you only copy over the bits that you want: $self = bless({ %$self, model_accessor = $c-model('MyModel')-whatever, }, ref($self)); return $self; then in view::TT: sub whatever { my $self = @_; $self-model_accessor-do_stuff; ... } But what if $c never exists, because you are writing a command line application that never invokes Catalyst? -J ___ 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/