[Maypole] New user (pt 2?)
Marcello
m.romani@spinsoft.it
Mon, 28 Feb 2005 17:19:26 +0100
Imran ha scritto:
> Hello again,
>
> Quite a while ago I wrote a simple frontend to a simple db. I think all I did
> was modify the beerdb example. my db was very similiar db wise. Got confused
> with some bugs, I think. and then I couldn't figure out how to sort the
> columns in my own order (it does it alphabetically).
>
> Anyway, decided to do it again (2.09 or whatever is latest as of couple of
> days ago) but use one table. I have a jokes section on my site, and wanted to
> just create an admin for it. I'm using mod_perl. and proxying the app to
> real server (didn't want restarts affecting real server).
>
> Location for the PerlHandler is /perl/jokes/. doc root is /web/niazi, have
> templates from the maypole distribution in /web/niazi/perl/jokes (no subdirs).
> and the code is at the bottom. (After writing this email, adding this: My
> questions are both 'what is the right answer', but also 'Where do the docs
> show this answer?') First of all if I browse to /perl/jokes/ it shows the
> 'poorly configured' maypole page. All good so far. There is one link "List by
> joke", since I only specified one table. But its a broken link:
> http://www.niazi.net/perl/joke/list
>
> What did I do wrong? It should be
> "http://www.niazi.net/perl/jokes/joke/list". Or atleast that works. (ok, i
> figured this out... forgot '/' at the end of uri_base. but in my defense i
> was following the example).
>
> Also the maypole.css was in the same dir as the template files. but the link
> it points to is '/maypole.css' which is the webroot. the factory templates
> shouldn't root the maypole.css. should be relative.
>
> How do I figure out what different untaint_columns types there are? from the
> documentation i mean. I think the only ones I could figure out from searching
> the web or reading the example, or searching for untaint from all the manual
> pages off of pod documentation) is the printable, integer and date. I guess
> what i'm curious about is if there is an enum type or something. That
> automagically does a pull down.
>
> And of course, how DO i set the column sort type. and is that explained in
> the docs... etc.
>
> Oh, one more thing, shouldn't maypole ignore tables that don't appear in
> display_tables, and no other relationships exist with those tables. Had to
> put the table all by itself, to get the example to work.
>
> After I get comfortable with this, i want to get a many-to-many relationship
> to work. And then figure out to the good stuff.
>
> Oh, also, the simple thing that I have working... its very slow. mod_perl+DBI
> applications i've written are really fast. almost like I'm getting static
> files. but maypole runs as fast as most cgi stuff runs. maybe even slightly
> slower. I have a small script that uses class::dbi & template tookit to
> generate my jokes pages (simple stuff I wrote to learn cdbi & tt), and thats
> extremely slow to run (for what it does). But its a commandline thing that
> generates pages, and I understand TT will run quicker persistently (since it
> will compile the templates etc). Or is it just the example templates are
> really slow? but not sure what would be different (or atleast what would be
> less...)
Maypole speed is an issue for me too.
I think the problem is not in maypole itself but in how
class::dbi::pager handles pagination.
From what I understood so far, if you have 100 records and want to
display 10 of them per page, the whole recordset gets loaded in memory
(so you get 100 objects in memory, with foreing keys columns inflated,
etc.), then the 80 non relevant object get discarded.
This causes a lot of CPU and memory consumption.
A first optimization is to use the 'lazy population' cdbi feature.
I have to admit it did not much for me, but maybe I only have to better
understand the relationship between 'Essential' columns and column
inflation...
I substituted Class::DBI::Pager with Class::DBI::Plugin::Pager, which
makes use of the LIMIT clause when working with MySQL, but did so in a
very simple beerdb sample app, and I didn't notice any significant
speedup. Have to try it on the production app (which has tables with
1000s of records and 10s of inflated columns) and see what happens.
HTH, HAND
Marcello
>
> Any example sites that are using maypole? Or even class::dbi + TT based
> dynamic sites?
>
> Thanks for reading and/or replying to this... :)
>
> Imran
>
> -------
> package Naweb::JokesAdmin;
>
> #use base 'Maypole::Application';
> use Maypole::Application;
>
> __PACKAGE__->setup("dbi:mysql:jokes","usr","pass");
> __PACKAGE__->config->uri_base("http://www.niazi.net/perl/jokes");
> __PACKAGE__->config->template_root("/web/niazi/perl/jokes");
> __PACKAGE__->config->rows_per_page(20);
> __PACKAGE__->config->display_tables([qw[joke]]);
>
> Naweb::JokesAdmin::Joke->untaint_columns(
> printable => [qw/joke_type rating credit title content answer/],
> date => [ qw/date/ ] );
>
>
> _______________________________________________
> maypole mailing list
> maypole@lists.netthink.co.uk
> http://lists.netthink.co.uk/listinfo/maypole
>