[Bast-commits] r3346 - in trunk/Anything/lib: . Anything/Controller/Test DB

castaway at dev.catalyst.perl.org castaway at dev.catalyst.perl.org
Mon May 21 21:20:21 GMT 2007


Author: castaway
Date: 2007-05-21 21:20:20 +0100 (Mon, 21 May 2007)
New Revision: 3346

Modified:
   trunk/Anything/lib/Anything.pm
   trunk/Anything/lib/Anything/Controller/Test/Item.pm
   trunk/Anything/lib/DB/Anything.pm
Log:
More reactionising


Modified: trunk/Anything/lib/Anything/Controller/Test/Item.pm
===================================================================
--- trunk/Anything/lib/Anything/Controller/Test/Item.pm	2007-05-21 18:45:30 UTC (rev 3345)
+++ trunk/Anything/lib/Anything/Controller/Test/Item.pm	2007-05-21 20:20:20 UTC (rev 3346)
@@ -7,30 +7,48 @@
 use Anything::UI::ActionForm::Item;
   
 __PACKAGE__->config(
-                    model_base => 'Anything',
+#                    model_base => 'Anything',
+                    model_base => 'Domain',
                     model_name => 'Items',
 #                    ActionForm_class => 'Anything::UI::ActionForm::Item',
                     action => { base => { Chained => '/test/base', PathPart => 'item' } }
   );
 
-sub get_collection {
-  my ($self, $c, $typeid) = @_;
-  my $model = $c->model(join('::', $self->model_base, $self->model_name));
-  if(defined $typeid)
-  {
-      $model = $model->search({ TypeID => $typeid });
-#      $model = $model->TypeID;
-  }
-  return $model;
-}
+# sub get_collection {
+#   my ($self, $c, $typeid) = @_;
+#   my $model = $c->model(join('::', $self->model_base, $self->model_name));
+#   if(defined $typeid)
+#   {
+#       $model = $model->search({ TypeID => $typeid });
+# #      $model = $model->TypeID;
+#   }
+#   return $model;
+# }
 
 sub get_model_action {
   my ($self, $c, $name, $target, $typeid) = @_;
 
+  $c->log->debug("Target: $target, " . ref($target));
+  ## this attempts to inflate our type object into an items obj, oops
+#  my $target_type = $target->related_resultset('TypeID')->find({ID => $typeid});
+  my $target_type = $c->model('Anything::Type')->find({ID => $typeid});
+#   my $rel_rs = $target->related_resultset('TypeID');
+#   $c->log->debug("Rel result_class " . $rel_rs->result_source->result_class);
+#   $c->log->debug("Rel: " . ref($rel_rs));
+#   use MRO::Compat;
+#   my $linear_isa = mro::get_linear_isa(ref $rel_rs);
+#   $c->log->debug("ISA $_") for @$linear_isa;
+
+#   my $target_type = $rel_rs->find({ID => $typeid});
+  $c->log->debug("Target ID: $typeid");
+  $c->log->debug("Target ID: $target_type");
+
   if ($target->can('action_for')) {
-    return $target->action_for($name, ctx => $c);
+    return $target->action_for($name, 
+                               ctx => $c,
+                               target_type => $target_type);
   }
-  my $target_type = $target->related_resultset('TypeID')->find({ID => $typeid});
+
   my $model_name = "Action::${name}".$self->model_name;
   my $model = $c->model($model_name);
   confess "no such Model $model_name" unless $model;
@@ -39,57 +57,22 @@
                      ctx => $c);
 }
 
