reverted cfs.py

This commit is contained in:
mdipierro
2012-07-11 22:11:20 -05:00
parent 2f8ceb3bc5
commit 4a49bdf352
2 changed files with 7 additions and 8 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.00.0 (2012-07-11 22:10:11) dev Version 2.00.0 (2012-07-11 22:11:17) dev
+6 -7
View File
@@ -13,6 +13,7 @@ FOR INTERNAL USE ONLY
""" """
import os import os
import stat
import thread import thread
from fileutils import read_file from fileutils import read_file
@@ -27,15 +28,13 @@ def getcfs(key, filename, filter=None):
:param key: the cache key :param key: the cache key
:param filename: the file to cache :param filename: the file to cache
:param filter: is the function used for filtering. Previous stored data :param filter: is the function used for filtering. Normally `filename` is a
(or None) are passed to this function as a parameter (READONLY!!). .py file and `filter` is a function that bytecode compiles the file.
Normally `filename` is a .py file and `filter` is a function that In this way the bytecode compiled file is cached. (Default = None)
bytecode compiles the file. In this way the bytecode compiled file
is cached. (Default = None)
This is used on Google App Engine since pyc files cannot be saved. This is used on Google App Engine since pyc files cannot be saved.
""" """
t = os.stat(filename).st_mtime t = os.stat(filename)[stat.ST_MTIME]
cfs_lock.acquire() cfs_lock.acquire()
item = cfs.get(key, None) item = cfs.get(key, None)
cfs_lock.release() cfs_lock.release()
@@ -44,7 +43,7 @@ def getcfs(key, filename, filter=None):
if not filter: if not filter:
data = read_file(filename) data = read_file(filename)
else: else:
data = filter(item[1]) if item else filter() data = filter()
cfs_lock.acquire() cfs_lock.acquire()
cfs[key] = (t, data) cfs[key] = (t, data)
cfs_lock.release() cfs_lock.release()