[Zope-CVS] CVS: Products/Ape/lib/apelib/fs -
classification.py:1.3.2.2 connection.py:1.5.2.2
interfaces.py:1.2.2.1 properties.py:1.3.4.1
security.py:1.2.6.2 structure.py:1.4.2.2
Shane Hathaway
shane at zope.com
Sat Dec 20 23:24:35 EST 2003
Update of /cvs-repository/Products/Ape/lib/apelib/fs
In directory cvs.zope.org:/tmp/cvs-serv18412/lib/apelib/fs
Modified Files:
Tag: ape-0_8-branch
classification.py connection.py interfaces.py properties.py
security.py structure.py
Log Message:
Continued cleanup after refactoring the interfaces. See CHANGES.txt.
All tests now pass except for the SQL tests.
=== Products/Ape/lib/apelib/fs/classification.py 1.3.2.1 => 1.3.2.2 ===
--- Products/Ape/lib/apelib/fs/classification.py:1.3.2.1 Sat Dec 20 02:31:05 2003
+++ Products/Ape/lib/apelib/fs/classification.py Sat Dec 20 23:24:04 2003
@@ -16,7 +16,7 @@
$Id$
"""
-from apelib.core.interfaces import IGateway
+from apelib.core.interfaces import IGateway, LoadError, ConflictError
from apelib.core.schemas import FieldSchema
from base import FSGatewayBase
@@ -47,6 +47,16 @@
# state is a classification
fs_conn = self.getConnection(event)
p = event.oid
+ if event.is_new:
+ # Don't overwrite existing data
+ try:
+ fs_conn.readNodeType(p)
+ except LoadError:
+ # Nothing exists yet.
+ pass
+ else:
+ # Something exists. Don't overwrite it.
+ raise ConflictError(p)
items = state.items()
items.sort()
text = []
=== Products/Ape/lib/apelib/fs/connection.py 1.5.2.1 => 1.5.2.2 ===
--- Products/Ape/lib/apelib/fs/connection.py:1.5.2.1 Fri Dec 19 21:52:48 2003
+++ Products/Ape/lib/apelib/fs/connection.py Sat Dec 20 23:24:04 2003
@@ -80,6 +80,9 @@
ops = StandardFileOperations()
self.ops = ops
+ def _clearCache(self):
+ self._props_cache.clear()
+ self._dir_cache.clear()
def _isLegalFilename(self, fn):
mp = self.metadata_prefix
@@ -529,8 +532,7 @@
self.ops.makedirs(self.basepath)
def begin(self):
- self._props_cache.clear()
- self._dir_cache.clear()
+ self._clearCache()
def vote(self):
"""Do some early verification
@@ -545,8 +547,7 @@
def reset(self):
self._final = 0
self._pending.clear()
- self._props_cache.clear()
- self._dir_cache.clear()
+ self._clearCache()
def abort(self):
self.reset()
@@ -575,7 +576,7 @@
return t
- def getSources(self, subpath):
+ def getPollSources(self, subpath):
p = self._expandPath(subpath)
props, remainder = self._getPropertyPaths(p)
paths = (p, props, remainder)
@@ -596,5 +597,3 @@
if t != new_t:
res[source] = new_t
return res
-
-
=== Products/Ape/lib/apelib/fs/interfaces.py 1.2 => 1.2.2.1 ===
--- Products/Ape/lib/apelib/fs/interfaces.py:1.2 Wed Jul 30 17:33:02 2003
+++ Products/Ape/lib/apelib/fs/interfaces.py Sat Dec 20 23:24:04 2003
@@ -78,7 +78,7 @@
"""Returns the modification time of a file.
"""
- def getSources(subpath):
+ def getPollSources(subpath):
"""Returns source information for a subpath.
The source information is a mapping that maps
=== Products/Ape/lib/apelib/fs/properties.py 1.3 => 1.3.4.1 ===
--- Products/Ape/lib/apelib/fs/properties.py:1.3 Wed Jul 9 11:40:03 2003
+++ Products/Ape/lib/apelib/fs/properties.py Sat Dec 20 23:24:04 2003
@@ -72,7 +72,7 @@
FSGatewayBase.__init__(self, conn_name)
def load(self, event):
- p = event.getKey()
+ p = event.oid
fs_conn = self.getConnection(event)
text = fs_conn.readSection(p, self.section, '')
res = []
@@ -95,7 +95,7 @@
lines.append('%s:%s=%s' % (k, t, escape_string(v)))
lines.sort()
text = '\n'.join(lines)
- p = event.getKey()
+ p = event.oid
fs_conn = self.getConnection(event)
fs_conn.writeSection(p, self.section, text)
state = list(state)
@@ -116,7 +116,7 @@
def load(self, event):
fs_conn = self.getConnection(event)
- p = event.getKey()
+ p = event.oid
state = fs_conn.readSection(p, self.section, '').strip()
return state, state
@@ -125,7 +125,7 @@
raise ValueError('Not a string: %s' % repr(state))
state = state.strip()
if state:
- p = event.getKey()
+ p = event.oid
fs_conn = self.getConnection(event)
fs_conn.writeSection(p, self.section, state)
return state
=== Products/Ape/lib/apelib/fs/security.py 1.2.6.1 => 1.2.6.2 ===
--- Products/Ape/lib/apelib/fs/security.py:1.2.6.1 Fri Dec 19 21:52:48 2003
+++ Products/Ape/lib/apelib/fs/security.py Sat Dec 20 23:24:04 2003
@@ -39,9 +39,8 @@
FSGatewayBase.__init__(self, conn_name)
def load(self, event):
- key = event.getKey()
fs_conn = self.getConnection(event)
- text = fs_conn.readSection(key, self.section, '')
+ text = fs_conn.readSection(event.oid, self.section, '')
res = []
if text:
lines = text.split('\n')
@@ -67,7 +66,7 @@
else:
raise ValueError(
"Could not read security declaration "
- "%s for %s" % (repr(line), repr(key)))
+ "%s for %s" % (repr(line), repr(event.oid)))
res.append(tuple(row))
res.sort()
return res, tuple(res)
@@ -89,7 +88,7 @@
lines.sort()
text = '\n'.join(lines)
fs_conn = self.getConnection(event)
- fs_conn.writeSection(event.getKey(), self.section, text)
+ fs_conn.writeSection(event.oid, self.section, text)
state = list(state)
state.sort()
return tuple(state)
@@ -109,7 +108,7 @@
def load(self, event):
c = self.getConnection(event)
- p = event.getKey()
+ p = event.oid
assert c.readNodeType(p) == 'f'
text = c.readData(p)
res = []
@@ -157,7 +156,7 @@
domainlist = self._joinList(domains)
to_write = '%s:%s:%s:%s' % (id, password, rolelist, domainlist)
replace_lines[id] = to_write
- p = event.getKey()
+ p = event.oid
fs_conn = self.getConnection(event)
fs_conn.writeNodeType(p, 'f')
text = fs_conn.readData(p, allow_missing=1)
=== Products/Ape/lib/apelib/fs/structure.py 1.4.2.1 => 1.4.2.2 ===
--- Products/Ape/lib/apelib/fs/structure.py:1.4.2.1 Fri Dec 19 21:52:48 2003
+++ Products/Ape/lib/apelib/fs/structure.py Sat Dec 20 23:24:04 2003
@@ -18,7 +18,7 @@
from types import StringType
-from apelib.core.interfaces import IGateway
+from apelib.core.interfaces import IGateway, LoadError
from apelib.core.schemas import FieldSchema, RowSequenceSchema
from base import FSGatewayBase
@@ -93,7 +93,7 @@
__implements__ = IGateway
schema = RowSequenceSchema()
- schema.addField('id', 'string', 1)
+ schema.addField('key', 'string', 1)
schema.addField('oid', 'string')
def load(self, event):
@@ -143,4 +143,60 @@
# Under normal circumstances, there is no need to change the mod
# time of a file. Ignore by returning None as the hash.
return None
+
+
+class RootDirectoryItems (FSGatewayBase):
+ """Read/write the root object.
+
+ The root object is stored as a normal directory with one special feature:
+ the name 'Application' is always present and points to the OID '/'. This
+ allows the root object to be stored inside the application object.
+ """
+
+ __implements__ = IGateway
+
+ schema = RowSequenceSchema()
+ schema.addField('key', 'string', 1)
+ schema.addField('oid', 'string')
+
+ def load(self, event):
+ p = event.oid
+ c = self.getConnection(event)
+ try:
+ t = c.readNodeType(p)
+ except LoadError:
+ # The root object doesn't exist, but it's reasonable
+ # to infer a state anyway.
+ names = []
+ else:
+ assert t == 'd', 'The root object must be a directory'
+ names = c.readData(p)
+ names.sort()
+ res = [('Application', '/')]
+ for name in names:
+ if name != 'Application':
+ oid = event.conf.oid_gen.new_oid(event, name, False)
+ res.append((name, oid))
+ res = tuple(res)
+ return res, res
+
+ def store(self, event, state):
+ p = event.oid
+ c = self.getConnection(event)
+ c.writeNodeType(p, 'd')
+ state = list(state)
+ state.sort()
+ names = []
+ for name, oid in state:
+ if name == 'Application':
+ expect = '/'
+ else:
+ expect = event.conf.oid_gen.new_oid(event, name, False)
+ names.append(name)
+ assert expect == oid, (
+ "Child of %s named %s must use OID %s, but used %s" %
+ (event.oid, name, expect, oid))
+ c.writeData(p, names)
+ return tuple(state)
+
More information about the Zope-CVS
mailing list