diff options
author | groditi <groditi@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7> | 2007-10-23 16:58:00 +0000 |
---|---|---|
committer | groditi <groditi@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7> | 2007-10-23 16:58:00 +0000 |
commit | a4f82080351c17ad76981742a8e45231781f75fe (patch) | |
tree | 1bbf7847aac7891f1e32b951cd780e3cc12913bd | |
parent | f272565b546b9c07bc251eb0e998e8b2b4b6d19d (diff) | |
download | reaction-a4f82080351c17ad76981742a8e45231781f75fe.tar.gz reaction-a4f82080351c17ad76981742a8e45231781f75fe.zip |
CRUDController syntax changed to be less retarded and Reflector::DBIC fixed to use DeleteAll action
-rw-r--r-- | lib/Catalyst/Model/Reaction/InterfaceModel/DBIC.pm | 15 | ||||
-rw-r--r-- | lib/ComponentUI/Controller/TestModel/Bar.pm | 4 | ||||
-rw-r--r-- | lib/ComponentUI/Controller/TestModel/Baz.pm | 4 | ||||
-rw-r--r-- | lib/ComponentUI/Controller/TestModel/Foo.pm | 4 | ||||
-rw-r--r-- | lib/ComponentUI/View/Site/Widget/Layout.pm | 3 | ||||
-rw-r--r-- | lib/Reaction/InterfaceModel/Reflector/DBIC.pm | 8 | ||||
-rw-r--r-- | lib/Reaction/UI/CRUDController.pm | 10 | ||||
-rw-r--r-- | lib/Reaction/UI/View.pm | 2 | ||||
-rw-r--r-- | lib/Reaction/UI/Widget/ActionForm.pm | 1 |
9 files changed, 21 insertions, 30 deletions
diff --git a/lib/Catalyst/Model/Reaction/InterfaceModel/DBIC.pm b/lib/Catalyst/Model/Reaction/InterfaceModel/DBIC.pm index bd75604..6b59e29 100644 --- a/lib/Catalyst/Model/Reaction/InterfaceModel/DBIC.pm +++ b/lib/Catalyst/Model/Reaction/InterfaceModel/DBIC.pm @@ -20,9 +20,6 @@ class DBIC, is 'Reaction::Object', is 'Catalyst::Component', which { my $im_class = $cfg{im_class}; Class::MOP::load_class($im_class); - my $model_name = $class; - $model_name =~ s/^[\w:]+::(?:Model|M):://; - #XXXthis could be cut out later for a more elegant method my @domain_models = $im_class->domain_models; confess "Unable to locate domain model in ${im_class}" @@ -33,18 +30,6 @@ class DBIC, is 'Reaction::Object', is 'Catalyst::Component', which { my $schema_class = $domain_model->_isa_metadata; Class::MOP::load_class($schema_class); - { - #I should probably MOPize this at some point maybe? nahhhh - #XXXMaybe I should just fix CRUDController and eliminate this shit period. - #pure bloat and namespace pollution - no strict 'refs'; - foreach my $collection ( $im_class->parameter_attributes ){ - my $classname = join '::', $class, $collection->name, 'ACCEPT_CONTEXT'; - my $reader = $collection->get_read_method; - *$classname = sub{ $_[1]->model($model_name)->$reader }; - } - } - my $params = $cfg{db_params} || {}; my $schema = $schema_class ->connect($cfg{db_dsn}, $cfg{db_user}, $cfg{db_password}, $params); diff --git a/lib/ComponentUI/Controller/TestModel/Bar.pm b/lib/ComponentUI/Controller/TestModel/Bar.pm index 644a20f..f3140ee 100644 --- a/lib/ComponentUI/Controller/TestModel/Bar.pm +++ b/lib/ComponentUI/Controller/TestModel/Bar.pm @@ -4,8 +4,8 @@ use base 'Reaction::UI::CRUDController'; use Reaction::Class; __PACKAGE__->config( - model_base => 'TestModel', - model_name => 'Bar', + model_name => 'TestModel', + collection_name => 'Bar', action => { base => { Chained => '/base', PathPart => 'testmodel/bar' }}, ); diff --git a/lib/ComponentUI/Controller/TestModel/Baz.pm b/lib/ComponentUI/Controller/TestModel/Baz.pm index ada76e4..a49c452 100644 --- a/lib/ComponentUI/Controller/TestModel/Baz.pm +++ b/lib/ComponentUI/Controller/TestModel/Baz.pm @@ -4,8 +4,8 @@ use base 'Reaction::UI::CRUDController'; use Reaction::Class; __PACKAGE__->config( - model_base => 'TestModel', - model_name => 'Baz', + model_name => 'TestModel', + collection_name => 'Baz', action => { base => { Chained => '/base', PathPart => 'testmodel/baz' } }, ); diff --git a/lib/ComponentUI/Controller/TestModel/Foo.pm b/lib/ComponentUI/Controller/TestModel/Foo.pm index 846223e..3477e0f 100644 --- a/lib/ComponentUI/Controller/TestModel/Foo.pm +++ b/lib/ComponentUI/Controller/TestModel/Foo.pm @@ -4,8 +4,8 @@ use base 'Reaction::UI::CRUDController'; use Reaction::Class; __PACKAGE__->config( - model_base => 'TestModel', - model_name => 'Foo', + model_name => 'TestModel', + collection_name => 'Foo', action => { base => { Chained => '/base', PathPart => 'testmodel/foo' } }, ); diff --git a/lib/ComponentUI/View/Site/Widget/Layout.pm b/lib/ComponentUI/View/Site/Widget/Layout.pm index 380a03a..5d1b57c 100644 --- a/lib/ComponentUI/View/Site/Widget/Layout.pm +++ b/lib/ComponentUI/View/Site/Widget/Layout.pm @@ -4,8 +4,7 @@ use Reaction::UI::WidgetClass; class Layout which { - widget renders [ qw(menu sidebar header main_content) => - { viewport => func('self', 'viewport') } ]; + widget renders [ qw(menu sidebar header main_content) ]; menu renders [ string { "DUMMY" } ]; sidebar renders [ string { "Sidebar Shit" } ]; diff --git a/lib/Reaction/InterfaceModel/Reflector/DBIC.pm b/lib/Reaction/InterfaceModel/Reflector/DBIC.pm index fca7fa5..326770f 100644 --- a/lib/Reaction/InterfaceModel/Reflector/DBIC.pm +++ b/lib/Reaction/InterfaceModel/Reflector/DBIC.pm @@ -43,8 +43,10 @@ class DBIC, which { }; implements build_builtin_collection_actions => as { - { Create => {name => 'Create', base => Create } }; - { DeleteAll => {name => 'DeleteAll', base => DeleteAll } }; + { + Create => {name => 'Create', base => Create }, + DeleteAll => {name => 'DeleteAll', base => DeleteAll } + }; }; implements _all_object_actions => as { @@ -299,7 +301,7 @@ class DBIC, which { unless( $reader ){ $reader = $source; $reader =~ s/([a-z0-9])([A-Z])/${1}_${2}/g ; - $reader = lc($reader) . "_collection"; + $reader = lc($reader) . "_collection"; #XXX change to not use _collection ? } unless( $dm_name ){ my @haystack = $meta->domain_models; diff --git a/lib/Reaction/UI/CRUDController.pm b/lib/Reaction/UI/CRUDController.pm index 6720cf4..f416c93 100644 --- a/lib/Reaction/UI/CRUDController.pm +++ b/lib/Reaction/UI/CRUDController.pm @@ -9,8 +9,8 @@ use aliased 'Reaction::UI::ViewPort::ListView'; use aliased 'Reaction::UI::ViewPort::ActionForm'; use aliased 'Reaction::UI::ViewPort::ObjectView'; -has 'model_base' => (isa => 'Str', is => 'rw', required => 1); -has 'model_name' => (isa => 'Str', is => 'rw', required => 1); +has 'model_name' => (isa => 'Str', is => 'rw', required => 1); +has 'collection_name' => (isa => 'Str', is => 'rw', required => 1); has action_viewport_map => (isa => 'HashRef', is => 'rw', lazy_build => 1); has action_viewport_args => (isa => 'HashRef', is => 'rw', lazy_build => 1); @@ -55,8 +55,10 @@ sub base :Action :CaptureArgs(0) { sub get_collection { my ($self, $c) = @_; - #this sucks and should be fixed - return $c->model(join('::', $self->model_base, $self->model_name)); + my $model = $c->model( $self->model_name ); + my $attr = $model->meta->find_attribute_by_name( $self->collection_name ); + my $reader = $attr->get_read_method; + return $model->$reader; } sub get_model_action { diff --git a/lib/Reaction/UI/View.pm b/lib/Reaction/UI/View.pm index 4c7e8ef..77d0699 100644 --- a/lib/Reaction/UI/View.pm +++ b/lib/Reaction/UI/View.pm @@ -69,6 +69,8 @@ class View which { my @search_path = ($base, $app_name, 'Reaction::UI'); my @haystack = map { join '::', $_, 'Widget', $tail } @search_path; for my $class (@haystack){ + #here we should throw if exits and error instead of eating the error + #only next when !exists eval { Class::MOP::load_class($class) }; #$@ ? next : return $class; $@ ? next : return $cache->{ $lset_name } = $class; diff --git a/lib/Reaction/UI/Widget/ActionForm.pm b/lib/Reaction/UI/Widget/ActionForm.pm index 0818656..fc2df18 100644 --- a/lib/Reaction/UI/Widget/ActionForm.pm +++ b/lib/Reaction/UI/Widget/ActionForm.pm @@ -8,6 +8,7 @@ class ActionForm, which { fields renders [field over func('viewport','ordered_fields')]; field renders [ 'viewport' ]; + #move button logic here buttons renders [ string {"DUMMY"} ], {message => sub{ $_{viewport}->can('message') ? $_{viewport}->message : "" } }; header renders [ string {"DUMMY"} ]; |