-# around get_model_action => sub {
-#     my $super = shift;
-#     my ($self, $c, $name, $target, $typeid) = @_;
-
-#     my $model = $super->(@_);
-#     $typeid ||= $model->target_model->TypeID->ID;
-#     my $tmodel = $model->target_model->result_source->schema->resultset('Type')->find($typeid);
-
-# #    {
-#         local $SIG{__DIE__} = sub {
-#             print STDERR Carp::longmess;
-#             print STDERR join " // ", @_;
-#             exit;
-#         };
-# #        sub undestroyable::DESTROY {
-# #            print STDERR Carp::longmess;
-# #            exit;
-# #        }
-# #        die bless {}, "undestroyable";
-# #        $c->log->info("Tmodel is ", ref($tmodel) . " (" . $tmodel->typefields->count . ")");
-# #    }
-#     $c->log->info("model is ", ref($model));
-#     foreach my $val ($tmodel->typefields->all)
-#     {
-# # has 'Some Attribute' => ( isa => 'ArrayRef', writer => sub { shift->value('Some Attribute', @_) }, is => 'rw', required => ?? );
-#         $c->log->debug("Adding attribute: " . $val->FieldID->Name . " ( isa => 'ArrayRef', is => 'rw', writer => sub { shift->value($val->FieldID->Name, @_) }, required => 1)");
-#         $model->meta->add_attribute($val->FieldID->Name, 
-#                                     ( isa => 'ArrayRef', is => 'rw', writer => { 'set_value' => sub { shift->value($val->FieldID->Name, @_) } }, required => 0)
-#                                     );
-        
-#     }
-    
-#     return $model;
-# };
-
-sub list :Chained('base') :PathPart('') :Args() {
-  my ($self, $c, $typeid) = @_;
+# sub list :Chained('base') :PathPart('') :Args() {
+#   my ($self, $c, $typeid) = @_;
   
-  $self->push_viewport(
-    $self->ListView_class, 
-    collection => $self->get_collection($c, $typeid),
-    exclude_columns => [qw/Created Modified/],
-    column_order => [qw/Name Description/],                   
-  );
-}
+#   $self->push_viewport(
+#     $self->ListView_class, 
+#     collection => $self->get_collection($c, $typeid),
+#     exclude_columns => [qw/Created Modified/],
+#     column_order => [qw/Name Description/],                   
+#   );
+# }
 
 sub create :Chained('base') :PathPart('create') :Args() {
   my ($self, $c, $typeid) = @_;
   my $action = $self->get_model_action($c, 'Create', $self->get_collection($c), $typeid);
   $self->push_viewport(
-    'Anything::UI::ActionForm::Item', # $self->ActionForm_class,
+    $self->ActionForm_class,
     action => $action,
     next_action => 'list',
     on_apply_callback => sub { $self->after_create_callback($c => @_); },

Modified: trunk/Anything/lib/Anything.pm
===================================================================
--- trunk/Anything/lib/Anything.pm	2007-05-21 18:45:30 UTC (rev 3345)
+++ trunk/Anything/lib/Anything.pm	2007-05-21 20:20:20 UTC (rev 3346)
@@ -20,7 +20,9 @@
   Authentication::Store::DBIC
   Authentication::Credential::Password
   Authorization::Roles
-    Static::Simple/;
+    Static::Simple
+    I18N
+/;
 
 our $VERSION = '0.01';
 
@@ -31,6 +33,7 @@
 #
 __PACKAGE__->config( name => 'Anything',
                      defaultaction => '/item/list',
+                     default_view => 'TToolkit',
 #                     DSN => 'dbi:SQLite:db/books.db', 
 #                     DSN => 'dbi:SQLite:db/webkb.db', 
                      DSN => 'dbi:mysql:stuff',
@@ -65,7 +68,7 @@
                      'authentication' => { dbic => {
                          'dbic_schema'    => 'Anything::Model::Anything',
                          'catalyst_user_class' => 'Anything::Store::DBIC::User',
-                         'user_class' => 'Items',
+                         'user_class' => 'Anything::Items',
                          'user_field' => 'username',
                          'password_field' => 'password',
                          password_type    => 'clear',
@@ -74,7 +77,12 @@
                      'authorization' => { dbic => {
                          role_field       => 'role',
                      },
-                                      }
+                                      },
+                     'Controller::Test' => {
+                         view_name => 'XHTML',
+                         window_title => 'Edit Item',
+                     },
+                     
                      );
 
 #
@@ -83,7 +91,8 @@
 __PACKAGE__->setup;
 
 __PACKAGE__->config->{authentication}{dbic}{dbic_schema} = 
-    __PACKAGE__->comp('DB::Anything');
+#    __PACKAGE__->comp('DB::Anything');
+    __PACKAGE__->model('Anything');
 
 Class::C3->reinitialize;
 
@@ -114,6 +123,18 @@
 {
     my ( $self, $c ) = @_;
 #    $c->stash->{types} = [ $c->comp('DB::Anything')->menu_list(undef, undef, $c->check_user_roles('Admin')) ];
+
+# { 
+#     local $SIG{__DIE__} = sub {
+#         print STDERR Carp::longmess;
+#         print STDERR join " // ", @_;
+#         exit;
+#     };
+    
+#     $c->model('Anything')->storage->ensure_connected;
+# }
+
+
     $c->stash->{types} = [ $c->model('Anything')->menu_list(undef, undef, $c->check_user_roles('Admin')) ];
     $c->stash->{page_title} = '';
     
@@ -131,6 +152,7 @@
         my $type = $c->model('Anything')->resultset('Type')->
 #        my $type = $c->comp('DB::Anything')->resultset('Type')->
           find({Name => ucfirst($type)});
+        $c->log->debug("Found type ? $type");
         if($type)
         {
             my $item = $c->model('Anything')->resultset('Items')->
@@ -145,6 +167,7 @@
         }
     }
 
+    $c->log->debug("auto: returning true");
     return 1;
 }
 

Modified: trunk/Anything/lib/DB/Anything.pm
===================================================================
--- trunk/Anything/lib/DB/Anything.pm	2007-05-21 18:45:30 UTC (rev 3345)
+++ trunk/Anything/lib/DB/Anything.pm	2007-05-21 20:20:20 UTC (rev 3346)
@@ -1,6 +1,6 @@
 
 package DB::Anything::Type;
-use base 'DBIx::Class';
+use base qw/DBIx::Class Reaction::Object/;
 use strict;
 use warnings;
 use Reaction::Class;
@@ -121,7 +121,7 @@
 
 
 package DB::Anything::Items;
-use base 'DBIx::Class';
+use base qw/DBIx::Class Reaction::Object/;
 use strict;
 use warnings;
 use Reaction::Class;




More information about the Bast-commits mailing list