Discussion:
[cgi-prototype-users] Guestbook app in Rose::DB, CGI::Prototype::PathInfo, and Seamstress
Terrence Brannon
2005-09-10 02:11:32 UTC
Permalink
Since I could not beat Darren Duncan to first post, I had to beat him
to first complete app in Rose::DB::Object :). Other technologies were
Data::FormValidator, CGI::Prototype::PathInfo, and HTML::Seamstress.

I have implemented a cgi guestbook using Rose::DB::Object. Play with
it here:

http://www.metaperl.org/Guestbook

You can look at the Rose-based code here:

# db setup classes ...
http://www.metaperl.org/Guestbook/DB.pm
http://www.metaperl.org/Guestbook/Model.pm

# The row-class for the entry table
http://www.metaperl.org/Guestbook/Model/entry.pm

# The Manager-class for the entry table
http://www.metaperl.org/Guestbook/Model/entry/Manager.pm

# A class which uses the row and manager to unroll a table
http://www.metaperl.org/Guestbook/viewsrc/view

# A class which uses the row and manager to count a rowset
http://www.metaperl.org/Guestbook/viewsrc/stats

If you want to get the entire Guestbook app, then install darcs and
type:

darcs get http://www.metaperl.org

The thing I enjoyed about using Rose is that Class::DBI
*requires* that you give the primary key column when creating row
objects. With Rose, I just left it out and it formulated the right
SQL. DBIx::SQLEngine tried to put a NULL for the primary key column
when I left it out and I could not supply either DEFAULT or
nextval('seq_name') to it without it munging it in someway that
DBD::Pg would not accept.

I built the database schema using the excellent Alzabo schema
editor. Here is the schema (all one table of it):

http://www.metaperl.com/alzabo/schema/view_table.html?table=entry&schema=terry_guestbook


I'm sorry about how ugly the web app is: I'm reading my first book on
css and xhtml right now, so I expect that part to get prettier and
prettier the more I read :)
--
Carter's Compass: I know I'm on the right track when,
by deleting something, I'm adding functionality.
Terrence Brannon
2005-09-10 15:17:54 UTC
Permalink
I added a little more functionality to my guestbook to have it tar up
the whole site and send it. For some reason, I kept getting this error
in the Apache log

[Sat Sep 10 15:00:05 2005] [error] [client 24.130.176.67] malformed
header from script. Bad header=metaperl.org/:
/var/www/terry/metaperl.org/cgi-bin/Guestbook.cgi

and I googled and googled. At first I thought I need autoflush on but
that was not it. Then I looked at exactly when the error was occurring
and reazlied that it was right when I started to tar the file.

What was happening was that tar was issuing output to STDOUT and
apache was trying to interpret it as an HTTP header!

So my fix would be to silence tar or redirect the system command
output elswhere or use Archive::Tar from CPAN.

What a great way to spend 1.5 hours on a Sunday morn...
--
Carter's Compass: I know I'm on the right track when,
by deleting something, I'm adding functionality.
Loading...