From simon@simon-cozens.org Tue Feb 1 08:58:22 2005 From: simon@simon-cozens.org (Simon Cozens) Date: Tue, 1 Feb 2005 08:58:22 +0000 Subject: [Maypole] Maypole on Windows success Message-ID: <20050201085822.GB22158@alibi.simon-cozens.org> Here, for posterity, is a log of actions I took to get a Maypole application up and running on a bare Windows machine. It can probably be done a lot simpler, and some of the modules I installed are specific to the application, but it proves it can be done: Install Perl: http://downloads.activestate.com/ActivePerl/Windows/5.8/ActivePerl-5.8.6.811-MSWin32-x86-122208.msi Install vim: ftp://ftp.vim.org/pub/vim/pc/vim63w32.zip Install nmake: ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe Install pscp Install 4nt ppm3 rep add theoryx5 http://theoryx5.uwinnipeg.ca/ppms/ Install XML-LibXSLT Install Class-DBI Install DBD-SQLite rep add interact http://openinteract.sourceforge.net/ppmpackages Install Template-Toolkit Install UNIVERSAL-exports Install SQL-Statement Install Test-MockModule Install XML-TreeBuilder Install File-Slurp Install Module-Build cpan install CPANPLUS get Class::DBI (0.96 is later than ppm version) cpanp install Class::DBI::SQLite install Template::Plugin::Class install Maypole -- WILLIAM: Just incidentally -- why are you wearing that? SPIKE: Ahm -- combination of factors really. No clean clothes... W: There never will be, you know, unless you actually clean your clothes. S: Right. Vicious circle. From m.romani@spinsoft.it Tue Feb 1 14:53:28 2005 From: m.romani@spinsoft.it (Marcello) Date: Tue, 01 Feb 2005 15:53:28 +0100 Subject: [Maypole] Maypole on Windows success In-Reply-To: <20050201085822.GB22158@alibi.simon-cozens.org> References: <20050201085822.GB22158@alibi.simon-cozens.org> Message-ID: <41FF97E8.6020106@spinsoft.it> Simon Cozens ha scritto: > Here, for posterity, is a log of actions I took to get a Maypole application > up and running on a bare Windows machine. It can probably be done a lot > simpler, and some of the modules I installed are specific to the application, > but it proves it can be done: > > Install Perl: http://downloads.activestate.com/ActivePerl/Windows/5.8/ActivePerl-5.8.6.811-MSWin32-x86-122208.msi > Install vim: ftp://ftp.vim.org/pub/vim/pc/vim63w32.zip > Install nmake: ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe > Install pscp > Install 4nt > ppm3 > rep add theoryx5 http://theoryx5.uwinnipeg.ca/ppms/ > Install XML-LibXSLT > Install Class-DBI > Install DBD-SQLite > rep add interact http://openinteract.sourceforge.net/ppmpackages > Install Template-Toolkit > Install UNIVERSAL-exports > Install SQL-Statement > Install Test-MockModule > Install XML-TreeBuilder > Install File-Slurp > Install Module-Build > > cpan > install CPANPLUS > get Class::DBI (0.96 is later than ppm version) > > cpanp > install Class::DBI::SQLite > install Template::Plugin::Class > install Maypole > Thank you very much for this information. Marcello From jkeroes@eli.net Tue Feb 1 16:34:19 2005 From: jkeroes@eli.net (Joshua Keroes) Date: Tue, 1 Feb 2005 08:34:19 -0800 Subject: [Maypole] Maypole on Windows success In-Reply-To: <20050201085822.GB22158@alibi.simon-cozens.org> References: <20050201085822.GB22158@alibi.simon-cozens.org> Message-ID: <1ED6DD93-746F-11D9-BD01-000A95C466EC@eli.net> On Feb 1, 2005, at 12:58 AM, Simon Cozens wrote: > Here, for posterity, is a log of actions I took to get a Maypole > application > up and running on a bare Windows machine. It can probably be done a lot > simpler, and some of the modules I installed are specific to the > application, > but it proves it can be done: [snip] That's good stuff. It's now linked off Wiki's FAQ to http://maypole.perl.org/?WindowsInstall . Might look better in the INSTALL. Cheers, J From j.chladek@wirtschaftsblatt.at Tue Feb 1 16:37:01 2005 From: j.chladek@wirtschaftsblatt.at (Josef Chladek) Date: Tue, 1 Feb 2005 17:37:01 +0100 Subject: [Maypole] mixing of tables in create In-Reply-To: <20050131201721.32291.qmail@web52108.mail.yahoo.com> References: <20050131201721.32291.qmail@web52108.mail.yahoo.com> Message-ID: <7F7F4D0C-746F-11D9-8C00-000A9575B1A4@wirtschaftsblatt.at> Am 31.01.2005 um 21:17 schrieb Peter Speltz: > > --- Josef Chladek wrote: > >> i'm fairly new to maypole, so excuse me if i'm asking something purely >> trivial. i've been studying the docs and examples but can't figure out >> how to realize mixing of textfields/areas from DIFFERENT tables in one >> create/edit >> >> create table article (id int not null auto_increment primary key, >> title varchar(100), >> lead text); >> >> create table textblock (id int not null auto_increment primary key, >> article integer, >> block text); >> >> an article has many textblocks. >> >> what i want to realize is a create mask, which has >> >> title >> lead >> block [0..n] >> >> in it. it seems that i'm only able to create the article FIRST, and >> then start adding blocks that i assign to the article. for an article >> this is not the most desired workflow... >> >> thanks >> josef >> > > Hi josef. > > I assume you're using default "FromCGI::create_from_cgi" sub to > create your > objects. This is a limitation of that -- it doesn't create objects > with many > components very well.. It could probably be overriden to > automatically add > your blocks to the article. I'd be interested in a solution to this > if you > write one. I've thought about doing this for a while but haven't > gotten around > to it. hello peter, yes, i'm using the FromCGI, but as my knowledge of maypole is that of a beginner (not to speak of CDBI) at the moment i have NO clue where to implement that (override the do_edit? how and where could i override the create_from_cgi? ...) as i read on www.spanner.org (http://www.spanner.org/lists/cdbi/2004/11/04/54ea4da4.html) > There's been talk a few times of having Class::DBI's normal create() be > able to take arguments for related classes as well, and do the right > thing. Nothing's really ever come of it, but if it did, then this may > help with your problem (rather than trying to handle it in > create_from_cgi itself). > > Tony any progress on that, or any plan to implement that in cdbi in the near future? thanks josef From dhudes@hudes.org Tue Feb 1 17:03:17 2005 From: dhudes@hudes.org (Dana Hudes) Date: Tue, 1 Feb 2005 12:03:17 -0500 (EST) Subject: [Maypole] Maypole::Plugin::Relationships and YAML Message-ID: First off, I want to note for anyone fooling with YAML: do not try to use TAB to indent. YAML won't like it, use only spaces. Now to the main point: I'm trying to use Maypole::Plugin::Relationship with YAML so I have use Maypole::Application qw(Config::YAML Loader Untaint Relationship -Setup); in my main module. I'm using Postgresql. I'll simplify my data model (!) for a similar example. Let us say I have clothes and I wish to use a controlled vocabulary for color (e.g., the Pantone colors so that I have an exact specification of color). So of course the color table has the structure TABLE colors ( ident SERIAL NOT NULL PRIMARY KEY, name VARCHAR(32) NOT NULL, C int2, M int2, Y int2, K int2 ); TABLE clothes ( ident SERIAL NOT NULL PRIMARY KEY, name VARCHAR(32), color integer, designer VARCHAR(64), -- really should be a CV also but for simplicity FOREIGN KEY ("color") REFERENCES "colors"("name") ); and then in my YAML spec, after the dbi config (which is fine, if it didn't work it would object) relationships: -a clothes has colors Now, the stock CDBI::Relationship::HasA will just bark "has_a needs a valid column" and if you've got multiple columns and multiple tables you're left wondering just what's the problem , exactly. So I've made a mod to HasA.pm to spit out the class nam and the candidate column name to which it objects. I'll send that to the CDBI list. After my mod, it tells me that its objecting to class (table) Colors and column clothing ! From peterspeltz@yahoo.com Tue Feb 1 17:09:43 2005 From: peterspeltz@yahoo.com (Peter Speltz) Date: Tue, 1 Feb 2005 09:09:43 -0800 (PST) Subject: [Maypole] mixing of tables in create In-Reply-To: <7F7F4D0C-746F-11D9-8C00-000A9575B1A4@wirtschaftsblatt.at> Message-ID: <20050201170943.33302.qmail@web52105.mail.yahoo.com> --- Josef Chladek wrote: > > hello peter, > > yes, i'm using the FromCGI, but as my knowledge of maypole is that of a > beginner (not to speak of CDBI) at the moment i have NO clue where to > implement that (override the do_edit? how and where could i override > the create_from_cgi? ...) I was thinking override create_from_cgi. you should just be able to put a sub in your base model class (or just class you want the override) called create_from_cgi. > (http://www.spanner.org/lists/cdbi/2004/11/04/54ea4da4.html) > > > There's been talk a few times of having Class::DBI's normal create() be > > able to take arguments for related classes as well, and do the right > > thing. Nothing's really ever come of it, but if it did, then this may > > help with your problem (rather than trying to handle it in > > create_from_cgi itself). > > > > Tony > > any progress on that, or any plan to implement that in cdbi in the near > future? > That'd be cool if there was progress on that. It make create_from_cgi work easier. What i want is to have create_from_cgi create all objects on the form. with one call. That is my form for a customer has address, person, customer inputs it will create those three objects and cross ref them. Problem was there wasn't a 1:1 relationship so you never knew if this was a required component or optional. so i made one, "has_one". Now AsForm can make inputs automatically for classes of that relationship and hopefully fromCGI can create them soon. _____________________________________ > maypole mailing list > maypole@lists.netthink.co.uk > http://lists.netthink.co.uk/listinfo/maypole > ===== pjs __________________________________ Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. http://promotions.yahoo.com/new_mail From tony@kasei.com Tue Feb 1 17:40:26 2005 From: tony@kasei.com (Tony Bowden) Date: Tue, 1 Feb 2005 17:40:26 +0000 Subject: [Maypole] mixing of tables in create In-Reply-To: <7F7F4D0C-746F-11D9-8C00-000A9575B1A4@wirtschaftsblatt.at> References: <20050131201721.32291.qmail@web52108.mail.yahoo.com> <7F7F4D0C-746F-11D9-8C00-000A9575B1A4@wirtschaftsblatt.at> Message-ID: <20050201174026.GA32355@soto.kasei.com> On Tue, Feb 01, 2005 at 05:37:01PM +0100, Josef Chladek wrote: > >There's been talk a few times of having Class::DBI's normal create() be > >able to take arguments for related classes as well, and do the right > >thing. Nothing's really ever come of it, but if it did, then this may > >help with your problem (rather than trying to handle it in > >create_from_cgi itself). > any progress on that, or any plan to implement that in cdbi in the near > future? I'm open to patches, but I've no plans (or time) to do it myself any time soon... Tony From jenniferfan007@yahoo.ca Tue Feb 1 17:50:52 2005 From: jenniferfan007@yahoo.ca (jennifer fan) Date: Tue, 1 Feb 2005 12:50:52 -0500 (EST) Subject: [Maypole] problem when I run beerdb Message-ID: <20050201175052.93697.qmail@web60407.mail.yahoo.com> Apache: 2.0.52 libapreq2-2.0.4-dev Followed the Maypole::Manual::About tried to see the beerdb from brower, but error messages I got in error_log. Can't locate Apache/Request.pm in @INC(..... at /usr/lib/perl5/site_perl/5.8.3/Apache/MVC.pm line 22.\nCompilation failed in require at (eval 3) line 3.\n\t...propagated at /usr/lib/perl5/5.8.3/base.pm line 70.\nBEGIN failed--compilation aborted at /usr/local/apache2/htdocs/beerdb/BeerDB.pm line 2.\nCompilation failed in require at (eval 2) line 3.\n ) Should to reinstall Apache 2.0.52 to Apache 2.0.46 as libapreq2-2.0.4-dev/PREREQUISITES said? Do it have a way to install Request.pm with Apache 2.0.52? Any ideas will be appreciated. Jennifer ______________________________________________________________________ Post your free ad now! http://personals.yahoo.ca From matt.adams@morcor.com Tue Feb 1 18:05:50 2005 From: matt.adams@morcor.com (Matt Adams) Date: Tue, 01 Feb 2005 13:05:50 -0500 Subject: [Maypole] Maypole::Application adds plugin classes to caller's @ISA Message-ID: <41FFC4FE.9080500@morcor.com> Hi there: I recently upgraded to Maypole 2.08 and discovered that it is not compatible with the Maypole app I have been using. I'm hoping that those of you who are more familiar with the Maypole-innards will be able to shed some light on why I'm having the problems I am. In the `Changes' file for Maypole 2.08 a fix is listed from Marcus Ramberg where "Maypole::Application adds plugin classes to caller's @ISA." The effect of this patch appears to be: --- Application.pm (my older copy) +++ Application.pm (Maypole SVN revision 334) @@ -7,7 +7,7 @@ use Maypole::Config; our @ISA; -our $VERSION = '2.07'; +our $VERSION = '2.08'; sub import { my ( $self, @plugins ) = @_; @@ -28,7 +28,7 @@ if ($@) { warn qq(Loading plugin "Maypole::Plugin::$_" failed: $@) } else { warn "Loaded plugin: Maypole::Plugin::$_" if $caller->debug; - unshift @ISA, "Maypole::Plugin::$_"; + push @{"${caller}::ISA"}, "Maypole::Plugin::$_"; } } } Now this is all fine and dandy but when I apply this patch my application breaks with the following error: MyApp...Debugging enabled MyApp...Loaded plugin: Maypole::Plugin::Authentication::Abstract MyApp...Loaded plugin: Maypole::Plugin::Config::YAML MyApp...No DSN set in config [error] Can't locate object method "new" via package "Class::DBI::Loader::" (perhaps you forgot to load "Class::DBI::Loader::"?) at /.../lib/Class/DBI/Loader.pm line 77. BEGIN failed--compilation aborted at /.../MyApp.pm line 36. Compilation failed in require at (eval 10) line 3. [error] Can't call method "_table2class" on an undefined value at /.../lib/Maypole/Model/CDBI.pm line 250. It may help to know that I begin the Maypole app by writing: BEGIN { package MyApp; use MyApp::Constants; $ENV{MAYPOLE_CONFIG} = BINPATH . '/MyApp.yaml'; } package MyApp; use Maypole::Application qw( -Debug Config::YAML Authentication::Abstract -Setup ); And that I am using Maypole::Plugin::Config::YAML 0.04 and Maypole::Plugin::Authentication::Abstract 0.10. Any explanations as to why this patch to Application.pm was made would be greatly appreciated as would be any suggestions concerning how I might go about fixing my application! Thanks Matt -- Matt Adams Development Specialist Morcor Solutions Inc. (613) 354-2912 x228 GnuPG public key at Key fingerprint: BED5 B4F7 CCF5 D7B5 7C56 0505 9A0A A0FB C937 5975 From sri@oook.de Tue Feb 1 18:01:14 2005 From: sri@oook.de (Sebastian Riedel) Date: Tue, 01 Feb 2005 19:01:14 +0100 Subject: [Maypole] Maypole::Plugin::Relationships and YAML In-Reply-To: References: Message-ID: <1107280874.19712.16.camel@localhost> Dana Hudes: > I'm using Postgresql. > I'll simplify my data model (!) for a similar example. Let us say I have > clothes and I wish to use a controlled vocabulary for color (e.g., the > Pantone colors so that I have an exact specification of color). So of > course the color table has the structure > TABLE colors ( > ident SERIAL NOT NULL PRIMARY KEY, > name VARCHAR(32) NOT NULL, > C int2, > M int2, > Y int2, > K int2 > ); > > TABLE clothes ( > ident SERIAL NOT NULL PRIMARY KEY, > name VARCHAR(32), > color integer, > designer VARCHAR(64), -- really should be a CV also but for simplicity > FOREIGN KEY ("color") REFERENCES "colors"("name") > ); > relationships: > -a clothes has colors > Plural table names are bad bad bad! Use id as primary key... This is better. TABLE color ( id SERIAL NOT NULL PRIMARY KEY, name VARCHAR(32) NOT NULL, C INT2, M INT2, Y INT2, K INT2 ); TABLE cloth ( id SERIAL NOT NULL PRIMARY KEY, name VARCHAR(32), color INTEGER REFERENCES color (id), designer VARCHAR(64) ); You already have foreign keys in your sql, so you should let Class::DBI::Loader setup your relationships. Just set relationships => 1 in Maypole::Model::CDBI -- sebastian From marcus@thefeed.no Tue Feb 1 18:26:47 2005 From: marcus@thefeed.no (Marcus Ramberg) Date: Tue, 01 Feb 2005 19:26:47 +0100 Subject: [Maypole] Maypole::Application adds plugin classes to caller's @ISA In-Reply-To: <41FFC4FE.9080500@morcor.com> References: <41FFC4FE.9080500@morcor.com> Message-ID: Hey Matt. I'm not about to be blamed for this ;-) Simon changed my patch, which actually made a proxy class for you application to inherit from, and he borked it up. He's fixed it in 2.09, which is available from CPAN. Marcus On 1. feb. 2005, at 19.05, Matt Adams wrote: > Hi there: > > I recently upgraded to Maypole 2.08 and discovered that it is not > compatible with the Maypole app I have been using. I'm hoping that > those of you who are more familiar with the Maypole-innards will be > able to shed some light on why I'm having the problems I am. > > In the `Changes' file for Maypole 2.08 a fix is listed from Marcus > Ramberg where "Maypole::Application adds plugin classes to caller's > @ISA." The effect of this patch appears to be: > > --- Application.pm (my older copy) > +++ Application.pm (Maypole SVN revision 334) > @@ -7,7 +7,7 @@ > use Maypole::Config; > > our @ISA; > -our $VERSION = '2.07'; > +our $VERSION = '2.08'; > > sub import { > my ( $self, @plugins ) = @_; > @@ -28,7 +28,7 @@ > if ($@) { warn qq(Loading plugin "Maypole::Plugin::$_" > failed: $@) } > else { > warn "Loaded plugin: Maypole::Plugin::$_" if > $caller->debug; > - unshift @ISA, "Maypole::Plugin::$_"; > + push @{"${caller}::ISA"}, "Maypole::Plugin::$_"; > } > } > } > > Now this is all fine and dandy but when I apply this patch my > application breaks with the following error: > > MyApp...Debugging enabled > MyApp...Loaded plugin: Maypole::Plugin::Authentication::Abstract > MyApp...Loaded plugin: Maypole::Plugin::Config::YAML > MyApp...No DSN set in config > [error] Can't locate object method "new" via package > "Class::DBI::Loader::" (perhaps you forgot to load > "Class::DBI::Loader::"?) at /.../lib/Class/DBI/Loader.pm line 77. > BEGIN failed--compilation aborted at /.../MyApp.pm line 36. > Compilation failed in require at (eval 10) line 3. > [error] Can't call method "_table2class" on an undefined value at > /.../lib/Maypole/Model/CDBI.pm line 250. > > It may help to know that I begin the Maypole app by writing: > > BEGIN { > package MyApp; > use MyApp::Constants; > $ENV{MAYPOLE_CONFIG} = BINPATH . '/MyApp.yaml'; > } > > package MyApp; > > use Maypole::Application qw( > -Debug > Config::YAML > Authentication::Abstract > -Setup > ); > > And that I am using Maypole::Plugin::Config::YAML 0.04 and > Maypole::Plugin::Authentication::Abstract 0.10. > > Any explanations as to why this patch to Application.pm was made would > be greatly appreciated as would be any suggestions concerning how I > might go about fixing my application! > > > Thanks > > Matt > -- > Matt Adams > Development Specialist > Morcor Solutions Inc. > (613) 354-2912 x228 > > GnuPG public key at > Key fingerprint: BED5 B4F7 CCF5 D7B5 7C56 0505 9A0A A0FB C937 5975 > > _______________________________________________ > maypole mailing list > maypole@lists.netthink.co.uk > http://lists.netthink.co.uk/listinfo/maypole From matt.adams@morcor.com Tue Feb 1 18:32:26 2005 From: matt.adams@morcor.com (Matt Adams) Date: Tue, 01 Feb 2005 13:32:26 -0500 Subject: [Maypole] Re: Maypole::Application adds plugin classes to caller's @ISA Message-ID: <41FFCB3A.5020506@morcor.com> Hi Marcus: Thanks for the heads-up. I check out 2.09! Matt -- Matt Adams Development Specialist Morcor Solutions Inc. (613) 354-2912 x228 GnuPG public key at Key fingerprint: BED5 B4F7 CCF5 D7B5 7C56 0505 9A0A A0FB C937 5975 From matt.adams@morcor.com Tue Feb 1 18:32:08 2005 From: matt.adams@morcor.com (Matt Adams) Date: Tue, 01 Feb 2005 13:32:08 -0500 Subject: [Maypole] Re: Maypole::Application adds plugin classes to caller's @ISA Message-ID: <41FFCB28.7060300@morcor.com> Hi Marcus: Thanks for the heads-up. I check out 2.09! Matt -- Matt Adams Development Specialist Morcor Solutions Inc. (613) 354-2912 x228 GnuPG public key at Key fingerprint: BED5 B4F7 CCF5 D7B5 7C56 0505 9A0A A0FB C937 5975 From Dave.Howorth@acm.org Tue Feb 1 19:56:34 2005 From: Dave.Howorth@acm.org (Dave Howorth) Date: Tue, 01 Feb 2005 19:56:34 +0000 Subject: [Maypole] Maypole::Plugin::Relationships and YAML In-Reply-To: <1107280874.19712.16.camel@localhost> References: <1107280874.19712.16.camel@localhost> Message-ID: <41FFDEF2.8060709@acm.org> Sebastian Riedel wrote: > Plural table names are bad bad bad! They work perfectly with my loader :) That was one inconsequential factor that drove me to write it. > Use id as primary key... > > This is better. Well, it's doubleplus conformant with the thought police maybe :) Cheers, Dave -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.8.3 - Release Date: 31/01/05 From matt.adams@morcor.com Tue Feb 1 19:58:50 2005 From: matt.adams@morcor.com (Matt Adams) Date: Tue, 01 Feb 2005 14:58:50 -0500 Subject: [Maypole] Maypole::Application still broken in 2.09? Message-ID: <41FFDF7A.3060706@morcor.com> Hi there: Just wondering if Marcus R. or Simon F. (or anyone else) had any other suggestions as to why Maypole::Application is still broken in 2.09. Maybe it's not... maybe it's me? Here's the problem (same as before -- just slightly edited). I recently upgraded to Maypole 2.09 and discovered that it is not compatible with the Maypole app I have been using. I'm hoping that those of you who are more familiar with the Maypole-innards will be able to shed some light on why I'm having the problems I am. It would appear that the neat stuff in Maypole::Application 2.09 is still causing problems for my poor Maypole-powered application. If I downgrade to Maypole::Application 2.07 everything works fine. I don't think my Maypole app is all that odd. Here's how it begins: BEGIN { package MyApp; use MyApp::Constants; $ENV{MAYPOLE_CONFIG} = BINPATH . '/MyApp.yaml'; } package MyApp; use Maypole::Application qw( -Debug Config::YAML Authentication::Abstract -Setup ); But unfortunately this doesn't work out too well with Maypole::Application 2.09 which still gives me the same error as in 2.08: MyApp...Debugging enabled MyApp...Loaded plugin: Maypole::Plugin::Authentication::Abstract MyApp...Loaded plugin: Maypole::Plugin::Config::YAML MyApp...No DSN set in config [error] Can't locate object method "new" via package "Class::DBI::Loader::" (perhaps you forgot to load "Class::DBI::Loader::"?) at /.../lib/Class/DBI/Loader.pm line 77. BEGIN failed--compilation aborted at /.../MyApp.pm line 36. Compilation failed in require at (eval 10) line 3. [error] Can't call method "_table2class" on an undefined value at /.../lib/Maypole/Model/CDBI.pm line 250. Can someone give me some pointers as to a) how to fix my app so that it is compliant with Maypole::Application 2.09 and/or b) what exactly was the purpose of the neat code in Maypole::Application 2.09? FWIW, I'm using a PERL5LIB path modified by my Apache configuration. Thanks! Matt -- Matt Adams Development Specialist Morcor Solutions Inc. (613) 354-2912 x228 GnuPG public key at Key fingerprint: BED5 B4F7 CCF5 D7B5 7C56 0505 9A0A A0FB C937 5975 From dhudes@hudes.org Tue Feb 1 22:15:24 2005 From: dhudes@hudes.org (Dana Hudes) Date: Tue, 1 Feb 2005 17:15:24 -0500 (EST) Subject: [Maypole] Maypole::Plugin::Relationships and YAML In-Reply-To: <41FFDEF2.8060709@acm.org> References: <1107280874.19712.16.camel@localhost> <41FFDEF2.8060709@acm.org> Message-ID: On Tue, 1 Feb 2005, Dave Howorth wrote: > Sebastian Riedel wrote: > > Plural table names are bad bad bad! > > They work perfectly with my loader :) > That was one inconsequential factor that drove me to write it. I don't see your loader on CPAN... > > > Use id as primary key... > > > > This is better. > > Well, it's doubleplus conformant with the thought police maybe :) With Sebastian, and nobody else including major works on database theory, ontology, semantics....you don't see Ullman writing schema with 'id'. Nor Codd. I don't believe Tim Berners-Lee used that as an identifier in his work on the Semantic Web. Individual objects may, or may not be, plural. Tables of rows certainly make sense as plural names. Or worse yet, collection names may be another word altogether. think about the plural and singular of clothing. We have an article, not item, of clothing and we have a collection of clothes....or a line of clothes is a term often used in the fashion industry (and therefore in a system catering to fashion photographers...). We speak of a particular designer's line of clothes, their (e.g.) fall collection, and a particular garment. Woops! garment! not clothing! I spend a LOT of time working and thinking about stuff like this. I need Maypole and Class::DBI::Loader etc. to not get in my way and make extra work. From dhudes@hudes.org Tue Feb 1 22:19:34 2005 From: dhudes@hudes.org (Dana Hudes) Date: Tue, 1 Feb 2005 17:19:34 -0500 (EST) Subject: [Maypole] Maypole::Plugin::Relationships and YAML In-Reply-To: <1107295442.20736.5.camel@localhost> References: <1107280874.19712.16.camel@localhost> <1107295442.20736.5.camel@localhost> Message-ID: On Tue, 1 Feb 2005, Sebastian Riedel wrote: > > > > > Use id as primary key... > > Maypole has id hardcoded at some points. (Not my decision) Unacceptable. Totally and completely unacceptable. I've got modelIdentifier, index, and all sorts of other things as primary key. It makes for clarity and makes for conformance with external standards and data models. I will take the time later this PM to start digging into this and come up with a fix which uses a variable name (and $_id to hold that is fine, its nobody's business what's done inside as long as it stays that way) From peterspeltz@yahoo.com Tue Feb 1 22:38:55 2005 From: peterspeltz@yahoo.com (Peter Speltz) Date: Tue, 1 Feb 2005 14:38:55 -0800 (PST) Subject: [Maypole] Maypole::Plugin::Relationships and YAML In-Reply-To: Message-ID: <20050201223855.697.qmail@web52106.mail.yahoo.com> --- Dana Hudes wrote: > > > On Tue, 1 Feb 2005, Dave Howorth wrote: > > > Sebastian Riedel wrote: > > > Plural table names are bad bad bad! > > > > They work perfectly with my loader :) > > That was one inconsequential factor that drove me to write it. > > I don't see your loader on CPAN... > > > > > Use id as primary key... > > > > > > This is better. > > > > Well, it's doubleplus conformant with the thought police maybe :) > > With Sebastian, and nobody else including major works on database theory, > ontology, semantics....you don't see Ullman writing schema with 'id'. > Nor Codd. I don't believe Tim Berners-Lee used that as an identifier > in his work on the Semantic Web. > Why is id recommended for all PK's? I'm guessing it makes something convenient but i haven't found what. CDBI users and some old database programmers from 8 years back are only people i've heard to say this. Database texts and articles i've read in past 2 years all say use something like "beer_id" and and if 'beer_id' is FK use 'beer_id' in foreign table too. > Individual objects may, or may not be, plural. Tables of rows certainly > make sense as plural names. Or worse yet, collection names may be another > word altogether. think about the plural and singular of clothing. > We have an article, not item, of clothing and we have a collection of > clothes....or a line of clothes is a term often used in the fashion > industry (and therefore in a system catering to fashion photographers...). > > We speak of a particular designer's line of clothes, their (e.g.) fall > collection, and a particular garment. I recall experts recommending singular names always. Also lowercase table adn column names because some dbms's are strange. My experience is in the english language singular is good for preventing typos cause it's easier to spell because plural endings vary. Lowercase is good cause you have less to think about. Someone should write up an article: "Database naming conventions and structure for a new Maypole, Class::DBI application ". I would but i dont have th eknow how. ===== pjs __________________________________ Do you Yahoo!? Yahoo! Mail - 250MB free storage. Do more. Manage less. http://info.mail.yahoo.com/mail_250 From peterspeltz@yahoo.com Tue Feb 1 22:41:34 2005 From: peterspeltz@yahoo.com (Peter Speltz) Date: Tue, 1 Feb 2005 14:41:34 -0800 (PST) Subject: [Maypole] Maypole::Plugin::Relationships and YAML In-Reply-To: Message-ID: <20050201224135.37218.qmail@web52104.mail.yahoo.com> --- Dana Hudes wrote: > > > On Tue, 1 Feb 2005, Sebastian Riedel wrote: > > > > > > > Use id as primary key... > > > > Maypole has id hardcoded at some points. (Not my decision) > This is only in the factory templates which are just examples anyway. I don't have a single PK named id and Maypole works fine. ===== pjs __________________________________ Do you Yahoo!? Yahoo! Mail - 250MB free storage. Do more. Manage less. http://info.mail.yahoo.com/mail_250 From Dave.Howorth@acm.org Tue Feb 1 23:16:21 2005 From: Dave.Howorth@acm.org (Dave Howorth) Date: Tue, 01 Feb 2005 23:16:21 +0000 Subject: [Maypole] Maypole::Plugin::Relationships and YAML In-Reply-To: References: <1107280874.19712.16.camel@localhost> <41FFDEF2.8060709@acm.org> Message-ID: <42000DC5.9010400@acm.org> Dana Hudes wrote: > I don't see your loader on CPAN... It's not in a state where I'd want to publish it on CPAN. It works for me at present but whether it's good for me, let alone for you is an entirely different question! You can find a snapshot here: The main real reason I wrote it was to get better control over all the text strings that Maypole causes to appear in web pages. Cheers, Dave -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.8.3 - Release Date: 31/01/05 From dhudes@hudes.org Tue Feb 1 23:17:21 2005 From: dhudes@hudes.org (Dana Hudes) Date: Tue, 1 Feb 2005 18:17:21 -0500 (EST) Subject: [Maypole] Maypole::Plugin::Relationships and YAML In-Reply-To: <20050201223855.697.qmail@web52106.mail.yahoo.com> References: <20050201223855.697.qmail@web52106.mail.yahoo.com> Message-ID: On Tue, 1 Feb 2005, Peter Speltz wrote: > > --- Dana Hudes wrote: > > > > > > > > > > > > Use id as primary key... > > > > With Sebastian, and nobody else including major works on database theory, > > ontology, semantics....you don't see Ullman writing schema with 'id'. > > Nor Codd. I don't believe Tim Berners-Lee used that as an identifier > > in his work on the Semantic Web. > > > > Why is id recommended for all PK's? I'm guessing it makes something convenient > but i haven't found what. CDBI users and some old database programmers from 8 > years back are only people i've heard to say this. I have a BS and MS in CS. My coursework and experience includes database theory circa 1989. I have here a copy of Jeffrey Ullman's _Principles of Database Knowledge-Base Systems, vol. 1_ from 1988. I am a former and hopefully future CS Professor; I nearly taught Database systems but as an adjunct I decided to pass on setting up and maintaining an Oracle server. Before punting, I did select the textbook based on what everyone else (Columbia, Cornell ,SUNY Stony Brook) was doing...and the textbook of choice was a current edition of Ullman (I see in my collection that somehow I didn't get a copy of that book...must've switched to Programming Languages and not bothered...I do have -quite- the collection of books on Programming Languages). I took my copy of Ullman's book from grad school off the shelf and flipped it open to the chapter on "Design Theory for Relational Databases". Its got a lot of stuff to say. One of them is avoiding redundancy. >From a documentation perspective, if I have a PK that I then use as a FK somewhere, gosh but it makes life so much clearer to use the same name. If the name is 'id', you're screwed. Oh sure you could use the name of the table whose PK you've got...but this is awkward, now you've got a column the same name as a table that is confusing. beer_id is ok. beerId is ok. beerIdentifier is more typical of XML. Probably want to avoid "beernumber" its not something you want to do arithmetic on yourself. I submit that what you have is properly called an index. Call it beerIndex (watch out, INDEX is a SQL keyword however you *can* have a column named "index" which is almost as bad as "id"). Oh, btw I am running a blog these days and my adventures in database, Maypole, Perl, YAML and knowledge representation as well as systems admin and whatever else comes to mind are recorded therein. http://www.hudes.org/blog From Dave.Howorth@acm.org Tue Feb 1 23:38:57 2005 From: Dave.Howorth@acm.org (Dave Howorth) Date: Tue, 01 Feb 2005 23:38:57 +0000 Subject: [Maypole] Maypole::Application still broken in 2.09? In-Reply-To: <41FFDF7A.3060706@morcor.com> References: <41FFDF7A.3060706@morcor.com> Message-ID: <42001311.5060103@acm.org> Matt Adams wrote: > Just wondering if Marcus R. or Simon F. (or anyone else) had any other > suggestions as to why Maypole::Application is still broken in 2.09. I suspect you'll have to wait for Simon for a definitive answer. > Maybe it's not... maybe it's me? > > Here's the problem (same as before -- just slightly edited). > > I recently upgraded to Maypole 2.09 and discovered that it is not > compatible with the Maypole app I have been using. I'm hoping that > those of you who are more familiar with the Maypole-innards will be able > to shed some light on why I'm having the problems I am. > > It would appear that the neat stuff in Maypole::Application 2.09 is > still causing problems for my poor Maypole-powered application. > > If I downgrade to Maypole::Application 2.07 everything works fine. > > I don't think my Maypole app is all that odd. Here's how it begins: > > BEGIN { > package MyApp; > use MyApp::Constants; > $ENV{MAYPOLE_CONFIG} = BINPATH . '/MyApp.yaml'; > } > > package MyApp; > > use Maypole::Application qw( > -Debug > Config::YAML > Authentication::Abstract > -Setup > ); > > But unfortunately this doesn't work out too well with > Maypole::Application 2.09 which still gives me the same error as in 2.08: > > MyApp...Debugging enabled > MyApp...Loaded plugin: Maypole::Plugin::Authentication::Abstract > MyApp...Loaded plugin: Maypole::Plugin::Config::YAML This looks a little odd. One of the things fixed in 2.09 was to make sure that the plugins really are loaded in the order they are declared (this wasn't the case in some previous releases). Now these messages aren't in the same order as in your use statement. So are you sure these messages are really being output by 2.09? If so, they seem to be showing a 2.09 bug. A complete simple test case would be very helpful. > MyApp...No DSN set in config > [error] Can't locate object method "new" via package > "Class::DBI::Loader::" (perhaps you forgot to load > "Class::DBI::Loader::"?) at /.../lib/Class/DBI/Loader.pm line 77. I guess your config might be relevant to understanding what's going on here? (Not by me, I don't use either the YAML or CDBI-Loader :) Cheers, Dave > BEGIN failed--compilation aborted at /.../MyApp.pm line 36. > Compilation failed in require at (eval 10) line 3. > [error] Can't call method "_table2class" on an undefined value at > /.../lib/Maypole/Model/CDBI.pm line 250. > > Can someone give me some pointers as to a) how to fix my app so that it > is compliant with Maypole::Application 2.09 and/or b) what exactly was > the purpose of the neat code in Maypole::Application 2.09? > > FWIW, I'm using a PERL5LIB path modified by my Apache configuration. > > > Thanks! > > Matt -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.8.3 - Release Date: 31/01/05 From tony@kasei.com Wed Feb 2 01:08:12 2005 From: tony@kasei.com (Tony Bowden) Date: Wed, 2 Feb 2005 01:08:12 +0000 Subject: [Maypole] Maypole::Plugin::Relationships and YAML In-Reply-To: References: <1107280874.19712.16.camel@localhost> <1107295442.20736.5.camel@localhost> Message-ID: <20050202010812.GA5397@soto.kasei.com> On Tue, Feb 01, 2005 at 05:19:34PM -0500, Dana Hudes wrote: > > Maypole has id hardcoded at some points. (Not my decision) > Unacceptable. Totally and completely unacceptable. Class::DBI always aliases ->id() to be your primary key, no matter what you've actually named it. It makes a lot of things a lot simpler. > I've got modelIdentifier, index, and all sorts of other things as primary > key. It makes for clarity and makes for conformance with external > standards and data models. This shouldn't be a problem. Tony From tony@kasei.com Wed Feb 2 01:12:48 2005 From: tony@kasei.com (Tony Bowden) Date: Wed, 2 Feb 2005 01:12:48 +0000 Subject: [Maypole] Maypole::Plugin::Relationships and YAML In-Reply-To: References: <20050201223855.697.qmail@web52106.mail.yahoo.com> Message-ID: <20050202011248.GA5503@soto.kasei.com> On Tue, Feb 01, 2005 at 06:17:21PM -0500, Dana Hudes wrote: > From a documentation perspective, if I have a PK that I then use as a FK > somewhere, gosh but it makes life so much clearer to use the same name. Why? I don't buy this one. I find it much clearer to make FKs the name of the table to which they refer. I also find it much simpler to just make the PK of every table be called 'id'. But I'm also a huge believer in the principle that Primary Keys should always be meaningless. Tony From dhudes@hudes.org Wed Feb 2 01:17:34 2005 From: dhudes@hudes.org (Dana Hudes) Date: Tue, 1 Feb 2005 20:17:34 -0500 (EST) Subject: [Maypole] Maypole::Plugin::Relationships and YAML In-Reply-To: <20050202010812.GA5397@soto.kasei.com> References: <1107280874.19712.16.camel@localhost> <1107295442.20736.5.camel@localhost> <20050202010812.GA5397@soto.kasei.com> Message-ID: On Wed, 2 Feb 2005, Tony Bowden wrote: > Class::DBI always aliases ->id() to be your primary key, no matter what > you've actually named it. Even if its a multi-column primary key its still called id? From dhudes@hudes.org Wed Feb 2 01:25:23 2005 From: dhudes@hudes.org (Dana Hudes) Date: Tue, 1 Feb 2005 20:25:23 -0500 (EST) Subject: [Maypole] Maypole::Plugin::Relationships and YAML In-Reply-To: <20050202011248.GA5503@soto.kasei.com> References: <20050201223855.697.qmail@web52106.mail.yahoo.com> <20050202011248.GA5503@soto.kasei.com> Message-ID: On Wed, 2 Feb 2005, Tony Bowden wrote: > On Tue, Feb 01, 2005 at 06:17:21PM -0500, Dana Hudes wrote: > > From a documentation perspective, if I have a PK that I then use as a FK > > somewhere, gosh but it makes life so much clearer to use the same name. > > Why? I don't buy this one. If you name the PK clearly and distinctively you can keep the name > > I find it much clearer to make FKs the name of the table to which they > refer. If the PK name includes the table name > > I also find it much simpler to just make the PK of every table be called > 'id'. > > But I'm also a huge believer in the principle that Primary Keys should > always be meaningless. But they're not meaningless! Sure, sometimes -- even often -- its suitable to have a pure number from a sequence. I've had systems in the past where part number was coded. There could be a sequence as -part- of the pn but it had other fields which meant something. In particular, this was a manufacturer of cable trays. Parts could be the tray, a bolt, a strap or other kinds of hardware. Trays had a number, bolts a number and so on. Then you have the particular kind of tray or bolt (perhaps coated with something, and you would then have particular kinds of coating with their own particular meaning including uncoated as a kind of coating). Length of part could be directly represented in the number as well. From dhudes@hudes.org Wed Feb 2 02:20:35 2005 From: dhudes@hudes.org (Dana Hudes) Date: Tue, 1 Feb 2005 21:20:35 -0500 (EST) Subject: [Maypole] Can't locate object method "new" via package "Class::DBI::Loader::" Message-ID: Testing with Maypole CLI as well as Apache. CDBIL v0.12 . The difference in the errors is that in apache it complains its a bad DSN. This is all on Linux with Perl 5.8.1 #!/usr/bin/perl package photogallery; use warnings; BEGIN { use Apache::Reload; use vars qw (%ENV @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); $ENV{MAYPOLE_CONFIG} = '/home/dhudes/photogallery.yaml'; $ENV{MAYPOLE_TEMPLATES} = '/srv/www/htdocs/sites/sitedb/factory'; use CGI::Carp qw(fatalsToBrowser); } use CGI::Carp qw(fatalsToBrowser); use Maypole::Constants; use Maypole::Application qw(Config::YAML Loader Untaint -Setup); 1; =============== photogallery.yaml: --- #YAML:1.0 dsn: 'dbi:Pg:dbname=photogalleries;host=127.0.0.1' user: dhudes pass: Oner0us492 uri_base: 'http://sitedb.advancedsolutions.biz/dbgui' template_root: '/srv/www/htdocs/sites/sitedb/templates' rows_per_page: 10 untaint_columns: keywords: html: - label websites: html: - site_name - subjects_template - gallery_template - css Filenames: - doc_root - secured_root - galleries_dir - gallery_thumbs_path - subject_thumbs_path - gallery_list - subject_list url: - secured_url galleries: integer: - quantity upload: - sample_picture boolean: - released - video date: - publicationDate - embargoDate html: - title - description ============ result: dhudes@screamer:~> perl -w -MMaypole::CLI=photogallery Content-type: text/html

