[Templates] Templates Cached to Disk
Tom Gioconda
achronos@bungie.com
Fri, 15 Mar 2002 17:05:08 -0800
No, I don't think it is supposed to get 1 all the time. I've traced it,
and when everything works, $compiled is returned as a reference. When
it fails, $compiled is 1 on the file that failed to load from the cache.
The eval around the require returns no error, so the 1 gets passed to
code assuming it has a reference, and when it doesn't, you get "invalid
template reference".
The comments in _load_compiled also suggest that the entire reason of
making the "delete $INC{$file}" call is to make sure that require
doesn't just return 1.
Oh well. If something else doesn't spring to mind next week, I'll have
to probably sack _load_compiled for a home-brewed solution. It can't be
"do $file" though, because that doesn't do all the appropriate exception
checking and what not. Unfortunately, that only solves the symptoms of
the problem. I'd still have no idea what is cause the intermittent
problem in the first place, meaning it could pop up elsewhere.
-Tom
-----Original Message-----
From: Perrin Harkins [mailto:perrin@elem.com]
Sent: Friday, March 15, 2002 3:10 PM
To: Tom Gioconda
Cc: templates@template-toolkit.org
Subject: Re: [Templates] Templates Cached to Disk
Importance: High
Tom Gioconda wrote:
> Basically,
> when it does "$compiled = require $file", $compiled gets the value 1
> on occasion.
Hmm... That looks like it should *always* return 1, unless the require
fails for some reason.
> I'm getting real close here to
> sacking _load_compiled and writing my own that doesn't use require but
> loads the file itself and then evals the contents of it (and not
> having to worry about %INC).
That's spelled "do $file;", but that would be a voodoo solution. It
shouldn't behave any differently from a require, except that require
checks %INC and needs to see a true return value.
- Perrin