Hey folks,

Having discovered a need for a Template::Provider::DBI, I've written one. 
I'd like opinions etc on it, as well as a small favour.. I needed to make 
a small change to the Template::Provider module, in order to extract the 
modify-time checking code out into a sub that I could override. I've 
attached it to this email, anyone like to apply/comment?

Currently, the T::P::DBI will supply/check modify-times, but doesn't do 
caching, it lets TTs usual "cache as file in /tmp" handle that. (In 
theory - I've tested the retrieval of templates from the DB, but not the 
caching.. any ideas how to test that?)

Anyway, comments? thoughts etc, please reply..

http://desert-island.dynodns.net:8888/perldists/Template-Provider-DBI-0.01.tar.gz


Jess

--- /usr/lib/perl5/site_perl/5.8.4/i686-linux-thread-multi/Template/Provider.pm 
2004-01-30 18:37:50.000000000 +0000
+++ Template/Provider.pm        2005-12-18 00:50:02.264515495 +0000
@@ -418,7 +418,7 @@
     if (defined $size && ! $size) {
         # caching disabled so load and compile but don't cache
         if ($compiled && -f $compiled 
-            && (stat($name))[9] <= (stat($compiled))[9]) {
+            && $self->_mtime($name) <= (stat($compiled))[9]) {
             $data = $self->_load_compiled($compiled);
             $error = $self->error() unless $data;
         }
@@ -752,8 +752,8 @@
     my ($slot, $head);
 
     # extract the load time and compiled template from the data
-#    my $load = $data->{ load };
-    my $load = (stat($name))[9];
+    my $load = $self->_mtime($name);
+#    my $load = (stat($name))[9];
     $data = $data->{ data };
 
     $self->debug("_store($name, $data)") if $self->{ DEBUG };
@@ -800,6 +800,12 @@
     return $data;
 }
 
+sub _mtime
+{
+    my ($self, $name) = @_;
+    my $load = (stat($name))[9];
+    return $load;
+}
 
 #------------------------------------------------------------------------
 # _compile($data)

Reply via email to