Software error:

Couldn't require photogallery - Can't coerce array into hash at 
/usr/lib/perl5/site_perl/5.8.1/Maypole/Plugin/Untaint.pm line 65.
BEGIN failed--compilation aborted at photogallery.pm line 26.
Compilation failed in require at 
/usr/lib/perl5/site_perl/5.8.1/Maypole/CLI.pm line 22.
BEGIN failed--compilation aborted.

For help, please send mail to this site's webmaster, giving this error message and the time and date of the error.

[Tue Feb 1 21:19:54 2005] -: Couldn't require photogallery - Can't coerce array into hash at /usr/lib/perl5/site_perl/5.8.1/Maypole/Plugin/Untaint.pm line 65. [Tue Feb 1 21:19:54 2005] -: BEGIN failed--compilation aborted at photogallery.pm line 26. [Tue Feb 1 21:19:54 2005] -: Compilation failed in require at /usr/lib/perl5/site_perl/5.8.1/Maypole/CLI.pm line 22. [Tue Feb 1 21:19:54 2005] -: BEGIN failed--compilation aborted. From dhudes@hudes.org Wed Feb 2 03:48:19 2005 From: dhudes@hudes.org (Dana Hudes) Date: Tue, 1 Feb 2005 22:48:19 -0500 (EST) Subject: [Maypole] further exploration of the error I posted Message-ID: so I have this short program to sanity-check the YAML: use YAML qw(Dump Load LoadFile); use Data::Dumper; print Dumper(LoadFile("photogallery.yaml")); print "\n"; print Dump(LoadFile("photogallery.yaml")); the Dumper output looks quite reasonable on first glance. However, on closer examination and comparison with the docs of Maypole::Plugin::Untaint I see some slight difference at the top level. I also see a sequence difference: in the perldoc for Plugin::Untaint, it shows setup invoked AFTER untaint. This makes little sense, how can you establish constraints in CDBI if you haven't built the tables yet! You can't very well build tables w/o the DSN. The YAML shows the dsn section first, but the perl for that version omits Loader. Removing Loader from my code doesn't change the error message. The difference I see in the data structure is that in the POD for Maypole::Plugin::Untaint the perl version is an array of hashes (since arguments to a method are in list context): MyApp->config->untaint_columns( table1 => { html => [qw(name email)] }, table2 => { printable => [qw(lalala)] } ); However the resultant data structure of YAML is in hash context: 'untaint_columns' => { 'websites' => { 'html' => [ 'site_name', 'subjects_template', 'gallery_template', 'css' ], 'Filenames' => [ 'doc_root', 'secured_root', 'galleries_dir', 'gallery_thumbs_path', 'subject_thumbs_path', 'gallery_list', 'subject_list' ], 'url' => [ 'secured_url' ] }, etc. } Now, I found another reason I really don't like YAML: Use of of white space to indicate hierarchy. The Filenames was a few spaces left of its proper position and that made a problem. Say what you will, you wouldn't have such a problem with XML. From dhudes@hudes.org Wed Feb 2 04:45:21 2005 From: dhudes@hudes.org (Dana Hudes) Date: Tue, 1 Feb 2005 23:45:21 -0500 (EST) Subject: [Maypole] plurality in column names Message-ID: We've bandied this about. I've come up with a definitive argument against messing with the plurality of column names. When we record a woman's measurements, we do not say "hip" measurement, we say "hips" because the measurement isn't around one hip its around two. In the trickier sense, is bust singular or plural? Of course, its really shorthand for "bustline" but nobody says or writes "bustline", we write "bust" (so, too, waist though you at least will see references to waistline in "slimming" context). I continue to build my fashion system and bang my head against well-meaning assumptions that break sensible data models. From tony@kasei.com Wed Feb 2 07:56:44 2005 From: tony@kasei.com (Tony Bowden) Date: Wed, 2 Feb 2005 07:56:44 +0000 Subject: [Maypole] Maypole::Plugin::Relationships and YAML In-Reply-To: References: <20050201223855.697.qmail@web52106.mail.yahoo.com> <20050202011248.GA5503@soto.kasei.com> Message-ID: <20050202075644.GB5503@soto.kasei.com> On Tue, Feb 01, 2005 at 08:25:23PM -0500, Dana Hudes wrote: > > > From a documentation perspective, if I have a PK that I then use as a FK > > > somewhere, gosh but it makes life so much clearer to use the same name. > > Why? I don't buy this one. > If you name the PK clearly and distinctively you can keep the name But why would you want to in the first place? This is a technical answer. I'm looking for a philosophical one. You say it makes things clearer. I say it's clearer to just use the table name. > > I find it much clearer to make FKs the name of the table to which they > > refer. > If the PK name includes the table name Why bother? > > But I'm also a huge believer in the principle that Primary Keys should > > always be meaningless. > But they're not meaningless! Sure, sometimes -- even often -- its > suitable to have a pure number from a sequence. I've had systems in the > past where part number was coded. There could be a sequence as -part- of > the pn but it had other fields which meant something. In particular, this > was a manufacturer of cable trays. Parts could be the tray, a bolt, a > strap or other kinds of hardware. Trays had a number, bolts a number and > so on. Then you have the particular kind of tray or bolt (perhaps coated > with something, and you would then have particular kinds of coating with > their own particular meaning including uncoated as a kind of coating). > Length of part could be directly represented in the number as well. This is bad bad bad bad bad. PK's should *always* be meaningless. Adding data in about things like part numbers, tray numbers etc leads to a world of pain when supposedly invariable data changes, as, invariably, happens. Tony From Aaron Trevena Wed Feb 2 09:51:04 2005 From: Aaron Trevena (Aaron Trevena) Date: Wed, 2 Feb 2005 09:51:04 +0000 Subject: [Maypole] Maypole::Plugin::Relationships and YAML In-Reply-To: <20050202075644.GB5503@soto.kasei.com> References: <20050201223855.697.qmail@web52106.mail.yahoo.com> <20050202011248.GA5503@soto.kasei.com> <20050202075644.GB5503@soto.kasei.com> Message-ID: On Wed, 2 Feb 2005 07:56:44 +0000, Tony Bowden wrote: > PK's should *always* be meaningless. not *meaningless*, they mean a unique identifier for whatever they are PK for. But you are right they should not have a meaning beyond that. > Adding data in about things like part numbers, tray numbers etc leads to > a world of pain when supposedly invariable data changes, as, invariably, > happens. Amen brother. I have just been dealing with a company via a webservices and they helpfully provided stock_codes for each item. Yes, that stock code was user defined.... and guess what before we even did a weeks development those values were changing and dissappearing. never ever ever re-use something else as an identifier. Either you don't need an identifier and can use a compound key of non-unique fields that is unique to that record or you need an identifier that is reliable, unchanging and unique. I can't believe I had to ask these people for real unique id's, explaining why it was important. A. From dhoworth@mrc-lmb.cam.ac.uk Wed Feb 2 15:43:38 2005 From: dhoworth@mrc-lmb.cam.ac.uk (Dave Howorth) Date: Wed, 02 Feb 2005 15:43:38 +0000 Subject: [Maypole] Data::FormValidator status Message-ID: <4200F52A.6060304@mrc-lmb.cam.ac.uk> I thought I'd let anybody who's interested know how far I've got. Basically, it runs! I used Maypole code from Jesse Sheidlower, and from Cees Hek and Perrin Harkins for the error handling. Thanks to them all. I've patched most of it into Maypole::Model::CDBI for now. I have this at the top: use Data::FormValidator; Maypole::Config->mk_accessors qw(dfv_profiles); Then here's my do_edit action: sub do_edit : Exported { my ( $self, $r ) = @_; my $profile = $r->config->dfv_profiles->{$r->model_class} || $self->dfv_profile; my $params = $r->params; my $results = Data::FormValidator->check($params, $profile); # could warn about unknown fields here if debugging if ($results->has_invalid or $results->has_missing) { my $dfv_msgs = $results->msgs({ format => '%s', invalid_seperator => "\cZ", # Yes, you have to misspell separator!! }); my $errors; # Template variable for error hash foreach my $missing_field ($results->missing) { $errors->{$missing_field}->{missing} = 'Missing'; } my $invalid = $results->invalid; foreach my $invalid_field (keys %$invalid) { my @msg_text = split "\cZ", $dfv_msgs->{$invalid_field}; foreach my $failed_constraint (@{$invalid->{$invalid_field}}) { $errors->{$invalid_field}->{$failed_constraint} = shift @msg_text ; } } # Set up to redisplay the completed form with the errors $r->template_args->{cgi_params} = $params; $r->template_args->{errors} = $errors; $r->template('edit'); return; } # If we got this far, the results are OK # my $valid_params = $results->valid; my ($obj) = @{ $r->objects || [] }; # get first object if ($obj) { # editing an existing object $obj->set(%$valid_params); $obj->update; } else { # creating a new object $obj = $self->create($valid_params); } $r->template('view'); $r->objects( $obj ? [$obj] : []); } The point of all the messing with errors is to allow all the error text to be kept in the templates and not in the code, whilst still allowing plausible defaults. Here's an extract from addnew.tt to give a flavour. This is not a finished template, it just shows both possibilities. coldata.singular is my replacement for colnames.$col. [%- IF errors.$col %] [%- FOREACH err = errors.$col ; IF err.key == 'missing' -%] Please provide a value for [% coldata.singular %]
[%- ELSE ; err.key ; ' ' ; err.value ; '
' ; END ; END -%]
[%- END ; I've played with two methods of setting profiles. I'm still undecided about their merits so the code supports both. Either the profiles can be stored in the config like this: # Data::FormValidator configuration use Regexp::Common qw/RE_num_int RE_URI_HTTP/; my $printable = qr/^[\040-\377\r\n\t]+$/; # surely there must be a d-fv 'printable' constraint!!? my $profiles = BeerDB->config->dfv_profiles({ 'BeerDB::Pub' => { required => [qw/name/], optional => [qw/notes url/], constraints => { name => $printable, notes => $printable, url => [ { name => 'format', constraint => 'RE_URI_HTTP' }, ] }, }, 'BeerDB::Style' => { required => [qw/name/], optional => [qw/notes/], constraints => { name => $printable, notes => $printable, }, }, ... etc ... }); My other method of loading profiles is via a method in each model sublass. This has the merit that everything is in the model, which some people see as a 'good thing'. For example: package QD1::Coord; # for coords table sub dfv_profile { return { required => [qw/name bio_database_id/], missing_optional_valid => 1, constraints => { id => 'RE_num_int', name => qr/^[\040-\377\r\n\t]+$/, bio_database_id => 'RE_num_int', } } } I've only tested D-FV a very little but it seems to work so far. Its power is definitely in the profiles. But so is the complexity and I'm still at the bottom of the learning curve. I haven't worked out how to make them most convenient and I haven't yet found any kind of dictionary or cookbook of practical constraints and programming idioms to achieve particular results. But it's early days. Cheers, Dave -- Dave Howorth MRC Centre for Protein Engineering Hills Road, Cambridge, CB2 2QH 01223 252960 From dhudes@hudes.org Wed Feb 2 16:00:29 2005 From: dhudes@hudes.org (Dana Hudes) Date: Wed, 2 Feb 2005 11:00:29 -0500 (EST) Subject: [Maypole] On primary keys In-Reply-To: <20050202075644.GB5503@soto.kasei.com> References: <20050201223855.697.qmail@web52106.mail.yahoo.com> <20050202011248.GA5503@soto.kasei.com> <20050202075644.GB5503@soto.kasei.com> Message-ID: On Wed, 2 Feb 2005, Tony Bowden wrote: > On Tue, Feb 01, 2005 at 08:25:23PM -0500, Dana Hudes wrote: > > > > From a documentation perspective, if I have a PK that I then use > > > > as a FK somewhere, gosh but it makes life so much clearer to use > > > > the same name. > > > Why? I don't buy this one. The name for the value remains consistent. The question you have to ask yourself is this a new thing, i.e. have you done or will you do some transformation, or is it the same thing? If its the same thing, why are you now making me wonder where this new thing came from? > > If you name the PK clearly and distinctively you can keep the name > > But why would you want to in the first place? Clarity. Hmm. Have you read Frederick Brooks _The Mythical Man Month_? I don't have a copy (I had read a library copy back in grad school). I feel this was addressed in an early essay in Yourdon's collection _Writings of the Revolution_ but I can't find my copy at the moment. I -have- got my copy of Blaha, Michael and William Premerlani _Object-Oriented Modeling and Design for Database Applications_ and they reinforce some of what I've said: from pp24-25 section 2.2.6 Qualified Associations: "A qualified association is an association in which th eobjects in a "many" role are partially or fully disambiguated by an attribute called the qualifier." > This is a technical > answer. I'm looking for a philosophical one. You say it makes things > clearer. I say it's clearer to just use the table name. Take a bank account. You CAN just call its key "accountNumber". Would it not be clearer to say which bank ? Or which institution? Consider some organization like Citigroup. They've got bank qua bank,Citibank, they've got bank qua investment house (Smith Barney) and they've got an insurance company (Travelers). They've also got Citicards (Diners Club , VISA/MC, and then they do card processing for private labels like AT&T Universal card). Each of these organizations gets back-office service from CGTI, the Citigroup Technology Infrastructure organization. A data modeler, for example, will likely bounce around amongst projects for all of these organizations (I certainly did as a LAN engineer!). When you look at a piece of code or a UML diagram, what do you want to see? accountnumber or CitiCheckingAccountNumber ? > > > > I find it much clearer to make FKs the name of the table to which they > > > refer. > > If the PK name includes the table name > > Why bother? disambiguation > This is bad bad bad bad bad. > > PK's should *always* be meaningless. > > Adding data in about things like part numbers, tray numbers etc leads to > a world of pain when supposedly invariable data changes, as, invariably, > happens. If you mean that its one column you may well have a point however if you have a MCPK composed of the column for part-type, coating and so on then where's the problem? If you change the coating you have a new part! Oh sure maybe performance is better on a SERIAL rather than a MCPK of 5 or 6 columns -- for insertion of a new part, which is done relatively rarely. If you are assembling a PO, however, you already have all the columns loaded. Furthermore if you are allowed to just use a pure SERIAL for the PK for part, then parts can change without changing the part #. Consider that I have all sorts of object containers lying around using this! Purchase Order, Bill of Lading, Invoice etc. . If you're allowed to go changing the coating you change the meaning of what was sold to someone! From simon@simon-cozens.org Wed Feb 2 16:10:40 2005 From: simon@simon-cozens.org (Simon Cozens) Date: Wed, 2 Feb 2005 16:10:40 +0000 Subject: [Maypole] On primary keys In-Reply-To: References: <20050201223855.697.qmail@web52106.mail.yahoo.com> <20050202011248.GA5503@soto.kasei.com> <20050202075644.GB5503@soto.kasei.com> Message-ID: <20050202161040.GA9568@alibi.simon-cozens.org> Maybe this would be better on cdbi-talk, or perhaps on some abstracted database theory mailing list somewhere. -- Premature optimization is the root of all evil. -- D.E. Knuth From sethg@ropine.com Wed Feb 2 16:13:19 2005 From: sethg@ropine.com (Seth Gordon) Date: Wed, 02 Feb 2005 11:13:19 -0500 Subject: [Maypole] Maypole::Plugin::Relationships and YAML Message-ID: <4200FC1F.4020105@ropine.com> I have a Maypole-based, not-quite-finished interface to a library database that I compiled a few years ago (http://dynamic.ropine.com/library/). The database schema does not have Maypole-friendly field names: e.g., the primary key of the "authors" table is "author_id", not "id". I handled this by telling Class::DBI what the primary key field was: "__PACKAGE__->columns(id => 'title_id');". I don't remember all the other deviations and workarounds--it's been a few months since I last looked at this code--but I remember (a) I made it work; (b) working around the naming convention was a bit more of a nuisance than I would have liked. Obviously, I could have renamed all the objects in my database to conform to Maypole's expectations, and made my life easier. However, in my experience, the person writing the front end of a database-backed Web application often does not have any control over the schema used for the database. Given that fact, this argument over how tables and fields *should* be named seems kind of beside the point. -- Reporter: "Why do you think bin Laden has not been caught?" President Bush: "Because he's hiding." // seth gordon // sethg@ropine.com // http://dynamic.ropine.com/yo/ // From johanl@DarSerMan.com Wed Feb 2 16:23:33 2005 From: johanl@DarSerMan.com (Johan Lindstrom) Date: Wed, 02 Feb 2005 17:23:33 +0100 Subject: [Maypole] On primary keys In-Reply-To: References: <20050201223855.697.qmail@web52106.mail.yahoo.com> <20050202011248.GA5503@soto.kasei.com> <20050202075644.GB5503@soto.kasei.com> Message-ID: <6.1.1.1.0.20050202171613.04b25f10@127.0.0.1> At 17:00 2005-02-02, Dana Hudes wrote: >If you're allowed to go changing the coating you change the meaning of >what was sold to someone! And this is exactly what happens in the real world. Things change. The fact that someone emphatically said that there can only be one coating per frobnitz a year ago doesn't prevent someone else to change that (for good or bad reasons) today. Having said that, we all know that there are databases out there which _have_ tables with composite primary keys, and IMHO it would be nice if CDBI could deal with that also. Other than that, I feel this has little to do with Maypole/CDBI. /J -------- ------ ---- --- -- -- -- - - - - - Johan Lindström Sourcerer @ Boss Casinos johanl AT DarSerMan.com Latest bookmark: "TCP Connection Passing" http://tcpcp.sourceforge.net/ dmoz: /Computers/Programming/Languages/JavaScript/ 12 From dhudes@hudes.org Wed Feb 2 16:27:03 2005 From: dhudes@hudes.org (Dana Hudes) Date: Wed, 2 Feb 2005 11:27:03 -0500 (EST) Subject: [Maypole] On primary keys In-Reply-To: <20050202161040.GA9568@alibi.simon-cozens.org> References: <20050201223855.697.qmail@web52106.mail.yahoo.com> <20050202011248.GA5503@soto.kasei.com> <20050202075644.GB5503@soto.kasei.com> <20050202161040.GA9568@alibi.simon-cozens.org> Message-ID: On Wed, 2 Feb 2005, Simon Cozens wrote: > Maybe this would be better on cdbi-talk, or perhaps on some abstracted > database theory mailing list somewhere. Except that it comes back to bite one in the ass with Maypole because of the automatic pluralisation which one cannot turn off. I've never seen a program mess with variable names before. hips becomes hip and its not the same thing! I spend a GREAT deal of time working on the names of things. To have a program that's supposed to be helping me turn around and decide for itself that I always mean the singular even if I said plural is madness! Maypole does a lot of nice things in theory (mind, I have yet to get the thing to work) but frankly I'm thinking my first contribution is to rip out that "feature" or at least make it optional. This is like the stuff in Class::Accessor that lower-cased everything SILENTLY (at least you documented the plural->singular change occurring)! Broke all sorts of stuff mysteriously. From j.chladek@wirtschaftsblatt.at Wed Feb 2 16:35:42 2005 From: j.chladek@wirtschaftsblatt.at (Josef Chladek) Date: Wed, 2 Feb 2005 17:35:42 +0100 Subject: [Maypole] mixing of tables in create In-Reply-To: <20050201170943.33302.qmail@web52105.mail.yahoo.com> References: <20050201170943.33302.qmail@web52105.mail.yahoo.com> Message-ID: <7B20322B-7538-11D9-97A4-000A9575B1A4@wirtschaftsblatt.at> Am 01.02.2005 um 18:09 schrieb Peter Speltz: > I was thinking override create_from_cgi. you should just be able to > put a sub > in your base model class (or just class you want the override) called > create_from_cgi. ok, so i did, this opens a can of worms for me: sub create_from_cgi { my $class = shift; my $article = $class->SUPER::create_from_cgi(@_); my $textblock = Article::Textblock->create_from_cgi(@_); $textblock->article($article->id); $textblock->update; $article; } with this i was able to insert the title, lead along with one block in the two tables. 1) i hardcoded the formfield in the addnew template, how could this be done automatically? Article::Article->columns(All => qw/title lead block/) is not the way, it of course tries to retrieve the value of block in the article table 2) related to this, what has to be done in the edit template 3) what about multiple blocks? how should the formfields be named (block -> i get an array), block1, block2 ... -> this breaks the automatic insertion) can someone point me in the right direction please? thanks josef From perrin@elem.com Wed Feb 2 16:39:51 2005 From: perrin@elem.com (Perrin Harkins) Date: Wed, 02 Feb 2005 11:39:51 -0500 Subject: [Maypole] On primary keys In-Reply-To: <6.1.1.1.0.20050202171613.04b25f10@127.0.0.1> References: <20050201223855.697.qmail@web52106.mail.yahoo.com> <20050202011248.GA5503@soto.kasei.com> <20050202075644.GB5503@soto.kasei.com> <6.1.1.1.0.20050202171613.04b25f10@127.0.0.1> Message-ID: <1107362391.5984.48.camel@localhost.localdomain> On Wed, 2005-02-02 at 17:23 +0100, Johan Lindstrom wrote: > Having said that, we all know that there are databases out there which > _have_ tables with composite primary keys, and IMHO it would be nice if > CDBI could deal with that also. Doesn't CDBI deal with that already? Or are you talking about foreign keys? - Perrin From johanl@DarSerMan.com Wed Feb 2 16:54:32 2005 From: johanl@DarSerMan.com (Johan Lindstrom) Date: Wed, 02 Feb 2005 17:54:32 +0100 Subject: [Maypole] On primary keys In-Reply-To: <1107362391.5984.48.camel@localhost.localdomain> References: <20050201223855.697.qmail@web52106.mail.yahoo.com> <20050202011248.GA5503@soto.kasei.com> <20050202075644.GB5503@soto.kasei.com> <6.1.1.1.0.20050202171613.04b25f10@127.0.0.1> <1107362391.5984.48.camel@localhost.localdomain> Message-ID: <6.1.1.1.0.20050202174616.04cc0d98@127.0.0.1> At 17:39 2005-02-02, Perrin Harkins wrote: > > Having said that, we all know that there are databases out there which > > _have_ tables with composite primary keys, and IMHO it would be nice if > > CDBI could deal with that also. > >Doesn't CDBI deal with that already? Or are you talking about foreign >keys? Sorry, I had no intention of FUDing. Yes that's what I'm referring to (that's part of what PKs are used for). I'm sure you have a much better view of this than me, but my impression from reading the docs is that it's difficult to do. I haven't been bitten by it myself. Um... yet :) /J -------- ------ ---- --- -- -- -- - - - - - Johan Lindström Sourcerer @ Boss Casinos johanl AT DarSerMan.com Latest bookmark: "TCP Connection Passing" http://tcpcp.sourceforge.net/ dmoz: /Computers/Programming/Languages/JavaScript/ 12 From tony@kasei.com Wed Feb 2 17:48:05 2005 From: tony@kasei.com (Tony Bowden) Date: Wed, 2 Feb 2005 17:48:05 +0000 Subject: [Maypole] Maypole::Plugin::Relationships and YAML In-Reply-To: <4200FC1F.4020105@ropine.com> References: <4200FC1F.4020105@ropine.com> Message-ID: <20050202174805.GA20077@soto.kasei.com> On Wed, Feb 02, 2005 at 11:13:19AM -0500, Seth Gordon wrote: > The database schema does not have Maypole-friendly field names: e.g., > the primary key of the "authors" table is "author_id", not "id". I think I'm missing something here. There seems to be this idea that Maypole (and / or Class::DBI) wants the primary key to be called 'id'. Is this actually true? It certainly isn't true for Class::DBI. > in my experience, the person writing the front end of a database-backed > Web application often does not have any control over the schema used for > the database. Given that fact, this argument over how tables and fields > *should* be named seems kind of beside the point. Maybe I'm missing the point here, but I thought one of the goals of Maypole was that you can have whatever schema you want, but, if you have things set up in a certain way, you can skip some of the setup stages, as Maypole will guess what you want. Other than this guessing, which you can override if it gets it wrong, Maypole certainly shouldn't care about your schema. But maybe I misunderstand; or maybe something has changed. But it seems to me that because there's a lot of discussion about abstract theory on what the /best/ way of doing something is, that people are picking up that that's the /only/ way Maypole can work. Or something. Tony From tony@kasei.com Wed Feb 2 17:49:33 2005 From: tony@kasei.com (Tony Bowden) Date: Wed, 2 Feb 2005 17:49:33 +0000 Subject: [Maypole] Data::FormValidator status In-Reply-To: <4200F52A.6060304@mrc-lmb.cam.ac.uk> References: <4200F52A.6060304@mrc-lmb.cam.ac.uk> Message-ID: <20050202174933.GB20077@soto.kasei.com> On Wed, Feb 02, 2005 at 03:43:38PM +0000, Dave Howorth wrote: > I used Maypole code from Jesse Sheidlower, and from Cees Hek and Perrin > Harkins for the error handling. Thanks to them all. Looks good. Are you planning on taking this out of Maypole into a generic "update Class::DBI objects using Data::FormValidator" that can go to CPAN just like Class::DBI::FromCGI? Tony From sri@oook.de Wed Feb 2 17:49:25 2005 From: sri@oook.de (Sebastian Riedel) Date: Wed, 02 Feb 2005 18:49:25 +0100 Subject: [Maypole] Maypole::Plugin::Relationships and YAML In-Reply-To: <20050202174805.GA20077@soto.kasei.com> References: <4200FC1F.4020105@ropine.com> <20050202174805.GA20077@soto.kasei.com> Message-ID: <1107366565.23083.1.camel@localhost> Tony Bowden: > I think I'm missing something here. There seems to be this idea that > Maypole (and / or Class::DBI) wants the primary key to be called 'id'. > Is this actually true? It certainly isn't true for Class::DBI. > Seems only Maypole's factory templates expect id. -- sebastian From sri@oook.de Wed Feb 2 17:51:22 2005 From: sri@oook.de (Sebastian Riedel) Date: Wed, 02 Feb 2005 18:51:22 +0100 Subject: [Maypole] Data::FormValidator status In-Reply-To: <20050202174933.GB20077@soto.kasei.com> References: <4200F52A.6060304@mrc-lmb.cam.ac.uk> <20050202174933.GB20077@soto.kasei.com> Message-ID: <1107366682.23083.4.camel@localhost> Tony Bowden: > Are you planning on taking this out of Maypole into a generic "update > Class::DBI objects using Data::FormValidator" that can go to CPAN just > like Class::DBI::FromCGI? This could also become a patch for Class::DBI::FromForm. ;) -- sebastian From dhudes@hudes.org Wed Feb 2 18:04:08 2005 From: dhudes@hudes.org (Dana Hudes) Date: Wed, 2 Feb 2005 13:04:08 -0500 (EST) Subject: [Maypole] Maypole::Plugin::Relationships and YAML In-Reply-To: <1107366565.23083.1.camel@localhost> References: <4200FC1F.4020105@ropine.com> <20050202174805.GA20077@soto.kasei.com> <1107366565.23083.1.camel@localhost> Message-ID: On Wed, 2 Feb 2005, Sebastian Riedel wrote: > Tony Bowden: > > I think I'm missing something here. There seems to be this idea that > > Maypole (and / or Class::DBI) wants the primary key to be called 'id'. > > Is this actually true? It certainly isn't true for Class::DBI. > > > > Seems only Maypole's factory templates expect id. > As Tony points out, CDBI makes an alias called 'id' -- in CDBI, not SQL it doesn't touch your schema -- for your PK no matter what you call it. So long as Maypole doesn't go generating SQL on its own, relying instead on CDBI, this should not pose a conflict. From peterspeltz@yahoo.com Wed Feb 2 18:34:44 2005 From: peterspeltz@yahoo.com (Peter Speltz) Date: Wed, 2 Feb 2005 10:34:44 -0800 (PST) Subject: [Maypole] On primary keys In-Reply-To: Message-ID: <20050202183444.85362.qmail@web52107.mail.yahoo.com> --- Dana Hudes wrote: > Except that it comes back to bite one in the ass with Maypole because > of the automatic pluralisation which one cannot turn off. > I've never seen a program mess with variable names before. > hips becomes hip > and its not the same thing! > I spend a GREAT deal of time working on the names of things. > To have a program that's supposed to be helping me turn around > and decide for itself that I always mean the singular even if I said > What are you talking about here? The templates that maypole ships with? Those are just examples as has been said several times on list. Simon even regrets shipping them because of the misconceptions they cause but they are helpful to those of us learning TT and html. You can throw em away and make your own. If you don't like the template args the View makes you can set them yourself or make your own View class. Similarly if you don't like CDBI you can make your own Model class. i have no idea where Maypole messes with variable names. ===== pjs __________________________________ Do you Yahoo!? Take Yahoo! Mail with you! Get it on your mobile phone. http://mobile.yahoo.com/maildemo From sf@flacks.net Wed Feb 2 19:22:15 2005 From: sf@flacks.net (Simon Flack) Date: Wed, 02 Feb 2005 19:22:15 +0000 Subject: [Maypole] Maypole::Application still broken in 2.09? In-Reply-To: <42001311.5060103@acm.org> References: <41FFDF7A.3060706@morcor.com> <42001311.5060103@acm.org> Message-ID: <42012867.8040901@flacks.net> Dave Howorth wrote: > Matt Adams wrote: > >> Just wondering if Marcus R. or Simon F. (or anyone else) had any other >> suggestions as to why Maypole::Application is still broken in 2.09. > > > I suspect you'll have to wait for Simon for a definitive answer. > >> Maybe it's not... maybe it's me? >> >> Here's the problem (same as before -- just slightly edited). >> >> I recently upgraded to Maypole 2.09 and discovered that it is not >> compatible with the Maypole app I have been using. I'm hoping that >> those of you who are more familiar with the Maypole-innards will be >> able to shed some light on why I'm having the problems I am. >> >> It would appear that the neat stuff in Maypole::Application 2.09 is >> still causing problems for my poor Maypole-powered application. >> >> If I downgrade to Maypole::Application 2.07 everything works fine. >> >> I don't think my Maypole app is all that odd. Here's how it begins: >> >> BEGIN { >> package MyApp; >> use MyApp::Constants; >> $ENV{MAYPOLE_CONFIG} = BINPATH . '/MyApp.yaml'; >> } >> >> package MyApp; >> >> use Maypole::Application qw( >> -Debug >> Config::YAML >> Authentication::Abstract >> -Setup >> ); >> >> But unfortunately this doesn't work out too well with >> Maypole::Application 2.09 which still gives me the same error as in 2.08: >> >> MyApp...Debugging enabled >> MyApp...Loaded plugin: Maypole::Plugin::Authentication::Abstract >> MyApp...Loaded plugin: Maypole::Plugin::Config::YAML > > > This looks a little odd. One of the things fixed in 2.09 was to make > sure that the plugins really are loaded in the order they are declared > (this wasn't the case in some previous releases). Now these messages > aren't in the same order as in your use statement. So are you sure these > messages are really being output by 2.09? Indeed. It looks like it has loaded the plugins in sort() order, which was the case pre 2.09. Matt, could you check the debug output of: #!/usr/bin/perl use Maypole::Application 2.09 qw(-Debug Config::YAML Authentication::Abstract); > If so, they seem to be showing a 2.09 bug. A complete simple test case > would be very helpful. > >> MyApp...No DSN set in config >> [error] Can't locate object method "new" via package >> "Class::DBI::Loader::" (perhaps you forgot to load >> "Class::DBI::Loader::"?) at /.../lib/Class/DBI/Loader.pm line 77. > > > I guess your config might be relevant to understanding what's going on > here? (Not by me, I don't use either the YAML or CDBI-Loader :) > > Cheers, Dave > >> BEGIN failed--compilation aborted at /.../MyApp.pm line 36. >> Compilation failed in require at (eval 10) line 3. >> [error] Can't call method "_table2class" on an undefined value at >> /.../lib/Maypole/Model/CDBI.pm line 250. >> >> Can someone give me some pointers as to a) how to fix my app so that >> it is compliant with Maypole::Application 2.09 and/or b) what exactly >> was the purpose of the neat code in Maypole::Application 2.09? >> >> FWIW, I'm using a PERL5LIB path modified by my Apache configuration. I wonder whether it's picking up an older version of Maypole. It would be good to check which version of Maypole::Application is being used. Do you have Apache::Status installed? Simon From dhudes@hudes.org Wed Feb 2 19:25:24 2005 From: dhudes@hudes.org (Dana Hudes) Date: Wed, 2 Feb 2005 14:25:24 -0500 (EST) Subject: [Maypole] Bringup problems with BeerDB Message-ID: In an attempt to eliminate problems with Apache, libraries , PostgreSQL and/or DBD::Pg quirks etc. I am trying to bring up the example Beer database on Apache with mod_perl. As you'll note I've stuck in a use Apache::Reload; as the 1st line after the package declaration, so that I can hack on this w/o HUPing apache. [Wed Feb 2 14:19:47 2005] BeerDB.pm: beers method already exists in BeerDB::Brewery [Wed Feb 2 14:19:47 2005] BeerDB.pm: at /usr/lib/perl5/site_perl/5.8.1/Class/DBI/Relationship/HasMany.pm line 13 [Wed Feb 2 14:19:47 2005] [error] Can't use an undefined value as a HASH reference at /usr/lib/perl5/site_perl/5.8.1/Class/DBI/Relationship/HasMany.pm line 51.\nCompilation failed in require at /usr/lib/perl5/site_perl/5.8.1/Apache/Reload.pm line 132.\n So obviously the problem is that the beers method already exists. Well that sounds like our friend with the plural "fixing" might be at work. From sri@oook.de Wed Feb 2 19:59:56 2005 From: sri@oook.de (Sebastian Riedel) Date: Wed, 02 Feb 2005 20:59:56 +0100 Subject: [Maypole] Maypole::Plugin::Relationships and YAML In-Reply-To: References: <4200FC1F.4020105@ropine.com> <20050202174805.GA20077@soto.kasei.com> <1107366565.23083.1.camel@localhost> Message-ID: <1107374396.23836.2.camel@localhost> Dana Hudes: > On Wed, 2 Feb 2005, Sebastian Riedel wrote: > > > Tony Bowden: > > > I think I'm missing something here. There seems to be this idea that > > > Maypole (and / or Class::DBI) wants the primary key to be called 'id'. > > > Is this actually true? It certainly isn't true for Class::DBI. > > > > > > > Seems only Maypole's factory templates expect id. > > > > As Tony points out, CDBI makes an alias called 'id' -- in CDBI, not SQL > it doesn't touch your schema -- for your PK no matter what you call it. > So long as Maypole doesn't go generating SQL on its own, relying instead > on CDBI, this should not pose a conflict. It also uses column lists... -- sebastian From sf@flacks.net Wed Feb 2 20:07:01 2005 From: sf@flacks.net (Simon Flack) Date: Wed, 02 Feb 2005 20:07:01 +0000 Subject: [Maypole] further exploration of the error I posted In-Reply-To: References: Message-ID: <420132E5.3060703@flacks.net> Dana Hudes wrote: > so I have this short program to sanity-check the YAML: > > use YAML qw(Dump Load LoadFile); > use Data::Dumper; > print Dumper(LoadFile("photogallery.yaml")); > print "\n"; > print Dump(LoadFile("photogallery.yaml")); > > > > the Dumper output looks quite reasonable on first glance. > However, on closer examination and comparison with the > docs of Maypole::Plugin::Untaint I see some slight difference > at the top level. > > I also see a sequence difference: in the perldoc for Plugin::Untaint, > it shows setup invoked AFTER untaint. This makes little > sense, how can you establish constraints in CDBI if you > haven't built the tables yet! You can't very well build tables > w/o the DSN. I've not used M::Plugin::Untaint, but it looks like you need to /define/ your untaint constraints before the call to setup(), so the untaint_columns can be configured individually for each table once they've been loaded. > The YAML shows the dsn section first, but > the perl for that version omits Loader. > Removing Loader from my code doesn't change the error message. > > The difference I see in the data structure is that > in the POD for Maypole::Plugin::Untaint the perl version is > an array of hashes (since arguments to a method are in list context): > MyApp->config->untaint_columns( > table1 => { html => [qw(name email)] }, > table2 => { printable => [qw(lalala)] } > ); I think that's a POD error. Maypole::Config doesn't have an 'untaint_columns' attribute, but if it did it'd probably be in hash context. > However the resultant data structure of YAML is in hash context: > 'untaint_columns' => { > 'websites' => { > 'html' => [ > 'site_name', > 'subjects_template', > 'gallery_template', > 'css' > ], > 'Filenames' => [ > 'doc_root', > 'secured_root', > 'galleries_dir', > 'gallery_thumbs_path', > 'subject_thumbs_path', > 'gallery_list', > 'subject_list' > ], > 'url' => [ > 'secured_url' > ] > }, > etc. > } I think that looks ok. Again, I've not used M::Plugin::Untaint, but from glancing at the source, it should dereference the hash when it sets [My::Table]->untaint_columns(). I think that was the source of your error message "Can't coerce array into hash" > > Now, I found another reason I really don't like YAML: > Use of of white space to indicate hierarchy. The Filenames > was a few spaces left of its proper position > and that made a problem. > Say what you will, you wouldn't have such a problem with XML. I've not really looked into YAML, but it sounds like it would irritate me :) Simon From dhudes@hudes.org Wed Feb 2 20:13:52 2005 From: dhudes@hudes.org (Dana Hudes) Date: Wed, 2 Feb 2005 15:13:52 -0500 (EST) Subject: [Maypole] Maypole::Plugin::Relationships and YAML In-Reply-To: <1107374396.23836.2.camel@localhost> References: <4200FC1F.4020105@ropine.com> <20050202174805.GA20077@soto.kasei.com> <1107366565.23083.1.camel@localhost> <1107374396.23836.2.camel@localhost> Message-ID: On Wed, 2 Feb 2005, Sebastian Riedel wrote: > > Dana Hudes: > >As Tony points out, CDBI makes an alias called 'id' -- in CDBI, not SQL > > it doesn't touch your schema -- for your PK no matter what you call it. > > So long as Maypole doesn't go generating SQL on its own, relying instead > > on CDBI, this should not pose a conflict. > > It also uses column lists... OK but the column list in CDBI includes the alias of id for your PK, I mean that's the point of an alias isn't it? So is this or is this not, a priori, a problem? From sri@oook.de Wed Feb 2 20:14:55 2005 From: sri@oook.de (Sebastian Riedel) Date: Wed, 02 Feb 2005 21:14:55 +0100 Subject: [Maypole] Maypole::Plugin::Relationships and YAML In-Reply-To: References: <4200FC1F.4020105@ropine.com> <20050202174805.GA20077@soto.kasei.com> <1107366565.23083.1.camel@localhost> <1107374396.23836.2.camel@localhost> Message-ID: <1107375295.23836.5.camel@localhost> Dana Hudes: > > On Wed, 2 Feb 2005, Sebastian Riedel wrote: > > > > Dana Hudes: > > > >As Tony points out, CDBI makes an alias called 'id' -- in CDBI, not SQL > > > it doesn't touch your schema -- for your PK no matter what you call it. > > > So long as Maypole doesn't go generating SQL on its own, relying instead > > > on CDBI, this should not pose a conflict. > > > > It also uses column lists... > > OK but the column list in CDBI includes the alias of id for your PK, I > mean that's the point of an alias isn't it? > So is this or is this not, a priori, a problem? OH right! I never used anything different than id, so i didn't know the alias thing. =) It never was a "real" problem, since it's just in the factory templates... -- sebastian From sf@flacks.net Wed Feb 2 20:21:55 2005 From: sf@flacks.net (Simon Flack) Date: Wed, 02 Feb 2005 20:21:55 +0000 Subject: [Maypole] plurality in column names In-Reply-To: References: Message-ID: <42013663.8040301@flacks.net> Dana Hudes wrote: > We've bandied this about. I've come up with a definitive > argument against messing with the plurality of column names. > When we record a woman's measurements, we do not say "hip" > measurement, we say "hips" because the measurement isn't > around one hip its around two. I don't think I've ever had occasion to, but I think I'd say "hip measurement". If there are hard and fast rules about plurality, I don't know what they are. Do you know why we brush our teeth with a toothbrush and not a teethbrush? As far as I'm concerned, you can call your tables and columns whatever you like. I think it's more important that there's a naming 'convention' (i.e. it's consistent and predictable). Maypole /shouldn't/ get in the way (other than a few reserved method names). But I suspect that the problems you're having with naming is coming from Class::DBI::Loader::Relationship or Class::DBI::Loader. Maypole should accommodate a custom loader or vanilla Class::DBI packages via Maypole::Model::CDBI::Plain. HTH Simon From peterspeltz@yahoo.com Wed Feb 2 20:38:46 2005 From: peterspeltz@yahoo.com (Peter Speltz) Date: Wed, 2 Feb 2005 12:38:46 -0800 (PST) Subject: [Maypole] Maypole::Plugin::Relationships and YAML In-Reply-To: Message-ID: <20050202203846.1488.qmail@web52104.mail.yahoo.com> --- Dana Hudes wrote: > > > On Wed, 2 Feb 2005, Sebastian Riedel wrote: > > > > Dana Hudes: > > > >As Tony points out, CDBI makes an alias called 'id' -- in CDBI, not SQL > > > it doesn't touch your schema -- for your PK no matter what you call it. > > > So long as Maypole doesn't go generating SQL on its own, relying instead > > > on CDBI, this should not pose a conflict. > > > > It also uses column lists... > > OK but the column list in CDBI includes the alias of id for your PK, I > mean that's the point of an alias isn't it? > So is this or is this not, a priori, a problem? > If you mean the list generated by $class->columns() , i don't think it does. CDBI makes an accessor called "id" which if you say $class->id returns the equivalent of $class->primary_column. But if your PK is not named "id" in your table i don't think the "columns()" list will have 'id' in it and i bet if you say $class->get('id') you won't get anything. I've never checked any of this and i could be misunderstanding. ===== pjs __________________________________ Do you Yahoo!? All your favorites on one personal page – Try My Yahoo! http://my.yahoo.com From sri@oook.de Wed Feb 2 20:39:22 2005 From: sri@oook.de (Sebastian Riedel) Date: Wed, 02 Feb 2005 21:39:22 +0100 Subject: [Maypole] Maypole::Plugin::Relationships and YAML In-Reply-To: <1107375295.23836.5.camel@localhost> References: <4200FC1F.4020105@ropine.com> <20050202174805.GA20077@soto.kasei.com> <1107366565.23083.1.camel@localhost> <1107374396.23836.2.camel@localhost> <1107375295.23836.5.camel@localhost> Message-ID: <1107376762.23836.8.camel@localhost> Sebastian Riedel: > > > >As Tony points out, CDBI makes an alias called 'id' -- in CDBI, not SQL > > > > it doesn't touch your schema -- for your PK no matter what you call it. > > > > So long as Maypole doesn't go generating SQL on its own, relying instead > > > > on CDBI, this should not pose a conflict. > > > > > > It also uses column lists... > > > > OK but the column list in CDBI includes the alias of id for your PK, I > > mean that's the point of an alias isn't it? > > So is this or is this not, a priori, a problem? > > OH right! I never used anything different than id, so i didn't know the > alias thing. =) > > It never was a "real" problem, since it's just in the factory > templates... > Ok i've tested it now, and columns() does NOT return id! -- sebastian From m.romani@spinsoft.it Wed Feb 2 20:57:27 2005 From: m.romani@spinsoft.it (Marcello) Date: Wed, 02 Feb 2005 21:57:27 +0100 Subject: [Maypole] Problems with sessions In-Reply-To: References: Message-ID: <42013EB7.1010702@spinsoft.it> Maybe I'm OT in here, but I have some trouble storing information in the session slot of the maypole request. I'm using Maypole::Authentication::UserSessionCookie version 1.4 My app is set up as follows: # authentication configuration ############################### SA::User->require || warn "Couldn't load SA::User class."; SA->config->{auth}{user_class} = "SA::User"; SA->config->{auth}{user_field} = "username"; SA->config->{auth}{password_field} = "password"; SA->config->{auth}{session_class} = "Apache::Session::MySQL"; SA->config->{auth}{session_args} = { DataSource => 'dbi:mysql:sa_sessions', UserName => $db_username, Password => $db_password, LockDataSource => 'dbi:mysql:sa_sessions', LockUserName => $db_username, LockPassword => $db_password, }; User authentication works perfectly. In Maypole/Model/CDBI.pm I have a "view" method, in which I store a key/value pair in the current session: sub view : Exported { my ($self, $r) = @_; my $me = $r->objects->[0]; $r->{session}{constraints}->{$me->table} = $me->id; return $self->SUPER::view($r); } The main problem I have is if I call the /view/ method on three tables, the first key/value pair goes away, i.e. it seems there can be only two key/value pairs in the "constraints" hash. An example: /customer/view/3 -> constraints{customer} == 3 /beer/view/1 -> constraints{beer} == 1 /othertable/view/5 -> constraints{othertable}==5, but the "customer" entry has gone away! What do you think ? Thanks in advance. Marcello From dhudes@hudes.org Thu Feb 3 00:37:46 2005 From: dhudes@hudes.org (Dana Hudes) Date: Wed, 2 Feb 2005 19:37:46 -0500 (EST) Subject: [Maypole] Maypole fails its tests Message-ID: I installed IO::CaptureOutput and did "make test" again in the build directory, running as myself not root. Some of it looks like just a bug in test 28 -- the output is there just the sequence is wrong. dhudes@screamer:~/Maypole-2.09> make test PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/01basics.........ok t/02pod............ok t/03podcoverage....ok 1/13Too late to run CHECK block at /home/dhudes/Maypole-2.09/blib/lib/Maypole/CLI.pm line 17. t/03podcoverage....ok t/apache_mvc.......ok t/application......ok 1/10Debugging enabled at /home/dhudes/Maypole-2.09/blib/lib/Maypole/Application.pm line 24. t/application......ok t/cgi_maypole......NOK 28 # Failed test (t/cgi_maypole.t at line 115) # got: 'X-bender: kiss my shiny metal ass # Content-length: 12 # Content-Type: text/plain; charset=iso8859-1 # # Hello World!' # expected: 'Content-length: 12 # X-bender: kiss my shiny metal ass # Content-Type: text/plain; charset=iso8859-1 # # Hello World!' # Looks like you failed 1 test of 30. t/cgi_maypole......dubious Test returned status 1 (wstat 256, 0x100) DIED. FAILED test 28 Failed 1/30 tests, 96.67% okay t/constants........ok t/headers..........ok t/maypole..........ok Failed Test Stat Wstat Total Fail Failed List of Failed ------------------------------------------------------------------------------- t/cgi_maypole.t 1 256 30 1 3.33% 28 Failed 1/9 test scripts, 88.89% okay. 1/231 subtests failed, 99.57% okay. make: *** [test_dynamic] Error 255 From m.romani@spinsoft.it Thu Feb 3 08:11:35 2005 From: m.romani@spinsoft.it (Marcello) Date: Thu, 03 Feb 2005 09:11:35 +0100 Subject: [Maypole] Problems with sessions In-Reply-To: <42013EB7.1010702@spinsoft.it> References: <42013EB7.1010702@spinsoft.it> Message-ID: <4201DCB7.3080502@spinsoft.it> Sorry to pollute this thread. I'll repost as a new thread. M. From m.romani@spinsoft.it Thu Feb 3 08:12:41 2005 From: m.romani@spinsoft.it (Marcello) Date: Thu, 03 Feb 2005 09:12:41 +0100 Subject: [Maypole] Problems with sessions Message-ID: <4201DCF9.9040404@spinsoft.it> Maybe I'm OT in here, but I have some trouble storing information in the session slot of the maypole request. I'm using Maypole::Authentication::UserSessionCookie version 1.4 My app is set up as follows: # authentication configuration ############################### SA::User->require || warn "Couldn't load SA::User class."; SA->config->{auth}{user_class} = "SA::User"; SA->config->{auth}{user_field} = "username"; SA->config->{auth}{password_field} = "password"; SA->config->{auth}{session_class} = "Apache::Session::MySQL"; SA->config->{auth}{session_args} = { DataSource => 'dbi:mysql:sa_sessions', UserName => $db_username, Password => $db_password, LockDataSource => 'dbi:mysql:sa_sessions', LockUserName => $db_username, LockPassword => $db_password, }; User authentication works perfectly. In Maypole/Model/CDBI.pm I have a "view" method, in which I store a key/value pair in the current session: sub view : Exported { my ($self, $r) = @_; my $me = $r->objects->[0]; $r->{session}{constraints}->{$me->table} = $me->id; return $self->SUPER::view($r); } The main problem I have is if I call the /view/ method on three tables, the first key/value pair goes away, i.e. it seems there can be only two key/value pairs in the "constraints" hash. An example: /customer/view/3 -> constraints{customer} == 3 /beer/view/1 -> constraints{beer} == 1 /othertable/view/5 -> constraints{othertable}==5, but the "customer" entry has gone away! What do you think ? Thanks in advance. Marcello From dhoworth@mrc-lmb.cam.ac.uk Thu Feb 3 11:47:07 2005 From: dhoworth@mrc-lmb.cam.ac.uk (Dave Howorth) Date: Thu, 03 Feb 2005 11:47:07 +0000 Subject: [Maypole] Data::FormValidator status In-Reply-To: <4200F52A.6060304@mrc-lmb.cam.ac.uk> References: <4200F52A.6060304@mrc-lmb.cam.ac.uk> Message-ID: <42020F3B.4020107@mrc-lmb.cam.ac.uk> In reply to: > Are you planning on taking this out of Maypole into a generic "update > Class::DBI objects using Data::FormValidator" that can go to CPAN just > like Class::DBI::FromCGI? and: > This could also become a patch for Class::DBI::FromForm. ;) At the moment, I don't see anything worth extracting. It looks to me like glue between Maypole's request and its view. There are several equivalent modules that do a similar job for other frameworks , I think. It's early days but if this hack does ever mutate into a module, I suspect it belongs under the Maypole top-level. Cheers, Dave From dhoworth@mrc-lmb.cam.ac.uk Thu Feb 3 12:11:39 2005 From: dhoworth@mrc-lmb.cam.ac.uk (Dave Howorth) Date: Thu, 03 Feb 2005 12:11:39 +0000 Subject: [Maypole] text string generation in Maypole Message-ID: <420214FB.2040102@mrc-lmb.cam.ac.uk> There's been another burst of discussion about text strings and as some will know, I have a bee in my bonnet about that! My views are recorded in the archive. Now I've lately come to realize that there're some fairly simple changes that would improve things, so let me try to explain. GOALS Some of Maypole's attraction comes from the automatic generation of labels for display. But philosophically, text belongs in the templates (or database, or resource files) but NOT in the code. There will always be exceptions to automatic generation (like, normally take the singular of a column, except for 'hips'). The clasic killer 'exception' is foreign language translation of labels. REALITY Label generation is spread over many methods in several modules, some of which are not even part of Maypole, with several different authors, so coordination is difficult and even locating a problem can be time-consuming. Well-known issues include plural and multi-word table or column names. THOUGHTS -1- Collect all the text generation algorithms in one place (like my Mangle.pm does) so we can all see what we've got any time we want and developers can easily override any part they need to. -2- Maypole uses context-sensitive names. E.g. classmetadata.moniker returns one string in a class called Beer and a different string in a class called Brewery. If we used absolute names. E.g.: tables.Beer.singular => 'Beer' tables.Brewery.singular => 'Brewery' so we say [% tables.$class.singular %] in a template instead of [% classmetadata.moniker %], then it becomes trivial to apply exceptions. We just have a text_exceptions.tt that is PROCESSed at the start of each template that can just contain things like: tables.Beer.singular => 'Bier' tables.Brewery.singular => 'Brauerei' So web designers can easily override things without having to change any code. Note that these data structures need to be hashes, not objects, for this to work. Cheers, Dave From tony@kasei.com Thu Feb 3 12:13:23 2005 From: tony@kasei.com (Tony Bowden) Date: Thu, 3 Feb 2005 12:13:23 +0000 Subject: [Maypole] Data::FormValidator status In-Reply-To: <42020F3B.4020107@mrc-lmb.cam.ac.uk> References: <4200F52A.6060304@mrc-lmb.cam.ac.uk> <42020F3B.4020107@mrc-lmb.cam.ac.uk> Message-ID: <20050203121323.GA31635@soto.kasei.com> On Thu, Feb 03, 2005 at 11:47:07AM +0000, Dave Howorth wrote: > At the moment, I don't see anything worth extracting. It looks to me > like glue between Maypole's request and its view. There are several > equivalent modules that do a similar job for other frameworks , I think. > It's early days but if this hack does ever mutate into a module, I > suspect it belongs under the Maypole top-level. I disagree. Having a module that integrates Class::DBI with Data::FormValidator is of much wider use than Maypole. Tony From naughton@umn.edu Fri Feb 4 05:08:17 2005 From: naughton@umn.edu (David Naughton) Date: Thu, 3 Feb 2005 23:08:17 -0600 Subject: [Maypole] Maypole or Catalyst? In-Reply-To: <20050203121323.GA31635@soto.kasei.com> References: <4200F52A.6060304@mrc-lmb.cam.ac.uk> <42020F3B.4020107@mrc-lmb.cam.ac.uk> <20050203121323.GA31635@soto.kasei.com> Message-ID: <20050204050817.GA15011@umn.edu> For a wiki framework I'm developing, I'm considering a port to either Maypole or Catalyst. I'd greatly appreciate any help in making up my mind. One big reason I'm asking has to do with URIs. My wiki supports hierarchical namespaces, i.e. /path/to/page. I'm planning to use Maypole or Catalyst to do things like /path/to/page/edit, /path/to/page/history, etc. where 'edit', 'history', etc. are methods. All pages will be handled by a default "wiki page" plugin, but I also want to easily override the default with other plugins for arbitrary URIs. Maypole? Maypole seems to be built around the assumption that URIs will be /path/to/some_class/some_method. Is it easy to override that behavior? Even if it is, I'm a little uncomfortable with the idea of constantly overriding a core feature. Am I right to be concerned about this? Catalyst? It seems that Catalyst may have the flexibility to support my goals OOTB. However, the documentation is so sparse that it's hard to tell. Sebastian, can you provide some more complex examples? I'd also love to know what features you've stolen from Ruby on Rails, Springs, etc. along with some examples of their use. If either of these projects would meet my needs, I'd be happy to contribute whatever I can. Thank you, David Naughton From sri@oook.de Fri Feb 4 07:16:59 2005 From: sri@oook.de (Sebastian Riedel) Date: Fri, 04 Feb 2005 08:16:59 +0100 Subject: [Maypole] Maypole or Catalyst? In-Reply-To: <20050204050817.GA15011@umn.edu> References: <4200F52A.6060304@mrc-lmb.cam.ac.uk> <42020F3B.4020107@mrc-lmb.cam.ac.uk> <20050203121323.GA31635@soto.kasei.com> <20050204050817.GA15011@umn.edu> Message-ID: <1107501420.5142.58.camel@localhost> David Naughton: > One big reason I'm asking has to do with URIs. My wiki supports > hierarchical namespaces, i.e. /path/to/page. I'm planning to use Maypole > or Catalyst to do things like /path/to/page/edit, /path/to/page/history, > etc. where 'edit', 'history', etc. are methods. All pages will be > handled by a default "wiki page" plugin, but I also want to easily > override the default with other plugins for arbitrary URIs. It's a bit unusual scheme, but i guess you've got your reasons... > Maypole? > > Maypole seems to be built around the assumption that URIs will be > /path/to/some_class/some_method. Is it easy to override that behavior? > Even if it is, I'm a little uncomfortable with the idea of constantly > overriding a core feature. Am I right to be concerned about this? Yes Maypole is bound to it's uri scheme and expects you to rewrite them in a parse_path() method or to use mod_rewrite... The nature of Maypole is to expose tables to the web and let the user call methods on them (whis mostly just works for most kind of webapps). > > Catalyst? > > It seems that Catalyst may have the flexibility to support my goals > OOTB. Definately. > However, the documentation is so sparse that it's hard to tell. > Sebastian, can you provide some more complex examples? I'd also love to > know what features you've stolen from Ruby on Rails, Springs, etc. along > with some examples of their use. I've stolen lots of features, and am still stealing every day. ;) >From RoR i've mostly stolen the overall structure with multiple controllers, optional scaffolding and automatically loading of components. For example a controller class. # lib/MyApp/C/Hunter.pm package Kobai::C::Hunter; use strict; use base 'Catalyst::Base'; Kobai->action( '?create' => sub { my ( $self, $c ) = @_; $c->stash->{template} = 'hunter/create.tt'; # do stuff } '?delete' => sub { my ( $self, $c ) = @_; $c->stash->{template} = 'hunter/delete.tt'; # do stuff } 'sign-in' => sub { my ( $self, $c ) = @_; $c->stash->{template} = 'sign-in.tt'; # do stuff } ); You just create this file and Catalyst will automatically find and load it without any configuration. This class would magically expose /hunter/create, /hunter/delete and /sign-in. (? is a placeholder for the actual class's moniker) >From Spring i've mostly just taken ideas on how to apply cool design pattern like interceptors, decorators and filters. Which was very simple, thanks to Catalysts easy flow control with $c->forward(). Kobai->action( '?create' => sub { my ( $self, $c ) = @_; # This is the entry point /prefix/create return unless $c->forward('!check-roles'); # do stuff $c->forward('prefix/send-new-password'); } '!check-roles' => sub { my ( $self, $c ) = @_; # check the permissions, # which are role based in Catalyst return 1 if world_is_fine(); return 0; } '?send-new-password' => sub { my ( $self, $c ) = @_; # This action can be used internally and externally! $c->stash->{template} ||= 'index.tt'; # do stuff } '!end' => sub { my ( $self, $c ) = @_; # This is a built in private action # used to render templates at end of request # Automatically called by Catalyst. # Set a template if noone else did $c->stash->{template} ||= 'index.tt'; # This will render the template $c->forward('Kobai::V::TT'); } ); Not a perfect example but you get the idea. ;) ! indicates private actions, some are built in... > If either of these projects would meet my needs, I'd be happy to > contribute whatever I can. Most of the time i'm hanging around in #maypole on irc.perl.org and am happy to answer all kind of questions. I also tend to extend the Catalyst Manual on request. ;) A Catalyst powered wiki would be a great contribution. Recipes for the manual would be cool too. Sad thing is that currently no big examples exist, but note that Catalyst is just a few weeks old. ;) I'm actually working on something really big, you'll see soon. =) You should get in contact with Marcus "draven" Ramberg (also on #maypole), he recently started porting his Mitiki to Catalyst. -- sebastian From simon@simon-cozens.org Fri Feb 4 07:58:21 2005 From: simon@simon-cozens.org (Simon Cozens) Date: Fri, 4 Feb 2005 07:58:21 +0000 Subject: [Maypole] Maypole or Catalyst? In-Reply-To: <1107501420.5142.58.camel@localhost> References: <4200F52A.6060304@mrc-lmb.cam.ac.uk> <42020F3B.4020107@mrc-lmb.cam.ac.uk> <20050203121323.GA31635@soto.kasei.com> <20050204050817.GA15011@umn.edu> <1107501420.5142.58.camel@localhost> Message-ID: <20050204075821.GA23713@alibi.simon-cozens.org> Sebastian Riedel: > Yes Maypole is bound to it's uri scheme and expects you to rewrite them > in a parse_path() method or to use mod_rewrite... Another way to put this is to say that, since you can override parse_path, Maypole is not bound to an URI scheme at all. ;) -- She said that she was working for the ABC News, It was as much of the alphabet as she knew how to use -- Elvis Costello From m.romani@spinsoft.it Fri Feb 4 17:38:50 2005 From: m.romani@spinsoft.it (Marcello) Date: Fri, 04 Feb 2005 18:38:50 +0100 Subject: [Maypole] Problems with sessions [Solved] In-Reply-To: <4201DCF9.9040404@spinsoft.it> References: <4201DCF9.9040404@spinsoft.it> Message-ID: <4203B32A.70209@spinsoft.it> Marcello ha scritto: > Maybe I'm OT in here, but I have some trouble storing information in the > session slot of the maypole request. > I'm using Maypole::Authentication::UserSessionCookie version 1.4 > > My app is set up as follows: > > > # authentication configuration > ############################### > SA::User->require || warn "Couldn't load SA::User class."; > SA->config->{auth}{user_class} = "SA::User"; > SA->config->{auth}{user_field} = "username"; > SA->config->{auth}{password_field} = "password"; > SA->config->{auth}{session_class} = "Apache::Session::MySQL"; > SA->config->{auth}{session_args} = { > DataSource => 'dbi:mysql:sa_sessions', > UserName => $db_username, > Password => $db_password, > LockDataSource => 'dbi:mysql:sa_sessions', > LockUserName => $db_username, > LockPassword => $db_password, > }; > > > User authentication works perfectly. > > In Maypole/Model/CDBI.pm I have a "view" method, in which I store a > key/value pair in the current session: > > > sub view : Exported { > my ($self, $r) = @_; > my $me = $r->objects->[0]; > $r->{session}{constraints}->{$me->table} = $me->id; > return $self->SUPER::view($r); > } > > > The main problem I have is if I call the /view/ method on three tables, > the first key/value pair goes away, i.e. it seems there can be only two > key/value pairs in the "constraints" hash. > An example: > /customer/view/3 -> constraints{customer} == 3 > /beer/view/1 -> constraints{beer} == 1 > /othertable/view/5 -> constraints{othertable}==5, but the "customer" > entry has gone away! > > What do you think ? > > Thanks in advance. > Marcello > > _______________________________________________ > maypole mailing list > maypole@lists.netthink.co.uk > http://lists.netthink.co.uk/listinfo/maypole > The problem was I was not familiar with tied references... I changed my code to modify the session this way: get a reference to the session variable my $a=$r->{session}->{constraints} modify the session variable $a->{customer} = 4 store the modified session variable into the session $r->{session}->{constraints} = $a This ensures the changes to the session are saved. Marcello From peterspeltz@yahoo.com Fri Feb 4 18:28:11 2005 From: peterspeltz@yahoo.com (Peter Speltz) Date: Fri, 4 Feb 2005 10:28:11 -0800 (PST) Subject: [Maypole] Problems with sessions [Solved] In-Reply-To: <4203B32A.70209@spinsoft.it> Message-ID: <20050204182811.61905.qmail@web52105.mail.yahoo.com> --- Marcello wrote: > Marcello ha scritto: > > The problem was I was not familiar with tied references... > > I changed my code to modify the session this way: > get a reference to the session variable > my $a=$r->{session}->{constraints} > modify the session variable > $a->{customer} = 4 > store the modified session variable into the session > $r->{session}->{constraints} = $a > This ensures the changes to the session are saved. > > Marcello > That's right. Apache::Session only looks in the top level for changes when deciding whether to write session or not. So it was looking at the constraints hash ref and not seeing any change (its still hash at same address) and it doesn't look down in the hash for changes. Another way to do it is to timestamp the session every time you update it as mentioned in Apache;:Session manual. $r->session->{timstamp} = localtime; or what not. ===== pjs __________________________________ Do you Yahoo!? The all-new My Yahoo! - Get yours free! http://my.yahoo.com From matt.adams@morcor.com Fri Feb 4 21:30:30 2005 From: matt.adams@morcor.com (Matt Adams) Date: Fri, 04 Feb 2005 16:30:30 -0500 Subject: [Maypole] Maypole::Application still broken in 2.09? In-Reply-To: <42012867.8040901@flacks.net> References: <41FFDF7A.3060706@morcor.com> <42001311.5060103@acm.org> <42012867.8040901@flacks.net> Message-ID: <4203E976.1020300@morcor.com> Hi Simon: Sorry it took so long to get back to you. Things have been crazy at the work place. Just to reiterate, here is my Maypole app configuration: BEGIN { package MyApp; use MyApp::Constants; $ENV{MAYPOLE_CONFIG} = BINPATH . '/MyApp.yaml'; } package MyApp; use Maypole::Application qw( -Debug Config::YAML Authentication::Abstract -Setup ); >>> >>> But unfortunately this doesn't work out too well with >>> Maypole::Application 2.09 which still gives me the same error as in >>> 2.08: >>> >>> MyApp...Debugging enabled >>> MyApp...Loaded plugin: Maypole::Plugin::Authentication::Abstract >>> MyApp...Loaded plugin: Maypole::Plugin::Config::YAML >> >> >> >> This looks a little odd. One of the things fixed in 2.09 was to make >> sure that the plugins really are loaded in the order they are declared >> (this wasn't the case in some previous releases). Now these messages >> aren't in the same order as in your use statement. So are you sure >> these messages are really being output by 2.09? Whoops. I should have looked at the output closer. You're right: Maypole::Application 2.09 gets the order straight. 2.08 doesn't. However, I still get the same error with 2.09 that I did with 2.08. The error (slightly edited to remove long paths) is: MyApp...Debugging enabled MyApp...Loaded plugin: Maypole::Plugin::Config::YAML MyApp...Loaded plugin: Maypole::Plugin::Authentication::Abstract MyApp...No DSN set in config [error] Can't locate object method "new" via package "Class::DBI::Loader::" (perhaps you forgot to load "Class::DBI::Loader::"?) at Class/DBI/Loader.pm line 77. BEGIN failed--compilation aborted at MyApp.pm line 36. Compilation failed in require at (eval 17) line 3. [error] Can't call method "_table2class" on an undefined value at Maypole/Model/CDBI.pm line 250. > Indeed. It looks like it has loaded the plugins in sort() order, which > was the case pre 2.09. > > Matt, could you check the debug output of: > > #!/usr/bin/perl > use Maypole::Application 2.09 qw(-Debug Config::YAML > Authentication::Abstract); Yes. The output (slightly edited to remove unsightly paths) of this command is: Debugging enabled at Maypole/Application.pm line 24. Loaded plugin: Maypole::Plugin::Config::YAML at Maypole/Application.pm line 31. Loaded plugin: Maypole::Plugin::Authentication::Abstract at Maypole/Application.pm line 31. >> If so, they seem to be showing a 2.09 bug. A complete simple test case >> would be very helpful. >> >> I guess your config might be relevant to understanding what's going on >> here? (Not by me, I don't use either the YAML or CDBI-Loader :) My YAML config file is: --- #YAML:1.0 dsn: dbi:mysql:myapp model: MyApp::Model::CDBI pass: user rows_per_page: 10 uri_base: http://bugs:8000/ user: user datetime: '%a, %b %e, %Y at %l:%M %p' FWIW, I'm using a PERL5LIB path modified by my Apache configuration. And few of my Perl modules are in the standard location but that doesn't seem to (and shouldn't) matter since the PERL5LIB path includes them all. > I wonder whether it's picking up an older version of Maypole. It would > be good to check which version of Maypole::Application is being used. Do > you have Apache::Status installed? Nope. It appears to be picking up the correct version of Maypole. I only have one installed. Things work if I use Maypole::Application 2.07 but not if I use Maypole::Application 2.08 or 2.09. Thanks for your help! Matt -- Matt Adams Development Specialist Morcor Solutions Inc. (613) 354-2912 x228 GnuPG public key at Key fingerprint: BED5 B4F7 CCF5 D7B5 7C56 0505 9A0A A0FB C937 5975 From matt.adams@morcor.com Fri Feb 4 21:32:20 2005 From: matt.adams@morcor.com (Matt Adams) Date: Fri, 04 Feb 2005 16:32:20 -0500 Subject: [Maypole] Maypole::Application still broken in 2.09? In-Reply-To: <42012867.8040901@flacks.net> References: <41FFDF7A.3060706@morcor.com> <42001311.5060103@acm.org> <42012867.8040901@flacks.net> Message-ID: <4203E9E4.3060706@morcor.com> Simon Flack wrote: > Do you have Apache::Status installed? Yes I do but it doesn't appear to do me any good unless Maypole loads correctly. Cheers Matt -- Matt Adams Development Specialist Morcor Solutions Inc. (613) 354-2912 x228 GnuPG public key at Key fingerprint: BED5 B4F7 CCF5 D7B5 7C56 0505 9A0A A0FB C937 5975 From Dave.Howorth@acm.org Fri Feb 4 22:31:34 2005 From: Dave.Howorth@acm.org (Dave Howorth) Date: Fri, 04 Feb 2005 22:31:34 +0000 Subject: [Maypole] Maypole::Application still broken in 2.09? In-Reply-To: <4203E976.1020300@morcor.com> References: <41FFDF7A.3060706@morcor.com> <42001311.5060103@acm.org> <42012867.8040901@flacks.net> <4203E976.1020300@morcor.com> Message-ID: <4203F7C6.9050906@acm.org> Matt Adams wrote: > BEGIN { > package MyApp; > use MyApp::Constants; > $ENV{MAYPOLE_CONFIG} = BINPATH . '/MyApp.yaml'; > } > > package MyApp; > > use Maypole::Application qw( > -Debug > Config::YAML > Authentication::Abstract > -Setup > ); > The error (slightly edited to remove long paths) is: > > MyApp...Debugging enabled > MyApp...Loaded plugin: Maypole::Plugin::Config::YAML > MyApp...Loaded plugin: Maypole::Plugin::Authentication::Abstract > MyApp...No DSN set in config > [error] Can't locate object method "new" via package > "Class::DBI::Loader::" (perhaps you forgot to load > "Class::DBI::Loader::"?) at Class/DBI/Loader.pm line 77. > BEGIN failed--compilation aborted at MyApp.pm line 36. > Compilation failed in require at (eval 17) line 3. > [error] Can't call method "_table2class" on an undefined value at > Maypole/Model/CDBI.pm line 250. > My YAML config file is: > > --- #YAML:1.0 > dsn: dbi:mysql:myapp > model: MyApp::Model::CDBI > pass: user > rows_per_page: 10 > uri_base: http://bugs:8000/ > user: user > datetime: '%a, %b %e, %Y at %l:%M %p' > > FWIW, I'm using a PERL5LIB path modified by my Apache configuration. > And few of my Perl modules are in the standard location but that doesn't > seem to (and shouldn't) matter since the PERL5LIB path includes them all. > It appears to be picking up the correct version of Maypole. I > only have one installed. Things work if I use Maypole::Application 2.07 > but not if I use Maypole::Application 2.08 or 2.09. Hi Matt, I just noticed one more oddity. Your 'reference' version of Maypole is 2.07. Now that was never actually released to CPAN because of problems that emerged with the pre-release. So I guess it's worth asking whether you see your problem with an earlier released version? That said, you may need to do some more investigation anyway. I mentioned that I didn't use YAML and it's clear from Simon's answer that he doesn't! Nobody else has stepped up to say that they DO use YAML and report either that they can repeat your problem or that it works for them. So there's a real lack of information to diagnose the problem. I'd suggest you step though the problem in the debugger using Maypole::CLI. The relevant bits of Maypole::Application, Maypole::Plugin::Config::YAML and Maypole::Model::CDBI are small enough that this should be fairly easy. That way you can find out just what is going wrong and in which module. Cheers, Dave -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.300 / Virus Database: 265.8.4 - Release Date: 01/02/05 From forehead@4red.org Sat Feb 5 05:29:03 2005 From: forehead@4red.org (forehead) Date: Sat, 5 Feb 2005 13:29:03 +0800 Subject: [Maypole] XUL or not? Message-ID: aGkgdGhlcmUsDQoNCmhlcmUgaXMgYSBibG9nIGF0cmljbGU6DQpodHRwOi8vd3d3LnplZHNoYXcu Y29tL2Jsb2cvcHJvZ3JhbW1pbmcvcnVieV94dWwuaHRtbA0KDQp3aGljaCB0YWxraW5nIGFib3V0 IHJ1Ynkgb24gcmFpbHMgLCB0aGUgZ3JlYXQgZnJhbWV3b3JrLA0Kd2hlbiByYWlscyBtZWV0IFhV TC4NCg0KdGhlbiAsaG93J3Mgb3VyIHR3byBNVkMgZnJhbXdvcmsoIE1heXBvbGUgb3IgQ2F0YWx5 c3QpDQptZWV0IFhVTD8NCg0KYW55IGlkZWE/DQoNCiAJCQkJDQoNCqGhoaGhoaGhoaGhoaGhoaFm b3JlaGVhZA0KoaGhoaGhoaGhoaGhoaGhoWZvcmVoZWFkQDRyZWQub3JnDQqhoaGhoaGhoaGhoaGh oaGhoaGhoTIwMDUtMDItMDUNCg== From sri@oook.de Sat Feb 5 06:45:53 2005 From: sri@oook.de (Sebastian Riedel) Date: Sat, 05 Feb 2005 07:45:53 +0100 Subject: [Maypole] XUL or not? In-Reply-To: References: Message-ID: <1107585954.15182.2.camel@localhost> forehead: > then ,how's our two MVC framwork( Maypole or Catalyst) > meet XUL? XUL is ordinary XML mixed with JavaScript...so it just works, with both. -- sebastian From Aaron Trevena Sat Feb 5 09:40:29 2005 From: Aaron Trevena (Aaron Trevena) Date: Sat, 5 Feb 2005 09:40:29 +0000 Subject: [Maypole] Data::FormValidator status In-Reply-To: <20050203121323.GA31635@soto.kasei.com> References: <4200F52A.6060304@mrc-lmb.cam.ac.uk> <42020F3B.4020107@mrc-lmb.cam.ac.uk> <20050203121323.GA31635@soto.kasei.com> Message-ID: On Thu, 3 Feb 2005 12:13:23 +0000, Tony Bowden wrote: > On Thu, Feb 03, 2005 at 11:47:07AM +0000, Dave Howorth wrote: > > At the moment, I don't see anything worth extracting. It looks to me > > like glue between Maypole's request and its view. There are several > > equivalent modules that do a similar job for other frameworks , I think. > > It's early days but if this hack does ever mutate into a module, I > > suspect it belongs under the Maypole top-level. > > I disagree. > > Having a module that integrates Class::DBI with Data::FormValidator is > of much wider use than Maypole. > Quite true. I'd like to use something like this in Class::PINT. Cheers, A. From m.romani@spinsoft.it Mon Feb 7 10:41:23 2005 From: m.romani@spinsoft.it (Marcello) Date: Mon, 07 Feb 2005 11:41:23 +0100 Subject: [Maypole] Problems with sessions [Solved] In-Reply-To: <20050204182811.61905.qmail@web52105.mail.yahoo.com> References: <20050204182811.61905.qmail@web52105.mail.yahoo.com> Message-ID: <420745D3.3050801@spinsoft.it> Peter Speltz ha scritto: > --- Marcello wrote: > > >>Marcello ha scritto: > > >>The problem was I was not familiar with tied references... >> >>I changed my code to modify the session this way: >>get a reference to the session variable >>my $a=$r->{session}->{constraints} >>modify the session variable >>$a->{customer} = 4 >>store the modified session variable into the session >>$r->{session}->{constraints} = $a >>This ensures the changes to the session are saved. >> >>Marcello >> > > > That's right. Apache::Session only looks in the top level for changes when > deciding whether to write session or not. So it was looking at the constraints > hash ref and not seeing any change (its still hash at same address) and it > doesn't look down in the hash for changes. > > Another way to do it is to timestamp the session every time you update it as > mentioned in Apache;:Session manual. > > $r->session->{timstamp} = localtime; > or what not. Thanks for the reference. Marcello From chicks@chicks.net Fri Feb 11 01:07:12 2005 From: chicks@chicks.net (Christopher Hicks) Date: Thu, 10 Feb 2005 20:07:12 -0500 (EST) Subject: [Maypole] Class::DBI->set() called with broke stuff Message-ID: I've been trying to get Maypole to work this table "contact": +------------------+------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------------+------------+------+-----+---------+----------------+ | id | int(14) | | PRI | NULL | auto_increment | | internic_handle | char(31) | YES | MUL | NULL | | | finilever_handle | char(31) | | UNI | | | | first_name | char(64) | | | | | | last_name | char(64) | | | | | | org_name | char(64) | | | | | | address1 | char(64) | | | | | | address2 | char(64) | | | | | | address3 | char(64) | | | | | | city | char(64) | | | | | | state | char(32) | | | | | | postal_code | char(32) | | | | | | country | char(2) | | | | | | phone | char(20) | | | | | | fax | char(20)