[Catalyst] [spam] Re: Where to put template files?

Marcello Romani mromani at ottotecnica.com
Fri Jun 9 08:35:06 CEST 2006


Dr. Jennifer Nussbaum ha scritto:
> 
> 
>      > On 08/06/06, *Dr. Jennifer Nussbaum*
>      > > wrote:
>      >
>      >
>      >
>      > You can do something like:
>      >
>      >
>      > SetHandler perl-script
>      > PerlResponseHandler MyApp
>      >
>      > Alias /myapp/static /path/to/myapp/root/static
>      >
>      > Order allow,deny
>      > Allow from all
>      >
>      > SetHandler default-handler
>      >
>      > Thank you!!!
>      >
>      > But one question--where do my templates go? Right now their under,
>      > lets say, /path/to/myapp/root/. And i dont want to change anything
>      > in MyApp.pm so i can
>      > keep running it with the builtin testing server.
> 
>     If everything is working fine under the test server, then it should
>     Just
>     Work (tm) under apache. Templates don't have to be moved.
> 
> 
> Thank you for this and thank you to everyone whose responded in detail 
> about setting this up but i think my main question is still out there.
> 
> i dont want to change INCLUDE_PATH in Template Toolkit because if i 
> specify a direct path the testserver wont work, right?

IME you don't have to touch that config item even if you move your app 
around. Catalyst sets it up so that everything Just Works(tm) wherever 
MyApp/ is.

> 
> And i understand that this will "Just Work" under apache if i leave 
> everything where it is but thats not what im asking. i want to know 
> where to put it if i DO need to move thing. Consider this:

Well, just copy MyApp/ in a suitable location and configure apache 
accordingly. You don't want code and templates to be in different 
places, especially on a production installation, do you ?

> 
> Right now i can create MyApp anywhere, it can be 
> /home/jen/temporary_projects/myapp/lib/MyApp.pm. And then if I run the 
> testserver it will find my templates at 
> /home/jen/temporary_projects/myapp/root/header.tt. But if i run this 
> under apache i DONT want to keep MyApp at /home/jen/temporary_projects, 
> i want to move it to something like /usr/local/web/modules/MyApp.pm 

Catalyst applications are structured like perl module distribution. You 
don't move MyApp.pm, but the entire MyApp/ directory instead. Since 
everything (code, templates, static resources, config files, etc.) is 
contained in that dir, and Catalyst knows where it's called from, 
there's no need to worry about it not finding templates.

In other words, to move your app from temporary_projects to 
/usr/local/web/modules, just cp temporary_projects/MyApp to 
/usr/local/web/modules.

To verify that everything Just Works(tm) as expected even in the new 
location, try to run it under the test server (i.e. cd 
/usr/local/web/modules/MyApp; perl script/myapp_server.pl): if it works 
this way, it'll work under apache.

> where the rest of my webapps are, and apache points to them. But then i 
> cant keep my templates in ~/temporary_projects or they wont be found. 

As I just said, templates are moved together with the application code.

> BUT if I make something like /usr/local/web/templates/myapp/ and point 
> INCLUDE_PATH to THAT, then the testserver wont find it if im running on 
> the development version in temporary_projects.
> 
> im sorry if im not explaining things well but what i really want is way 
> that i can do two things: 1. run a development version with the 
> testserver and run a production version with apache, and 2. do this 
> without changing code between the versions (changing the code to get the 
> production version to point to different directories that is).
> 
> is that clearer? Thanks for keeping on reading!!
> 
> Jen
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Catalyst mailing list
> Catalyst at lists.rawmode.org
> http://lists.rawmode.org/mailman/listinfo/catalyst

I hope I made it clear enough :-)

Keep asking if needed!

-- 
Marcello Romani
Responsabile IT
Ottotecnica s.r.l.
http://www.ottotecnica.com



More information about the Catalyst mailing list