[Maypole] Maypole and Postgres

From: Justin Tocci (jtocci at coderascal.com)
Date: Mon Jan 24 2005 - 19:01:05 GMT


I'm having trouble using PostgreSQL VIEWS (instead of TABLEs). I've
downloaded the mailing list archive and searched it out. There is a
mention of how to get it to work, but pity me please, I'm having
trouble following it (reposted below).

I spent two weeks trying to get Maypole to work with PostgreSQL VIEWs.
Then I spent about six hours this past weekend trying to modify code I
got out of "CGI Programming with Perl" from O'Reilly to use primary
keys for updates and deletes on a VIEW.

I much prefer Maypole because all my business app's need what it gives;
a quick way to get the data on the web so you can CRUD it. I'd hate to
write all that from scratch, but I was frustrated enough to start.

So here I am. The $24,000 question.

> > > > > > > > >
>>> Does anyone have a working setup of Maypole with PostgreSQL
VIEWs?
> > > > > > > > >

For bonus points, could I persuade someone to post sample code, how
they got it working, advice, caveats, ANYTHING! If I get it working I
will post a tutorial on the Maypole Wiki.

justin tocci
fort wayne, in

As a novice to Perl and Maypole I am not sure I can contribute much to
the community. I am PostgreSQL savvy however and if I get Maypole going
I'll try to help if I see Pg related posts. Meanwhile, this little
ditty strips the email headers out of the Maypole mailing list archive.
This is only my tenth or so perl program, so go easy on me. I'm just
trying to help out in my own lame way.

#!/usr/bin/perl -w
use strict;
open MAYPOLEIN, "/Users/jtocci/Desktop/maypole.txt"
   or die "A problem occured ($!)";
my $file;
while (<MAYPOLEIN>) {
   $file .=$_;
}
close MAYPOLEIN;
open MAYPOLEMID, "> /Users/jtocci/Desktop/maypolemid.txt"
   or die "A problem occured ($!)";
$_ = $file;
s/\n\t//g;
s/\nSubject:/\n---------------------------------------------\nSubject:/
g;
print MAYPOLEMID $_;

close MAYPOLEMID;
open MAYPOLEMID, "/Users/jtocci/Desktop/maypolemid.txt"
   or die "A problem occured ($!)";

open MAYPOLEFINAL, "> /Users/jtocci/Desktop/maypolefin.txt"
   or die "A problem occured ($!)";

while (<MAYPOLEMID>) {
   unless ((/^Received:/) or (/^Message-ID:/) or (/^Mime-Version:/) or
(/^In-Reply-To:/) or (/^References:/) or (/^Message-Id:/) or (/^X-/) or
(/^Sender:/) or (/^Errors-To:/) or (/^Precedence:/) or (/^List-/) or
(/^Content-/) or (/^User-Agent:/) or (/^To:/)) {
     print MAYPOLEFINAL $_;
   }
}

----------------------------------
>
> Subject: RE: [Maypole] If you hated Maypole, you'll also dislike...
> Date: Wed, 21 Jul 2004 13:29:16 +0100
> MIME-Version: 1.0
>
> Hi there,
>
> I don't know if this is of any use, but I have been happily extending
> Maypole "horizontally" for a while using a very minor change to the
> existing
> framework.
>
> I guess I don't understand it, but I think the "rubberband" approach
> might
> be a bit complicated.
>
>
>
> What I did was to add "views" to the config which did not correspond to
> tables but which acted in the same way as existing model classes over
> tables.
>
> To have Maypole recognise & react to the views all you have to do is
> add the
> views to the ok_tables config entry in Maypole.pm
>
> $config->{ok_tables} = {map {$_ => 1} (@{$config->{display_tables}},
> @{$config->{views}}) };
>
> For example, in my website/database "Tennis" I have Players & Matches
> corresponding to tables. I also have an "Admin" view which has no
> associated
> table
>
> Tennis->config->{display_tables} = [qw[players matches]];
> Tennis->config->{views} = [qw[admin]];
>
>
> You then just write Tennis::Admin package with the same structure as
> the
> Tennis::Players or Tennis::Matches
>
> ------------------------------------------------------------------
>
> package Tennis3::Admin;
> use base 'Maypole::Model::CDBI';
> use strict;
>
> sub list :Exported(Protected) {
>
> my ($self, $r) = @_;$r->objects([ $self->search_current_matches()
> ]);$r->{template} = "list";
>
> }
>
> __PACKAGE__->set_sql(current_matches => qq {select date > now()
> "current"
> from matches});
>

_______________________________________________
maypole mailing list
maypole at lists.netthink.co.uk
http://lists.netthink.co.uk/listinfo/maypole



This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:57 GMT