[Catalyst-commits] r8726 - trunk/examples/CatalystAdvent/root/2008
dhoss at dev.catalyst.perl.org
dhoss at dev.catalyst.perl.org
Fri Dec 5 01:59:14 GMT 2008
Author: dhoss
Date: 2008-12-05 01:59:14 +0000 (Fri, 05 Dec 2008)
New Revision: 8726
Modified:
trunk/examples/CatalystAdvent/root/2008/5.pod
Log:
applied patch, sort of
Modified: trunk/examples/CatalystAdvent/root/2008/5.pod
===================================================================
--- trunk/examples/CatalystAdvent/root/2008/5.pod 2008-12-05 01:41:19 UTC (rev 8725)
+++ trunk/examples/CatalystAdvent/root/2008/5.pod 2008-12-05 01:59:14 UTC (rev 8726)
@@ -40,7 +40,7 @@
Create a controller in your application called Photos as follows:
- perl script/*create.pl controller Photos
+ perl script/myapp_create.pl controller Photos
Next, you'll want to set up a table called Photos in your RDBMS of
choice. Here, I've used MySQL, but you could use SQLite , Postresql
@@ -63,6 +63,20 @@
null: no
other:
+=item mime
+
+type: VARCHAR
+size: 255
+null: no
+other:
+
+=item mime
+
+type: VARCHAR
+size: 255
+null: no
+other:
+
=item uploaded
type: DATETIME
@@ -117,10 +131,21 @@
},
[ "dbi:mysql:myapp", "user", "password" ]
);
-
-now run perl script/*update*. If there are no errors, proceed!
+now run this script:
+ perl script/myapp_update_schema.pl
+ MyApp::Schema::Photos->load_components(
+ "InflateColumn::DateTime",
+ "InflateColumn::FS",
+ ...
+ MyApp::Schema::Photos->set_primary_key("photoid");
+ MyApp::Schema::Photos->add_unique_constraint("photos_pkey", ["photoid"]);
+ Dumping manual schema for MyApp::Schema to directory /tmp/MyApp/script/../lib ...
+ Schema dump completed.
+
+If there are no errors, proceed!
+
=head2 Adding the InflateColumn::FS magic
Open up lib/Schema/Photos.pm. Since we used ::Loader, there will be a
@@ -232,7 +257,7 @@
my $mime = MIME::Types->new;
## comment out this block if you're not using the Authorization plugin
- unless ( $c->check_user_roles('admin') ) {
+ if ( $c->can('check_user_roles') && !$c->check_user_roles('admin') ) {
$c->flash->{error_msg} =
"You don't have the proper permissions to add photos here";
@@ -377,15 +402,14 @@
}
}
+
1;
-
-
=head2 The view:
=over 12
-=item add.tt2
+=item root/photos/add.tt2
<h2>Upload your photos</h2>
[% UNLESS form.submitted_and_valid %]
@@ -398,7 +422,7 @@
[% END %]
-=item delete.tt2
+=item root/photos/delete.tt2
[% UNLESS c.req.param('delete') %]
<h2>Deleting [% photo.name %]</h2>
@@ -413,7 +437,7 @@
<p>Deleted!</p>
[% END %]
-=item index.tt2
+=item root/photos/index.tt2
[% USE table (photos, rows=3) %]
<h2>Puppy Photos</h2>
@@ -438,9 +462,8 @@
<table>
</div>
+=item root/photos/view.tt2
-=item view.tt2
-
<h2>[% photo.name %]</h2>
<div id="photo">
<img src="[% c.uri_for("/photo/$photo.photoid/generate") %]" alt="[% photo.name %]" />
@@ -448,14 +471,13 @@
<p>[% photo.caption %]</p>
<div>«<a href="[% c.uri_for("/photos") %]">back</a>
-
=head2 FormFu
And last but not least, the required HTML::FormFu files:
=over 12
-=item add.yml
+=item root/forms/photos/add.yml
---
indicator: submit
More information about the Catalyst-commits
mailing list