[Catalyst-commits] r6434 - in trunk/Catalyst-Engine-Wx: . demo
demo/lib demo/lib/SampleApp demo/lib/SampleApp/Controller
demo/lib/SampleApp/Model demo/lib/SampleApp/View
demo/lib/SampleAppDB demo/lib/SampleAppWx
eriam at dev.catalyst.perl.org
eriam at dev.catalyst.perl.org
Sun May 27 13:06:24 GMT 2007
Author: eriam
Date: 2007-05-27 13:06:23 +0100 (Sun, 27 May 2007)
New Revision: 6434
Added:
trunk/Catalyst-Engine-Wx/demo/
trunk/Catalyst-Engine-Wx/demo/db.sql
trunk/Catalyst-Engine-Wx/demo/lib/
trunk/Catalyst-Engine-Wx/demo/lib/MyAppDB.pm
trunk/Catalyst-Engine-Wx/demo/lib/SampleApp.pm
trunk/Catalyst-Engine-Wx/demo/lib/SampleApp/
trunk/Catalyst-Engine-Wx/demo/lib/SampleApp/Controller/
trunk/Catalyst-Engine-Wx/demo/lib/SampleApp/Controller/Root.pm
trunk/Catalyst-Engine-Wx/demo/lib/SampleApp/Model/
trunk/Catalyst-Engine-Wx/demo/lib/SampleApp/Model/SampleAppDB.pm
trunk/Catalyst-Engine-Wx/demo/lib/SampleApp/View/
trunk/Catalyst-Engine-Wx/demo/lib/SampleApp/View/Wx.pm
trunk/Catalyst-Engine-Wx/demo/lib/SampleAppDB.pm
trunk/Catalyst-Engine-Wx/demo/lib/SampleAppDB/
trunk/Catalyst-Engine-Wx/demo/lib/SampleAppDB/Author.pm
trunk/Catalyst-Engine-Wx/demo/lib/SampleAppDB/Book.pm
trunk/Catalyst-Engine-Wx/demo/lib/SampleAppDB/BookAuthor.pm
trunk/Catalyst-Engine-Wx/demo/lib/SampleAppWx/
trunk/Catalyst-Engine-Wx/demo/lib/SampleAppWx/default.pm
trunk/Catalyst-Engine-Wx/demo/sampleapp.db
trunk/Catalyst-Engine-Wx/demo/wx.pl
Log:
Added a demo.
Added: trunk/Catalyst-Engine-Wx/demo/db.sql
===================================================================
--- trunk/Catalyst-Engine-Wx/demo/db.sql (rev 0)
+++ trunk/Catalyst-Engine-Wx/demo/db.sql 2007-05-27 12:06:23 UTC (rev 6434)
@@ -0,0 +1,45 @@
+--
+-- Create a very simple database to hold book and author information
+--
+CREATE TABLE books (
+ id INTEGER PRIMARY KEY,
+ title TEXT ,
+ rating INTEGER
+);
+
+-- 'book_authors' is a many-to-many join table between books & authors
+CREATE TABLE book_authors (
+ book_id INTEGER,
+ author_id INTEGER,
+ PRIMARY KEY (book_id, author_id)
+);
+
+CREATE TABLE authors (
+ id INTEGER PRIMARY KEY,
+ first_name TEXT,
+ last_name TEXT
+);
+---
+--- Load some sample data
+---
+INSERT INTO books VALUES (1, 'CCSP SNRS Exam Certification Guide', 5);
+INSERT INTO books VALUES (2, 'TCP/IP Illustrated, Volume 1', 5);
+INSERT INTO books VALUES (3, 'Internetworking with TCP/IP Vol.1', 4);
+INSERT INTO books VALUES (4, 'Perl Cookbook', 5);
+INSERT INTO books VALUES (5, 'Designing with Web Standards', 5);
+INSERT INTO authors VALUES (1, 'Greg', 'Bastien');
+INSERT INTO authors VALUES (2, 'Sara', 'Nasseh');
+INSERT INTO authors VALUES (3, 'Christian', 'Degu');
+INSERT INTO authors VALUES (4, 'Richard', 'Stevens');
+INSERT INTO authors VALUES (5, 'Douglas', 'Comer');
+INSERT INTO authors VALUES (6, 'Tom', 'Christiansen');
+INSERT INTO authors VALUES (7, ' Nathan', 'Torkington');
+INSERT INTO authors VALUES (8, 'Jeffrey', 'Zeldman');
+INSERT INTO book_authors VALUES (1, 1);
+INSERT INTO book_authors VALUES (1, 2);
+INSERT INTO book_authors VALUES (1, 3);
+INSERT INTO book_authors VALUES (2, 4);
+INSERT INTO book_authors VALUES (3, 5);
+INSERT INTO book_authors VALUES (4, 6);
+INSERT INTO book_authors VALUES (4, 7);
+INSERT INTO book_authors VALUES (5, 8);
Added: trunk/Catalyst-Engine-Wx/demo/lib/MyAppDB.pm
===================================================================
--- trunk/Catalyst-Engine-Wx/demo/lib/MyAppDB.pm (rev 0)
+++ trunk/Catalyst-Engine-Wx/demo/lib/MyAppDB.pm 2007-05-27 12:06:23 UTC (rev 6434)
@@ -0,0 +1,10 @@
+package MyAppDB;
+
+# Our schema needs to inherit from 'DBIx::Class::Schema'
+use base qw/DBIx::Class::Schema/;
+
+__PACKAGE__->load_classes({
+ MyAppDB => [qw/Book BookAuthor Author/]
+});
+
+1;
\ No newline at end of file
Added: trunk/Catalyst-Engine-Wx/demo/lib/SampleApp/Controller/Root.pm
===================================================================
--- trunk/Catalyst-Engine-Wx/demo/lib/SampleApp/Controller/Root.pm (rev 0)
+++ trunk/Catalyst-Engine-Wx/demo/lib/SampleApp/Controller/Root.pm 2007-05-27 12:06:23 UTC (rev 6434)
@@ -0,0 +1,21 @@
+package SampleApp::Controller::Root;
+
+use strict;
+use warnings;
+use base 'Catalyst::Controller';
+use Test::More;
+
+__PACKAGE__->config->{namespace} = '';
+
+sub default : Private {
+ my ( $self, $c ) = @_;
+
+ $c->stash->{books} = [$c->model('SampleAppDB::Book')->all];
+
+ $c->forward('SampleApp::View::Wx');
+ print $ENV{CATALYST_ENGINE}."\n";
+ #$c->forward('SampleApp::View::TT');
+
+}
+
+1;
Property changes on: trunk/Catalyst-Engine-Wx/demo/lib/SampleApp/Controller/Root.pm
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/Catalyst-Engine-Wx/demo/lib/SampleApp/Model/SampleAppDB.pm
===================================================================
--- trunk/Catalyst-Engine-Wx/demo/lib/SampleApp/Model/SampleAppDB.pm (rev 0)
+++ trunk/Catalyst-Engine-Wx/demo/lib/SampleApp/Model/SampleAppDB.pm 2007-05-27 12:06:23 UTC (rev 6434)
@@ -0,0 +1,17 @@
+package SampleApp::Model::SampleAppDB;
+
+use strict;
+use base 'Catalyst::Model::DBIC::Schema';
+
+__PACKAGE__->config(
+ schema_class => 'SampleAppDB',
+ connect_info => [
+ "dbi:SQLite:dbname=sampleapp.db",
+ "",
+ "",
+ {AutoCommit => 1}
+ ]
+);
+
+
+1;
Added: trunk/Catalyst-Engine-Wx/demo/lib/SampleApp/View/Wx.pm
===================================================================
--- trunk/Catalyst-Engine-Wx/demo/lib/SampleApp/View/Wx.pm (rev 0)
+++ trunk/Catalyst-Engine-Wx/demo/lib/SampleApp/View/Wx.pm 2007-05-27 12:06:23 UTC (rev 6434)
@@ -0,0 +1,12 @@
+package SampleApp::View::Wx;
+
+use strict;
+use base 'Catalyst::View::Wx';
+
+__PACKAGE__->config({
+ NAMESPACE => 'SampleAppWx',
+ CATALYST_VAR => 'Catalyst',
+});
+
+
+1;
Property changes on: trunk/Catalyst-Engine-Wx/demo/lib/SampleApp/View/Wx.pm
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/Catalyst-Engine-Wx/demo/lib/SampleApp.pm
===================================================================
--- trunk/Catalyst-Engine-Wx/demo/lib/SampleApp.pm (rev 0)
+++ trunk/Catalyst-Engine-Wx/demo/lib/SampleApp.pm 2007-05-27 12:06:23 UTC (rev 6434)
@@ -0,0 +1,11 @@
+package SampleApp;
+
+use strict;
+use warnings;
+
+use Catalyst::Runtime '5.70';
+use Catalyst;
+
+our $VERSION = '0.01';
+
+1;
Property changes on: trunk/Catalyst-Engine-Wx/demo/lib/SampleApp.pm
___________________________________________________________________
Name: svn:executable
+ *
Added: trunk/Catalyst-Engine-Wx/demo/lib/SampleAppDB/Author.pm
===================================================================
--- trunk/Catalyst-Engine-Wx/demo/lib/SampleAppDB/Author.pm (rev 0)
+++ trunk/Catalyst-Engine-Wx/demo/lib/SampleAppDB/Author.pm 2007-05-27 12:06:23 UTC (rev 6434)
@@ -0,0 +1,23 @@
+package SampleAppDB::Author;
+
+use base qw/DBIx::Class/;
+
+# Load required DBIC stuff
+__PACKAGE__->load_components(qw/PK::Auto Core/);
+# Set the table name
+__PACKAGE__->table('authors');
+# Set columns in table
+__PACKAGE__->add_columns(qw/id first_name last_name/);
+# Set the primary key for the table
+__PACKAGE__->set_primary_key(qw/id/);
+
+#
+# Set relationships:
+#
+
+__PACKAGE__->has_many(book_author => 'SampleAppDB::BookAuthor', 'author_id');
+
+__PACKAGE__->many_to_many(books => 'book_author', 'book');
+
+
+1;
\ No newline at end of file
Added: trunk/Catalyst-Engine-Wx/demo/lib/SampleAppDB/Book.pm
===================================================================
--- trunk/Catalyst-Engine-Wx/demo/lib/SampleAppDB/Book.pm (rev 0)
+++ trunk/Catalyst-Engine-Wx/demo/lib/SampleAppDB/Book.pm 2007-05-27 12:06:23 UTC (rev 6434)
@@ -0,0 +1,22 @@
+package SampleAppDB::Book;
+
+use base qw/DBIx::Class/;
+
+# Load required DBIC stuff
+__PACKAGE__->load_components(qw/PK::Auto Core/);
+# Set the table name
+__PACKAGE__->table('books');
+# Set columns in table
+__PACKAGE__->add_columns(qw/id title rating/);
+# Set the primary key for the table
+__PACKAGE__->set_primary_key(qw/id/);
+
+#
+# Set relationships:
+#
+
+__PACKAGE__->has_many(book_authors => 'SampleAppDB::BookAuthor', 'book_id');
+
+__PACKAGE__->many_to_many(authors => 'book_authors', 'author');
+
+1;
\ No newline at end of file
Added: trunk/Catalyst-Engine-Wx/demo/lib/SampleAppDB/BookAuthor.pm
===================================================================
--- trunk/Catalyst-Engine-Wx/demo/lib/SampleAppDB/BookAuthor.pm (rev 0)
+++ trunk/Catalyst-Engine-Wx/demo/lib/SampleAppDB/BookAuthor.pm 2007-05-27 12:06:23 UTC (rev 6434)
@@ -0,0 +1,22 @@
+package SampleAppDB::BookAuthor;
+
+use base qw/DBIx::Class/;
+
+# Load required DBIC stuff
+__PACKAGE__->load_components(qw/PK::Auto Core/);
+# Set the table name
+__PACKAGE__->table('book_authors');
+# Set columns in table
+__PACKAGE__->add_columns(qw/book_id author_id/);
+# Set the primary key for the table
+__PACKAGE__->set_primary_key(qw/book_id author_id/);
+
+#
+# Set relationships:
+#
+__PACKAGE__->belongs_to(book => 'SampleAppDB::Book', 'book_id');
+
+__PACKAGE__->belongs_to(author => 'SampleAppDB::Author', 'author_id');
+
+
+1;
\ No newline at end of file
Added: trunk/Catalyst-Engine-Wx/demo/lib/SampleAppDB.pm
===================================================================
--- trunk/Catalyst-Engine-Wx/demo/lib/SampleAppDB.pm (rev 0)
+++ trunk/Catalyst-Engine-Wx/demo/lib/SampleAppDB.pm 2007-05-27 12:06:23 UTC (rev 6434)
@@ -0,0 +1,10 @@
+package SampleAppDB;
+
+# Our schema needs to inherit from 'DBIx::Class::Schema'
+use base qw/DBIx::Class::Schema/;
+
+__PACKAGE__->load_classes({
+ SampleAppDB => [qw/Book BookAuthor Author/]
+});
+
+1;
\ No newline at end of file
Added: trunk/Catalyst-Engine-Wx/demo/lib/SampleAppWx/default.pm
===================================================================
--- trunk/Catalyst-Engine-Wx/demo/lib/SampleAppWx/default.pm (rev 0)
+++ trunk/Catalyst-Engine-Wx/demo/lib/SampleAppWx/default.pm 2007-05-27 12:06:23 UTC (rev 6434)
@@ -0,0 +1,50 @@
+package SampleAppWx::default;
+
+use strict;
+use warnings;
+
+use Wx ':everything';
+use Catalyst::Engine::Wx::Event qw(EVT EVT_QUIT EVT_CLOSE);
+
+use base 'Wx::Frame';
+
+sub new {
+ my ($class, $catalyst, $c ) = @_;
+
+ my $self = $class->SUPER::new( undef, -1, 'Books', [0, 0], [475,300] );
+
+ my $list_ctrl = Wx::ListCtrl->new($self,-1,[3,3],[20,20],
+ wxSIMPLE_BORDER|wxSUNKEN_BORDER|wxSTATIC_BORDER|wxLC_REPORT|wxLC_ALIGN_LEFT|wxLC_HRULES);
+
+ $list_ctrl->InsertColumn( 0, "Title" );
+ $list_ctrl->InsertColumn( 1, "Rating" );
+ $list_ctrl->InsertColumn( 2, "Authors" );
+
+ $self->Refresh();
+ $self->Show(1);
+
+ my $i = 0;
+ foreach (@{ $c->stash->{books} }) {
+ my $idx_1 = $list_ctrl->InsertStringItem( $i, $_->title );
+ $list_ctrl->SetItem( $idx_1, 1, $_->rating );
+
+ my $authors;
+ foreach my $author ( $_->authors ) {
+ $authors .= $author->first_name." ".$author->last_name.", ";
+
+ }
+ chop($authors);
+ chop($authors);
+
+ $list_ctrl->SetItem( $idx_1, 2, $authors );
+ }
+
+ $list_ctrl->SetColumnWidth(0, -1);
+ $list_ctrl->SetColumnWidth(2, -1);
+
+ EVT_CLOSE( $self, sub { EVT_QUIT; } );
+
+ return 1;
+}
+
+1;
Added: trunk/Catalyst-Engine-Wx/demo/sampleapp.db
===================================================================
(Binary files differ)
Property changes on: trunk/Catalyst-Engine-Wx/demo/sampleapp.db
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/Catalyst-Engine-Wx/demo/wx.pl
===================================================================
--- trunk/Catalyst-Engine-Wx/demo/wx.pl (rev 0)
+++ trunk/Catalyst-Engine-Wx/demo/wx.pl 2007-05-27 12:06:23 UTC (rev 6434)
@@ -0,0 +1,24 @@
+
+BEGIN {
+ use lib "./lib";
+
+ $ENV{CATALYST_ENGINE} ||= 'Wx';
+ require Catalyst::Engine::Wx;
+}
+
+use strict;
+use warnings;
+
+require SampleApp;
+
+SampleApp->config(
+ name => 'SampleApp',
+);
+
+SampleApp->setup;
+
+SampleApp->run({
+ bootstrap => '/',
+});
+
+1;
More information about the Catalyst-commits
mailing list