[Bast-commits] r3388 - in trunk/Anything/lib: .
Anything/Controller/Test Anything/InterfaceModel
Anything/InterfaceModel/Items/Action
castaway at dev.catalyst.perl.org
castaway at dev.catalyst.perl.org
Mon May 28 20:46:19 GMT 2007
Author: castaway
Date: 2007-05-28 20:46:18 +0100 (Mon, 28 May 2007)
New Revision: 3388
Modified:
trunk/Anything/lib/Anything.pm
trunk/Anything/lib/Anything/Controller/Test/Item.pm
trunk/Anything/lib/Anything/InterfaceModel/Items.pm
trunk/Anything/lib/Anything/InterfaceModel/Items/Action/Create.pm
Log:
Recent updates
Modified: trunk/Anything/lib/Anything/Controller/Test/Item.pm
===================================================================
--- trunk/Anything/lib/Anything/Controller/Test/Item.pm 2007-05-28 18:30:18 UTC (rev 3387)
+++ trunk/Anything/lib/Anything/Controller/Test/Item.pm 2007-05-28 19:46:18 UTC (rev 3388)
@@ -10,43 +10,46 @@
# model_base => 'Anything',
model_base => 'Domain',
model_name => 'Items',
-# ActionForm_class => 'Anything::UI::ActionForm::Item',
+ 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));
+# $c->log->debug("DM: " . ref $target->_items_store);
## 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 = $target->_items_store->related_resultset('TypeID')->find({ID => $typeid});
+ 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});
+ 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,
- target_type => $target_type);
+ target_type => $target_type,
+ target_model => $target);
}
my $model_name = "Action::${name}".$self->model_name;
@@ -71,6 +74,8 @@
sub create :Chained('base') :PathPart('create') :Args() {
my ($self, $c, $typeid) = @_;
my $action = $self->get_model_action($c, 'Create', $self->get_collection($c), $typeid);
+# print STDERR $action->dump, "\n";
+# print STDERR $_->blessed for $action->meta->compute_all_applicable_attributes;
$self->push_viewport(
$self->ActionForm_class,
action => $action,
@@ -80,18 +85,18 @@
);
}
-sub view :Chained('object') :Args() {
- my ($self, $c) = @_;
- my $object :Stashed;
- my $action = $self->get_model_action($c, 'View', $object);
- my @cap = @{$c->req->captures};
- pop(@cap); # object id
- $self->push_viewport(
- $self->ObjectView_class,
- action => $action,
- column_order => [qw/Name Description/],
- );
-}
+# sub view :Chained('object') :Args() {
+# my ($self, $c) = @_;
+# my $object :Stashed;
+# my $action = $self->get_model_action($c, 'View', $object);
+# my @cap = @{$c->req->captures};
+# pop(@cap); # object id
+# $self->push_viewport(
+# $self->ObjectView_class,
+# action => $action,
+# column_order => [qw/Name Description/],
+# );
+# }
1;
Modified: trunk/Anything/lib/Anything/InterfaceModel/Items/Action/Create.pm
===================================================================
--- trunk/Anything/lib/Anything/InterfaceModel/Items/Action/Create.pm 2007-05-28 18:30:18 UTC (rev 3387)
+++ trunk/Anything/lib/Anything/InterfaceModel/Items/Action/Create.pm 2007-05-28 19:46:18 UTC (rev 3388)
@@ -17,23 +17,40 @@
my %args = @_;
return $super->($self, @_) if $self->meta->is_anon_class;
+ print STDERR "Inherits from $class\n";
my $action_meta = $self->meta->create_anon_class(superclasses => [$class]);
+# print STDERR "Self: $self\n";
+ # this one errors
+# $self->delayed_fields({});
my %delayed_fields;
for my $val ($args{target_type}->typefields->all){
- my $attr_name = $val->FieldID->Name;
+ my $attr_name = $val->FieldID->Name;
+ $DB::single=1;
+ print STDERR "Typefield: $attr_name " if($ENV{REACTION_DEBUG});
$attr_name =~ s/ /_/g; #TODO FIX FOR POSSIBLE COLLISIONS WHEN USING UNDERSCORES
- $delayed_fields{$attr_name} = $val;
+# {
+# local $SIG{__DIE__} = sub {
+# print STDERR Carp::longmess;
+# print STDERR join " // ", @_;
+# exit;
+ # this one doesnt
+# $self->delayed_fields->{$attr_name} = $val->FieldID->Name;
+ $delayed_fields{$attr_name} = $val->FieldID->Name;
$action_meta->add_attribute
($attr_name,
reader => 'get_field_{$attr_name}',
writer => 'set_field_{$attr_name}',
is => 'rw',
- isa => $val->TypeID->Name, #this will need fixing still
+ isa => $val->FieldID->TypeID->Name, #this will need fixing still
predicate => "has_field_${attr_name}",
required => 0
);
+# };
+# }
+ print STDERR "Done Typefield: $attr_name " if($ENV{REACTION_DEBUG});
+ print STDERR "Field: $attr_name, Type: ", $val->FieldID->TypeID->Name, "\n" if $ENV{REACTION_DEBUG};
}
my $obj = $action_meta->new_object(@_, delayed_fields => \%delayed_fields);
Modified: trunk/Anything/lib/Anything/InterfaceModel/Items.pm
===================================================================
--- trunk/Anything/lib/Anything/InterfaceModel/Items.pm 2007-05-28 18:30:18 UTC (rev 3387)
+++ trunk/Anything/lib/Anything/InterfaceModel/Items.pm 2007-05-28 19:46:18 UTC (rev 3388)
@@ -12,7 +12,7 @@
reflect_actions
(
-# Create => { attrs =>[qw(Name Description)] },
+ Create => { attrs =>[qw(Name Description)] },
Update => { attrs =>[qw(Name Description)] },
Delete => {},
);
Modified: trunk/Anything/lib/Anything.pm
===================================================================
--- trunk/Anything/lib/Anything.pm 2007-05-28 18:30:18 UTC (rev 3387)
+++ trunk/Anything/lib/Anything.pm 2007-05-28 19:46:18 UTC (rev 3388)
@@ -11,7 +11,8 @@
# -Debug: activates the debug mode for very useful log messages
# Static::Simple: will serve static files from the applications root directory
#
-use Catalyst qw/-Debug FormValidator StackTrace
+# StackTrace
+use Catalyst qw/-Debug FormValidator
ConfigLoader
Session
Session::State::Cookie
More information about the Bast-commits
mailing list