[Zope-CVS] CVS: Products/Ape/lib/apelib/fs - base.py:1.5 classification.py:1.3 connection.py:1.4 interfaces.py:1.2 structure.py:1.4
Shane Hathaway
shane@zope.com
Wed, 30 Jul 2003 17:33:40 -0400
Update of /cvs-repository/Products/Ape/lib/apelib/fs
In directory cvs.zope.org:/tmp/cvs-serv5368/lib/apelib/fs
Modified Files:
base.py classification.py connection.py interfaces.py
structure.py
Log Message:
Merged ape-scan-branch, sneaking in interface updates and minor reformatting.
Ape now watches the filesystem for changes to objects that Zope has in its
cache.
=== Products/Ape/lib/apelib/fs/base.py 1.4 => 1.5 ===
--- Products/Ape/lib/apelib/fs/base.py:1.4 Mon May 19 15:32:34 2003
+++ Products/Ape/lib/apelib/fs/base.py Wed Jul 30 17:33:02 2003
@@ -33,3 +33,5 @@
def getConnection(self, event):
return event.getConnection(self.conn_name)
+ def getSources(self, event):
+ return None
=== Products/Ape/lib/apelib/fs/classification.py 1.2 => 1.3 ===
--- Products/Ape/lib/apelib/fs/classification.py:1.2 Tue Apr 29 18:11:50 2003
+++ Products/Ape/lib/apelib/fs/classification.py Wed Jul 30 17:33:02 2003
@@ -30,17 +30,17 @@
schema = FieldSchema('classification', 'classification')
def load(self, event):
- c = self.getConnection(event)
+ fs_conn = self.getConnection(event)
p = event.getKey()
- classification = {'node_type': c.readNodeType(p)}
- text = c.readSection(p, 'classification', '')
+ classification = {'node_type': fs_conn.readNodeType(p)}
+ text = fs_conn.readSection(p, 'classification', '')
if text:
lines = text.split('\n')
for line in lines:
if '=' in line:
k, v = line.split('=', 1)
classification[k.strip()] = v.strip()
- classification['extension'] = c.getExtension(p)
+ classification['extension'] = fs_conn.getExtension(p)
return classification, text.strip()
def store(self, event, state):
=== Products/Ape/lib/apelib/fs/connection.py 1.3 => 1.4 ===
--- Products/Ape/lib/apelib/fs/connection.py:1.3 Sat May 24 17:51:26 2003
+++ Products/Ape/lib/apelib/fs/connection.py Wed Jul 30 17:33:02 2003
@@ -19,7 +19,7 @@
import re
from types import StringType
-from apelib.core.interfaces import ITPCConnection
+from apelib.core.interfaces import ITPCConnection, ISourceRepository
from apelib.core.exceptions import NoStateFoundError
from interfaces import IFSConnection
from exceptions import FSWriteError
@@ -62,7 +62,7 @@
square-bracket section headers and encodes sections by doubling
left-square brackets.
"""
- __implements__ = IFSConnection, ITPCConnection
+ __implements__ = IFSConnection, ITPCConnection, ISourceRepository
basepath = ''
@@ -563,4 +563,38 @@
def close(self):
self.reset()
+
+
+ def _get_paths_mtime(self, paths):
+ t = []
+ for path in paths:
+ try:
+ t.append(self.ops.getmtime(path))
+ except OSError:
+ t.append(None)
+ return t
+
+
+ def getSources(self, subpath):
+ p = self._expandPath(subpath)
+ props, remainder = self._getPropertyPaths(p)
+ paths = (p, props, remainder)
+ t = self._get_paths_mtime(paths)
+ return {(self, paths): t}
+
+
+ def freshen(self, sources):
+ """ISourceRepository implementation.
+
+ Returns the changed items.
+ """
+ res = {}
+ for source, t in sources.items():
+ myself, paths = source
+ assert myself is self
+ new_t = self._get_paths_mtime(paths)
+ if t != new_t:
+ res[source] = new_t
+ return res
+
=== Products/Ape/lib/apelib/fs/interfaces.py 1.1 => 1.2 ===
--- Products/Ape/lib/apelib/fs/interfaces.py:1.1 Wed Apr 9 23:09:55 2003
+++ Products/Ape/lib/apelib/fs/interfaces.py Wed Jul 30 17:33:02 2003
@@ -78,3 +78,12 @@
"""Returns the modification time of a file.
"""
+ def getSources(subpath):
+ """Returns source information for a subpath.
+
+ The source information is a mapping that maps
+ (source_repository, path) to a state object. The contents of
+ path and state are specific to a source repository. The
+ source repository (an ISourceRepository) may be polled
+ periodically to freshen the state of objects in caches.
+ """
=== Products/Ape/lib/apelib/fs/structure.py 1.3 => 1.4 ===
--- Products/Ape/lib/apelib/fs/structure.py:1.3 Wed Jul 9 11:40:03 2003
+++ Products/Ape/lib/apelib/fs/structure.py Wed Jul 30 17:33:02 2003
@@ -82,6 +82,10 @@
raise ValueError('Mismatched file ID')
return id
+ def getSources(self, event):
+ fs_conn = self.getConnection(event)
+ return fs_conn.getSources(event.getKey())
+
class FSDirectoryItems (FSGatewayBase):