diff options
author | groditi <groditi@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7> | 2007-10-03 21:04:04 +0000 |
---|---|---|
committer | groditi <groditi@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7> | 2007-10-03 21:04:04 +0000 |
commit | de48f4e69aef2efba652b10994a920d6a61e856d (patch) | |
tree | 97be169c03c1905ab439a7d960814161cf040241 /lib/Reaction | |
parent | e716714fb1197850975fcd131149db2f53b07f64 (diff) | |
download | reaction-de48f4e69aef2efba652b10994a920d6a61e856d.tar.gz reaction-de48f4e69aef2efba652b10994a920d6a61e856d.zip |
optimizations are fun! widget cache, reflector and immutable, other details. bye old view
Diffstat (limited to 'lib/Reaction')
-rw-r--r-- | lib/Reaction/InterfaceModel/Reflector/DBIC.pm | 10 | ||||
-rw-r--r-- | lib/Reaction/UI/View.pm | 9 | ||||
-rw-r--r-- | lib/Reaction/UI/ViewPort/ActionForm.pm | 1 | ||||
-rw-r--r-- | lib/Reaction/UI/ViewPort/Field.pm | 2 | ||||
-rw-r--r-- | lib/Reaction/UI/ViewPort/GridView.pm | 1 | ||||
-rw-r--r-- | lib/Reaction/UI/ViewPort/ObjectView.pm | 1 |
6 files changed, 17 insertions, 7 deletions
diff --git a/lib/Reaction/InterfaceModel/Reflector/DBIC.pm b/lib/Reaction/InterfaceModel/Reflector/DBIC.pm index 70b65b7..4d83357 100644 --- a/lib/Reaction/InterfaceModel/Reflector/DBIC.pm +++ b/lib/Reaction/InterfaceModel/Reflector/DBIC.pm @@ -14,6 +14,8 @@ use Catalyst::Utils; class DBIC, which { + has make_classes_immutable => (isa => "Bool", is => "rw", required => 1, default => sub{ 1 }); + #user defined actions and prototypes has object_actions => (isa => "HashRef", is => "rw", lazy_build => 1); has collection_actions => (isa => "HashRef", is => "rw", lazy_build => 1); @@ -178,7 +180,7 @@ class DBIC, which { my $sources = $self->parse_reflect_rules($rules, $haystack); - my $make_immutable = $meta->is_immutable; + my $make_immutable = $meta->is_immutable || $self->make_classes_immutable; $meta->make_mutable if $meta->is_immutable; $meta->add_domain_model @@ -372,7 +374,7 @@ class DBIC, which { my $meta = eval { Class::MOP::load_class($class) } ? $class->meta : $base->meta->create( $class, superclasses => [ $base ]); - my $make_immutable = $meta->is_immutable; + my $make_immutable = $meta->is_immutable || $self->make_classes_immutable;; $meta->make_mutable if $meta->is_immutable; $meta->add_method(_build_im_class => sub{ $object } ); #XXX as a default pass the domain model as a target_model until i come up with something @@ -467,7 +469,7 @@ class DBIC, which { $dm_opts->{is} ||= 'rw'; $dm_opts->{required} ||= 1; - my $make_immutable = $meta->is_immutable; + my $make_immutable = $meta->is_immutable || $self->make_classes_immutable;; $meta->make_mutable if $meta->is_immutable; my $dm_attr = $meta->add_domain_model($dm_name, %$dm_opts); @@ -753,7 +755,7 @@ class DBIC, which { #create the class my $meta = eval { Class::MOP::load_class($class) } ? $class->meta : $base->meta->create($class, superclasses => [$base]); - my $make_immutable = $meta->is_immutable; + my $make_immutable = $meta->is_immutable || $self->make_classes_immutable; $meta->make_mutable if $meta->is_immutable; for my $attr_name (keys %$attributes){ diff --git a/lib/Reaction/UI/View.pm b/lib/Reaction/UI/View.pm index 081a16f..4c7e8ef 100644 --- a/lib/Reaction/UI/View.pm +++ b/lib/Reaction/UI/View.pm @@ -8,7 +8,8 @@ use Reaction::UI::RenderingContext; class View which { - has '_layout_set_cache' => (is => 'ro', default => sub { {} }); + has '_layout_set_cache' => (is => 'ro', default => sub { {} }); + has '_widget_class_cache' => (is => 'ro', default => sub { {} }); has 'app' => (is => 'ro', required => 1); @@ -59,14 +60,18 @@ class View which { my ($self, $layout_set) = @_; my $base = $self->blessed; my $tail = $layout_set->widget_type; + my $lset_name = $layout_set->name; # eventually more stuff will go here i guess? my $app_name = ref $self->app || $self->app; + my $cache = $self->_widget_class_cache; + return $cache->{ $lset_name } if exists $cache->{ $lset_name }; my @search_path = ($base, $app_name, 'Reaction::UI'); my @haystack = map { join '::', $_, 'Widget', $tail } @search_path; for my $class (@haystack){ eval { Class::MOP::load_class($class) }; - $@ ? next : return $class; + #$@ ? next : return $class; + $@ ? next : return $cache->{ $lset_name } = $class; } confess "Couldn't load widget '$tail': tried: @haystack"; }; diff --git a/lib/Reaction/UI/ViewPort/ActionForm.pm b/lib/Reaction/UI/ViewPort/ActionForm.pm index b28c25d..373b81d 100644 --- a/lib/Reaction/UI/ViewPort/ActionForm.pm +++ b/lib/Reaction/UI/ViewPort/ActionForm.pm @@ -85,6 +85,7 @@ class ActionForm is 'Reaction::UI::ViewPort', which { my $tried_isa = 0; CONSTRAINT: while (defined($constraint)) { my $name = $constraint->name; + $name = $attr->_isa_metadata if($name eq '__ANON__'); if (eval { $name->can('meta') } && !$tried_isa++) { foreach my $class ($name->meta->class_precedence_list) { my $mangled_name = $class; diff --git a/lib/Reaction/UI/ViewPort/Field.pm b/lib/Reaction/UI/ViewPort/Field.pm index 06d0598..99a51f3 100644 --- a/lib/Reaction/UI/ViewPort/Field.pm +++ b/lib/Reaction/UI/ViewPort/Field.pm @@ -43,7 +43,7 @@ class Field is 'Reaction::UI::ViewPort', which { implements build_label => as { my ($self) = @_; my $label = join(' ', map { ucfirst } split('_', $self->name)); - print STDERR "Field " . $self->name . " has label '$label'\n"; + # print STDERR "Field " . $self->name . " has label '$label'\n"; return $label; }; diff --git a/lib/Reaction/UI/ViewPort/GridView.pm b/lib/Reaction/UI/ViewPort/GridView.pm index 5691ff1..4313119 100644 --- a/lib/Reaction/UI/ViewPort/GridView.pm +++ b/lib/Reaction/UI/ViewPort/GridView.pm @@ -94,6 +94,7 @@ class GridView is 'Reaction::UI::ViewPort', which { my $tried_isa = 0; CONSTRAINT: while (defined($constraint)) { my $name = $constraint->name; + $name = $attr->_isa_metadata if($name eq '__ANON__'); if (eval { $name->can('meta') } && !$tried_isa++) { foreach my $class ($name->meta->class_precedence_list) { my $mangled_name = $class; diff --git a/lib/Reaction/UI/ViewPort/ObjectView.pm b/lib/Reaction/UI/ViewPort/ObjectView.pm index 2dc7f63..3b101e4 100644 --- a/lib/Reaction/UI/ViewPort/ObjectView.pm +++ b/lib/Reaction/UI/ViewPort/ObjectView.pm @@ -56,6 +56,7 @@ class ObjectView is 'Reaction::UI::ViewPort', which { my $tried_isa = 0; CONSTRAINT: while (defined($constraint)) { my $name = $constraint->name; + $name = $attr->_isa_metadata if($name eq '__ANON__'); if (eval { $name->can('meta') } && !$tried_isa++) { foreach my $class ($name->meta->class_precedence_list) { my $mangled_name = $class; |