Re: [Catalyst] Beginner question: View directory
On Thu, 8 Nov 2007, Ash Berlin wrote: Similarly, I setup subs that I always want aviabale in the TT stash, such as format_datetime (which formats a DateTime object according do the currently logged in user's prefernce.) I also assing VMethods to $Template::Whatever::SCALAR_OPS here, since this seems like the place that such code belonds. For Mason, this just involves importing subs that I want into the relevant package, but it's a similar thing. Yes, this obviously belongs in the view as well. Of course, if you had enough of this for TT you might want to put it in separate modules. -dave /*=== VegGuide.Orgwww.BookIRead.com Your guide to all that's veg. My book blog ===*/ ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Beginner question: View directory
On 8 Nov 2007, at 20:22, Ash Berlin wrote: Similarly, I setup subs that I always want available in the TT stash, such as format_datetime (which formats a DateTime object according do the currently logged in user's preference.) I also accessing VMethods to $Template::Whatever::SCALAR_OPS here, since this seems like the place that such code belongs. a ha! which is the kind of issue where I was conflating with setting stash and session. ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Beginner question: View directory
Dave Rolsky wrote: On Thu, 8 Nov 2007, Kieren Diment wrote: Good call, my mistake. Goes to show that there's not usually much (or any) extra stuff that needs to be done in the View class. I was actually struggling to think of code related things (rather than config) which you might want to put in there. Personally I've always munged headers in the sub end : ActionClass(’RenderView’) {} subs (see perldoc Catalyst::Action::RenderView for details). I have a few bits of code in my view class, but not much. For the Mason view, I had subclass new() and chown() all the files created by the Mason Interp object to make things happy under mod_perl. Mason has this built-in to its mod_perl integration, but that doesn't get used with Catalyst. I also have a method has_template_for_path() which does what it says. I call this from some controller auto() methods where the URI in question is basically static content that doesn't need a separate controller method. -dave Similarly, I setup subs that I always want aviabale in the TT stash, such as format_datetime (which formats a DateTime object according do the currently logged in user's prefernce.) I also assing VMethods to $Template::Whatever::SCALAR_OPS here, since this seems like the place that such code belonds. -ash ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Beginner question: View directory
On Thu, 8 Nov 2007, Kieren Diment wrote: Good call, my mistake. Goes to show that there's not usually much (or any) extra stuff that needs to be done in the View class. I was actually struggling to think of code related things (rather than config) which you might want to put in there. Personally I've always munged headers in the sub end : ActionClass(’RenderView’) {} subs (see perldoc Catalyst::Action::RenderView for details). I have a few bits of code in my view class, but not much. For the Mason view, I had subclass new() and chown() all the files created by the Mason Interp object to make things happy under mod_perl. Mason has this built-in to its mod_perl integration, but that doesn't get used with Catalyst. I also have a method has_template_for_path() which does what it says. I call this from some controller auto() methods where the URI in question is basically static content that doesn't need a separate controller method. -dave /*=== VegGuide.Orgwww.BookIRead.com Your guide to all that's veg. My book blog ===*/___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Beginner question: View directory
On 8 Nov 2007, at 16:16, Dave Rolsky wrote: On Thu, 8 Nov 2007, Kieren Diment wrote: TT.pm is the file that contains the programming logic for rendering your view. You can do stuff like set http headers, automatically add stuff to the stash/session/whatever and co in here. It inherits from Catalyst::View::TT The View subclass for your app is _not_ the place to do those things. They should be done in your controllers. I can imagine doing some header setting in the view, primarily the content type, but I would imagine most other headers are better off being set in the controller. Good call, my mistake. Goes to show that there's not usually much (or any) extra stuff that needs to be done in the View class. I was actually struggling to think of code related things (rather than config) which you might want to put in there. Personally I've always munged headers in the sub end : ActionClass(’RenderView’) {} subs (see perldoc Catalyst::Action::RenderView for details). ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Beginner question: View directory
On Thu, 8 Nov 2007, Kieren Diment wrote: TT.pm is the file that contains the programming logic for rendering your view. You can do stuff like set http headers, automatically add stuff to the stash/session/whatever and co in here. It inherits from Catalyst::View::TT The View subclass for your app is _not_ the place to do those things. They should be done in your controllers. I can imagine doing some header setting in the view, primarily the content type, but I would imagine most other headers are better off being set in the controller. -dave /*=== VegGuide.Orgwww.BookIRead.com Your guide to all that's veg. My book blog ===*/ ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Beginner question: View directory
On 8 Nov 2007, at 15:59, Gerda Shank wrote: I'm trying to learn Catalyst by working my way through the tutorial and other docs, and I'm a little puzzled by the View directory. In the tutorials it only has a TT.pm file in it, which is a config file for Template Toolkit. Are there ever any other kinds of files in that directory? The files that would be considered views in other MVC frameworks (the .tt files, I guess) are put into the root/src and root/lib directories instead of the View directory. Why? One that jrockway didn't answer. The template files in root/wherever (you're using TTsite which is fine for the tutorial but don't be tempted to use it routinely) are editable template files that don't require an app restart to refresh. So you can edit your templates and reload. They're not really code, although template-toolkit contains some programming constructs optimised for templating rather than for general purpose computing. TT.pm is the file that contains the programming logic for rendering your view. You can do stuff like set http headers, automatically add stuff to the stash/session/whatever and co in here. It inherits from Catalyst::View::TT the vanilla version of which looks like this: ~$ cat Desktop/dev/WIAB/trunk/WIAB/lib/WIAB/View/TT.pm package WIAB::View::TT; use strict; use base 'Catalyst::View::TT'; # snip a bunch of auto-generated docs 1; Compare that to what Catalyst::Helper::View::TTSite has produced for you and it might start to make some sense... ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/
Re: [Catalyst] Beginner question: View directory
Gerda Shank wrote: > I'm trying to learn Catalyst by working my way through the tutorial > and other docs, and I'm a little puzzled by the View directory. In the > tutorials it only has a TT.pm file in it, which is a config file for > Template Toolkit. Are there ever any other kinds of files in that > directory? The files that would be considered views in other MVC > frameworks (the .tt files, I guess) are put into the root/src and > root/lib directories instead of the View directory. Why? You might have view in addition to your TT view. First off, not everyone uses TT as a templating language (see Mason, HTML::Template, Template::Declare, etc.). Secondly, you can have more than one view; consider the case of RSS feeds, Email, JSON, XML, etc. I recommend a search for "Catalyst::View" on the CPAN for more details. Regards, Jonathan Rockway ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/
[Catalyst] Beginner question: View directory
I'm trying to learn Catalyst by working my way through the tutorial and other docs, and I'm a little puzzled by the View directory. In the tutorials it only has a TT.pm file in it, which is a config file for Template Toolkit. Are there ever any other kinds of files in that directory? The files that would be considered views in other MVC frameworks (the .tt files, I guess) are put into the root/src and root/lib directories instead of the View directory. Why? Confused... Gerda Shank ___ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ Dev site: http://dev.catalyst.perl.org/