[Catalyst] Using path_to()
J. Shirley
jshirley at gmail.com
Wed Apr 29 10:12:01 GMT 2009
2009/4/29 Octavian Rasnita <orasnita at gmail.com>
> Hi,
>
> In which components of a Catalyst app can I use __PACKAGE__->path_to()?
>
> I've seen that if I use in a MyApp/View/TT.pm module
>
> __PACKAGE__->config(
> COMPILE_DIR =3D> __PACKAGE__->path_to('templates'),
> );
>
> it gives an error like:
>
> Can't locate object method "path_to" via package "MyApp::View::TT" at
> D:/web/MyApp/scr
> ipt/../lib/MyApp/View/TT.pm line 7.
>
> It works if I use MyApp->path_to() instead...
>
> Generally, it would be also very helpful if we could find which methods a=
re
> offered by a certain $c object in a certain place. Is there a way for doi=
ng
> this?
>
> Thanks.
>
> --
> Octavian
>
Well, in config scenarios (this doesn't really answer your question) I opt
to use __path_to(...)__ -- as that is guaranteed to be expanded in a
documented fashion from what the documents say.
Having said that, it really just calls MyApp->path_to(...);
The difference is that ->path_to is a method on the application class, and
not a component class.
Every MyApp::(Controller|Model|View)::*.pm is essentially a
Catalyst::Component at the core. If a method doesn't exist in
Catalyst::Component or in the subsequent Controller/Model/View base classes,
it won't be available in the __PACKAGE__ usage you were attempting above.
The actual application is an instance of the 'Catalyst' package, so you can
look at Catalyst::Runtime's Catalyst.pm for documentation on what works.
Hope that clears it up.
-Jay
PS., may be beneficial to read
http://search.cpan.org/~hkclark/Catalyst-Manual-5.7020/lib/Catalyst/Manual/=
ExtendingCatalyst.pod
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20090429/43e0c=
a11/attachment.htm
More information about the Catalyst
mailing list