[Catalyst-dev] Instantiation of $app (like all other COMPONENTs) at setup time

Guillermo Roditi groditi at gmail.com
Thu May 22 16:39:07 GMT 2008


For some reason, all Components which ->can('COMPONENT') get
instantiated except for MyApp. This seems silly. I know it might be
strange to call $c->component('MyApp') right now, but i think it could
be an important thing to do before app /ctx split.

The reason I ask is because path_prefix and action_namespace should be
attributes with builder methods where the result is cached for the
duration of the instance, but currently it needs to be calculated
every time leading to an inefficient (although i doubt significantly
so) process and crufty code. The reason for this is that the codepaths
are different when $self is a reference and when it is a class name.
Because Controllers are always instantiated (Controller ISA Component,
which can(COMPONENT)) it seems that we could cut half of that logic
out because the only time that sub is called with a classname in
practice is when Myapp->path_prefix is called  (one more woe of MyApp
ISA Controller).

The test suite shows no errors for this change other than two unit
tests which are testing that the default is built properly. the fix
was remarkably simple.

Please speak up now or relinquish your right to complain later.

-- 
Guillermo Roditi (groditi)



More information about the Catalyst-dev mailing list