Re: [Catalyst] Gentoo myapp_fastcgi.pl startup script?
You may want to check out http://www.catalystframework.org/calendar/2006/16, but I would recommend going the daemontools route: http://www.catalystframework.org/calendar/2006/4 ___ 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] Recommend methods for form handling
snip The only issue I had was with checkboxes filled in from the database, since CGI does not send back a value for unchecked checkboxes then FillInForm would not handle them correctly so I had to develop a work-around. Regards Ian Docherty (IcyDee) Oh, amazing! I was just starting to write a post asking something like that, although my problem showed on radiobuttons (e.g. option 0=No doesn't get selected), using Formbuilder, but I think it's the same principle. Would you please show/explain your workaround? In the meanwhile, I just tried using false instead of 0 (works for inserting/updating, at least with PostgreSQL) and converting 0 to false when filling form, but I don't think it's really elegant... Regards, Juan Juan I have a hidden field in the form 'action' which is true when the form is submitted, but false the first time the form is displayed (from the database). Then for a checkbox (and I assume this could be extended to radio buttons) I do the following in my template. input name=user_active type=checkbox [% IF user.active and not action %]checked[% END %] So, first time round the 'checked' values depends only on the user.active flag (from the database) on subsequent times round (for example when a form error was found) and 'action' is set then the state of the checkbox is handled by FillInForm. Without the 'and not action' bit if the database had 'user.active' set then if an attempt to uncheck the checkbox was made, and if there was an error on the form elsewhere, FillInForm would not uncheck the box. Regards Ian Docherty (IcyDee) ___ 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] Re: Catalyst vs Rails vs Django Cook off
* Jay K [EMAIL PROTECTED] [2007-01-17 18:20]: I agree 100% on this... if we are judging Catalyst, et al, as simple dispatchers, then we should consider apache+cgi in the discussion as well - as apache is obviously one of the most venerable and widely deployed dispatchers out there. Eh? Apache doesn’t dispatch anything unless maybe you’re talking about mod_perl, and CGI.pm certainly doesn’t dispatch anything. Not in the web framework sense of dispatch anwyay, which was born precisely out of the desire to avoid having to write an ad-hoc dispatcher in every CGI script. Regards, -- Aristotle Pagaltzis // http://plasmasturm.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] Accessing YAML details from within the Model libraries
--- Anthony Gladdish [EMAIL PROTECTED] wrote: Hi, I'm trying to pull out all my DBIx::Class connection details for my Catalyst application, from a .yml config file, something like: --- model: MyCatPackage::Cat::Model::MyPackageDB schema_class: MyPackage::Schema connect_info: dsn: DBI:mysql:database=somedb;host=somehost username: user1 password: password1 Is it possible to access these details from the application's Model libraries? If so, what is the recommended way? I only seem to be able to access '__PACKAGE__-config-{schema_class}' (for example), via the catalyst application's main library, and NOT from within any of the Model libraries. Thanks, Anthony I put all my config into into the .yml files for models. My setup look like this: 'Model::myschemas': schema_class: 'Schema::db' connect_info: - 'DBI:mysql:database=mydb;host=localhost' - 'xx' - 'xxx' - RaiseError: 1 PrintError: 0 ShowErrorStatement: 1 TraceLevel: 0 I'm not sure about Models, but anything you put into a controller is available via $self-{attr} 'Controller::test': attr: onetwothree then: package myapp::Controller::test; [snip snip] sub myaction :Local { my ($self, $c) = @_; $c-log-info($self-{attr}); #onetwothree to log } I haven't tested this but I image it would work from Views and Models as well. Give it a try. --john ___ 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/ Get your own web address. Have a HUGE year through Yahoo! Small Business. http://smallbusiness.yahoo.com/domains/?p=BESTDEAL ___ 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] Catalyst::Helper::Model::DBIC::Schema patchette?
Kieren Diment wrote: script/myapp_create.pl model CatalystModelName DBIC::Schema MySchemaClass [ create=dynamic | create=static ] [ connect_info arguments ] I would recommend an example that uses some usual naming conventions: create.pl model SomethingDB DBIC::Schema Schema::SomethingDB create=static dbi:SQLite:database In fact, I would recommend that: create.pl model SomethingDB DBIC::Schema dbi:... Does What They Mean, i.e. create a static schmea in MyApp::Schema::SomethingDB::*. That would save typing for the very common case. Finally, the helper should add two scripts as well: myapp_somethingdb_createschema.pl (that will copy the schema from a named object to a DBIC schema module), and myapp_somethingdb_deploy.pl, which will push the schema to the database named in the myapp.[cfg|yml|whatever] file. I'm a bit swamped at the moment, but these should be super simple to write. Copy mojomojo_spawn as the _deploy script, and just do a one-liner around SQL::Translator for the _createschema.pl script. If someone would implement that, it would make DBIC::Schema even more pleasant than it already is. ;) -- package JAPH;use Catalyst qw/-Debug/;($;=JAPH)-config(name = do { $,.=reverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //, ;$;]-[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;-setup; ___ 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] Re: Catalyst vs Rails vs Django Cook off
A. Pagaltzis wrote: Eh? Apache doesn’t dispatch anything unless maybe you’re talking about mod_perl If that's true, then GETting http://mysite.com/foo/bar/baz.html would get a file named $DOCROOT/foo\/bar\/baz.html. Considering that's never the case (you can't have / in UNIX filenames, only paths), I would say Apache is a dispatcher. Add mod_alias and mod_rewrite into the mix, and Apache is definitely a URL dispatcher. -- package JAPH;use Catalyst qw/-Debug/;($;=JAPH)-config(name = do { $,.=reverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //, ;$;]-[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;-setup; ___ 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] Accessing YAML details from within the Model libraries
John Napiorkowski wrote: package myapp::Controller::test; [snip snip] sub myaction :Local { my ($self, $c) = @_; $c-log-info($self-{attr}); #onetwothree to log } It would be better if you did: package MyApp::C::Test; use base 'Catalyst::Controller'; __PACKAGE__-mk_accessors(qw/attr somethingelse whatever/); # ^^ important! sub an_action :Whatever { my ($self, $c, @args) = @_; my $attr = $self-attr; # get $self-somethingelse('something else'); # set } You can set them via the config file as above: Controller::Test: attr: foo whatever: bar See the Class::Accessor documentation for full details on how these accessors work. I haven't tested this but I image it would work from Views and Models as well. Give it a try. It works. Views, Models, and Controllers are all Components. Theoretically you can have components that aren't M/V/C, but I've never done that. -- package JAPH;use Catalyst qw/-Debug/;($;=JAPH)-config(name = do { $,.=reverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //, ;$;]-[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;-setup; ___ 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] Re: Catalyst vs Rails vs Django Cook off
* Jonathan Rockway [EMAIL PROTECTED] [2007-01-18 17:55]: A. Pagaltzis wrote: Eh? Apache doesn’t dispatch anything unless maybe you’re talking about mod_perl If that's true, then GETting http://mysite.com/foo/bar/baz.html would get a file named $DOCROOT/foo\/bar\/baz.html. Considering that's never the case (you can't have / in UNIX filenames, only paths), I would say Apache is a dispatcher. Add mod_alias and mod_rewrite into the mix, and Apache is definitely a URL dispatcher. Hmm, you’re right. I guess I’ll start writing my apps as lots of little CGI scripts so that I can use the Apache dispatching. No wait, this isn’t 1992 anymore. (Except for many PHP people who’re still stuck there.) Last I checked, Apache’s URI translation won’t route requests to particular methods within an app that’s launched from a single script, so no, Apache is not a dispatcher in the sense that Catalyst or RoR is. You can of course load your app *into* the webserver with mod_perl, in which case you can configure Apache to dispatch the URI to a particular method in your app; but I mentioned that as an exception in the previous mail anyway. I assumed that would be enough of a hint, but I guess I expected too much. Are we done splitting this hair now or do you need more clarification? Regards, -- Aristotle Pagaltzis // http://plasmasturm.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/
[Catalyst] Re: Catalyst vs Rails vs Django Cook off
* Jonathan Rockway [EMAIL PROTECTED] [2007-01-18 19:40]: A. Pagaltzis wrote: Are we done splitting this hair now or do you need more clarification? Depends on what you mean by methods: foo.pl: use MyApp; print MyApp-foo($ENV{QUERY_STRING}); bar.pl: use MyApp; print MyApp-bar($ENV{QUERY_STRING}); I don't think this is a good idea, but you can do it if you want to. can and good idea is the hair that I'm splitting. Yes, sure, as I already said in my previous mail [1], you can abuse Apache’s URI-to-filesystem mapper as a dispatcher with the right contortions as long as your URI structure is static. (No wait, your next mail will point out that you can create directories and generate scripts from a template; so the URI structure needn’t be static.) Noone in their right mind is going to want to in practice, of course. So when the subject was what dispatchers should be benchmarked, why point it out? Is anyone going to care? I guess it’s me who shouldn’t have. Sorry. I should know better. [1] Does anyone notice a pattern here? Regards, -- Aristotle Pagaltzis // http://plasmasturm.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] Recommend methods for form handling
Ian Docherty wrote: Jim Spath wrote: Thanks for all the responses guys, they have been very helpful! What about multi-lingual support? It seems like FormBuilder is my best choice if I want to add multi-lingual support down the road. - Jim What has FormBuilder got to do with multi-lingual support? I use Catalyst::Plugin::I18N::DBIC (shameless plug) I don't use FormBuilder, I 'roll my own' html which gives me more control. Well, if you like how FormBuilder does the layout, you might as well let it do the i18n. For the rest of the site, though, you'll need something else, I would imagine. FormBuilder is rather non-Catalyst-y in the sense that it's a little bloated. Removing FormBuilder's built-in templating, i18n, etc. and integrating them with Catalyst's facilities for these things would be a nice project. In the mean time, FormBuilder's default are quite convenient for most people, especially if you use TTSite. I like it, anyway. -- package JAPH;use Catalyst qw/-Debug/;($;=JAPH)-config(name = do { $,.=reverse qw[Jonathan tsu rehton lre rekca Rockway][$_].[split //, ;$;]-[$_].q; ;for 1..4;$,=~s;^.;;;$,});$;-setup; ___ 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] Re: Catalyst vs Rails vs Django Cook off
* Jay K [EMAIL PROTECTED] [2007-01-18 20:10]: Point being that frameworks provide more than choosing what to do, Care to actually mention a few examples? if you stop the comparison at that point, then you might as well include every web server in your comparison. As long as the web server provides a way to dispatch to a piece of my own code, then yes, absolutely. Apache + mod_perl is a reasonable benchmark candidate, f.ex. Regards, -- Aristotle Pagaltzis // http://plasmasturm.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] Templates in the database
On Jan 18, 2007, at 3:22 PM, Bill Moseley wrote: I do maintain a history of these pages, and I have a crude diff view using Algorithm::Diff. I have a table that holds the history of the content and use triggers to write to it on update. Is this how you are (or would) do this? I am doing post history/revision with a similar, but crude, interface to what wikimedia uses. Doing it with Algorithm::Diff and Algorithm::Diff::Apply (and YAML). I'm not confident my code is clean or something to emulate but I put part of it in the foot. Not including the TT stuff but I'll send it to you if you're curious. The only thing I'd also suggest (which I'm not actually doing yet) is doing a compilation of the edited template before saving it. Only save it and catch the revision if it compiles (i.e. the editor working on it hasn't broken it). There would be no reason to allow broken templates into your history. It would just gum up the revision process. -Ashley -- # IN the table's schema sub store_column { my ( $self, $name, $value ) = @_; $value =~ s/[^[:print:]\s]//g; # not sure this is a good idea 321 222 if ( $name eq body and $self-in_storage and $self-body ) { my @original = split /\n/, $self-body; my @new = split /\n/, $value; chomp( @original, @new ); my @diff = Algorithm::Diff::diff( [EMAIL PROTECTED], [EMAIL PROTECTED] ); $self-add_to_revisions({ diff = YAML::freeze([EMAIL PROTECTED]) }) if @diff; } $self-next::method($name, $value); } # IN the table's editor/admin sub rev : Chained(/article/article) : Args(1) { my ( $self, $c, $rev ) = @_; my $article = $c-stash-{article}; my @revisions = $article-revisions; @revisions = $rev || die RC_404: no such revision to article . $article-id; my ( @reverted, @tmp ); my @body = split /\n/, $article-body; @tmp = @body; for ( my $i = @revisions; $i = $rev; ) { $i--; my $diff = YAML::thaw($revisions[$i]-diff); @tmp = @reverted if @reverted; @reverted = Algorithm::Diff::Apply::apply_diff([EMAIL PROTECTED], $diff); } chomp(@reverted); chomp(@body); s/$CRLF|$LF|$CR// for @reverted, @body; my @sdiff = Algorithm::Diff::sdiff( [EMAIL PROTECTED], [EMAIL PROTECTED] ); my %english = ( '+' = 'added', '-' = 'removed', # removed-ish 'u' = 'unmodified', 'c' = 'changed', ); $_-[0] = $english{$_-[0]} for @sdiff; $c-stash( template = 'admin/article/edit.tt', nosidebar = 1, revision = $rev, sdiff = [EMAIL PROTECTED], body = join(\n, @reverted) ); } ___ 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/