rename NewDirectoryNode to DirectoryNode, NewDirectoryURI to DirectoryURI

This commit is contained in:
Brian Warner 2009-07-16 20:01:03 -05:00
parent 8536db4e64
commit 531cc7899f
11 changed files with 60 additions and 62 deletions

View File

@ -21,13 +21,13 @@ from allmydata.util import hashutil, base32, pollmixin, cachedir, log
from allmydata.util.abbreviate import parse_abbreviated_size from allmydata.util.abbreviate import parse_abbreviated_size
from allmydata.util.time_format import parse_duration, parse_date from allmydata.util.time_format import parse_duration, parse_date
from allmydata.uri import LiteralFileURI, UnknownURI from allmydata.uri import LiteralFileURI, UnknownURI
from allmydata.dirnode import NewDirectoryNode from allmydata.dirnode import DirectoryNode
from allmydata.mutable.filenode import MutableFileNode from allmydata.mutable.filenode import MutableFileNode
from allmydata.unknown import UnknownNode from allmydata.unknown import UnknownNode
from allmydata.stats import StatsProvider from allmydata.stats import StatsProvider
from allmydata.history import History from allmydata.history import History
from allmydata.interfaces import IURI, INewDirectoryURI, IStatsProducer, \ from allmydata.interfaces import IURI, IDirectoryURI, IStatsProducer, \
IReadonlyNewDirectoryURI, IFileURI, IMutableFileURI, RIStubClient, \ IReadonlyDirectoryURI, IFileURI, IMutableFileURI, RIStubClient, \
UnhandledCapTypeError UnhandledCapTypeError
KiB=1024 KiB=1024
@ -419,12 +419,12 @@ class Client(node.Node, pollmixin.PollMixin):
return UnknownNode(writecap, readcap) return UnknownNode(writecap, readcap)
u_s = u.to_string() u_s = u.to_string()
if u_s not in self._node_cache: if u_s not in self._node_cache:
if IReadonlyNewDirectoryURI.providedBy(u): if IReadonlyDirectoryURI.providedBy(u):
# new-style read-only dirnodes # read-only dirnodes
node = NewDirectoryNode(self).init_from_uri(u) node = DirectoryNode(self).init_from_uri(u)
elif INewDirectoryURI.providedBy(u): elif IDirectoryURI.providedBy(u):
# new-style dirnodes # dirnodes
node = NewDirectoryNode(self).init_from_uri(u) node = DirectoryNode(self).init_from_uri(u)
elif IFileURI.providedBy(u): elif IFileURI.providedBy(u):
if isinstance(u, LiteralFileURI): if isinstance(u, LiteralFileURI):
node = LiteralFileNode(u, self) # LIT node = LiteralFileNode(u, self) # LIT
@ -439,7 +439,7 @@ class Client(node.Node, pollmixin.PollMixin):
def create_empty_dirnode(self): def create_empty_dirnode(self):
d = self.create_mutable_file() d = self.create_mutable_file()
d.addCallback(NewDirectoryNode.create_with_mutablefile, self) d.addCallback(DirectoryNode.create_with_mutablefile, self)
return d return d
def create_mutable_file(self, contents="", keysize=None): def create_mutable_file(self, contents="", keysize=None):

View File

@ -18,7 +18,7 @@ from allmydata.monitor import Monitor
from allmydata.util import hashutil, mathutil, base32, log from allmydata.util import hashutil, mathutil, base32, log
from allmydata.util.assertutil import _assert, precondition from allmydata.util.assertutil import _assert, precondition
from allmydata.util.netstring import netstring, split_netstring from allmydata.util.netstring import netstring, split_netstring
from allmydata.uri import NewDirectoryURI, LiteralFileURI, from_string from allmydata.uri import DirectoryURI, LiteralFileURI, from_string
from pycryptopp.cipher.aes import AES from pycryptopp.cipher.aes import AES
class CachingDict(dict): class CachingDict(dict):
@ -140,7 +140,7 @@ class Adder:
new_contents = self.node._pack_contents(children) new_contents = self.node._pack_contents(children)
return new_contents return new_contents
class NewDirectoryNode: class DirectoryNode:
implements(IDirectoryNode, ICheckable, IDeepCheckable) implements(IDirectoryNode, ICheckable, IDeepCheckable)
filenode_class = MutableFileNode filenode_class = MutableFileNode
@ -175,7 +175,7 @@ class NewDirectoryNode:
d.addCallback(self._filenode_created) d.addCallback(self._filenode_created)
return d return d
def _filenode_created(self, res): def _filenode_created(self, res):
self._uri = NewDirectoryURI(IMutableFileURI(self._node.get_uri())) self._uri = DirectoryURI(IMutableFileURI(self._node.get_uri()))
return self return self
def get_size(self): def get_size(self):

View File

@ -467,9 +467,9 @@ class IImmutableFileURI(IFileURI):
class IMutableFileURI(Interface): class IMutableFileURI(Interface):
"""I am a URI which represents a mutable filenode.""" """I am a URI which represents a mutable filenode."""
class INewDirectoryURI(Interface): class IDirectoryURI(Interface):
pass pass
class IReadonlyNewDirectoryURI(Interface): class IReadonlyDirectoryURI(Interface):
pass pass
class CannotPackUnknownNodeError(Exception): class CannotPackUnknownNodeError(Exception):
@ -2023,7 +2023,7 @@ class IClient(Interface):
IFileNode or IMutableFileNode -providing instances, like IFileNode or IMutableFileNode -providing instances, like
FileNode, LiteralFileNode, or MutableFileNode. FileNode, LiteralFileNode, or MutableFileNode.
Directory-specifying URIs will result in Directory-specifying URIs will result in
IDirectoryNode-providing instances, like NewDirectoryNode. IDirectoryNode-providing instances, like DirectoryNode.
""" """
class IClientStatus(Interface): class IClientStatus(Interface):

View File

@ -430,15 +430,15 @@ def dump_uri_instance(u, nodeid, secret, out, show_header=True):
print >>out, " storage index:", si_b2a(u.storage_index) print >>out, " storage index:", si_b2a(u.storage_index)
print >>out, " fingerprint:", base32.b2a(u.fingerprint) print >>out, " fingerprint:", base32.b2a(u.fingerprint)
elif isinstance(u, uri.NewDirectoryURI): elif isinstance(u, uri.DirectoryURI):
if show_header: if show_header:
print >>out, "Directory Writeable URI:" print >>out, "Directory Writeable URI:"
dump_uri_instance(u._filenode_uri, nodeid, secret, out, False) dump_uri_instance(u._filenode_uri, nodeid, secret, out, False)
elif isinstance(u, uri.ReadonlyNewDirectoryURI): elif isinstance(u, uri.ReadonlyDirectoryURI):
if show_header: if show_header:
print >>out, "Directory Read-only URI:" print >>out, "Directory Read-only URI:"
dump_uri_instance(u._filenode_uri, nodeid, secret, out, False) dump_uri_instance(u._filenode_uri, nodeid, secret, out, False)
elif isinstance(u, uri.NewDirectoryURIVerifier): elif isinstance(u, uri.DirectoryURIVerifier):
if show_header: if show_header:
print >>out, "Directory Verifier URI:" print >>out, "Directory Verifier URI:"
dump_uri_instance(u._filenode_uri, nodeid, secret, out, False) dump_uri_instance(u._filenode_uri, nodeid, secret, out, False)

View File

@ -25,19 +25,19 @@ class FakeMutableFileNode(mut_filenode.MutableFileNode):
mut_filenode.MutableFileNode.__init__(self, client) mut_filenode.MutableFileNode.__init__(self, client)
self._uri = uri.WriteableSSKFileURI(randutil.insecurerandstr(16), randutil.insecurerandstr(32)) self._uri = uri.WriteableSSKFileURI(randutil.insecurerandstr(16), randutil.insecurerandstr(32))
class FakeDirectoryNode(dirnode.NewDirectoryNode): class FakeDirectoryNode(dirnode.DirectoryNode):
def __init__(self, client): def __init__(self, client):
dirnode.NewDirectoryNode.__init__(self, client) dirnode.DirectoryNode.__init__(self, client)
mutfileuri = uri.WriteableSSKFileURI(randutil.insecurerandstr(16), randutil.insecurerandstr(32)) mutfileuri = uri.WriteableSSKFileURI(randutil.insecurerandstr(16), randutil.insecurerandstr(32))
myuri = uri.NewDirectoryURI(mutfileuri) myuri = uri.DirectoryURI(mutfileuri)
self.init_from_uri(myuri) self.init_from_uri(myuri)
children = [] # tuples of (k, v) (suitable for passing to dict()) children = [] # tuples of (k, v) (suitable for passing to dict())
packstr = None packstr = None
fakeclient = FakeClient() fakeclient = FakeClient()
testdirnode = dirnode.NewDirectoryNode(fakeclient) testdirnode = dirnode.DirectoryNode(fakeclient)
testdirnode.init_from_uri(uri.NewDirectoryURI(uri.WriteableSSKFileURI(randutil.insecurerandstr(16), randutil.insecurerandstr(32)))) testdirnode.init_from_uri(uri.DirectoryURI(uri.WriteableSSKFileURI(randutil.insecurerandstr(16), randutil.insecurerandstr(32))))
def random_unicode(l): def random_unicode(l):
while True: while True:

View File

@ -290,7 +290,7 @@ def make_verifier_uri():
return uri.SSKVerifierURI(storage_index=os.urandom(16), return uri.SSKVerifierURI(storage_index=os.urandom(16),
fingerprint=os.urandom(32)) fingerprint=os.urandom(32))
class FakeDirectoryNode(dirnode.NewDirectoryNode): class FakeDirectoryNode(dirnode.DirectoryNode):
"""This offers IDirectoryNode, but uses a FakeMutableFileNode for the """This offers IDirectoryNode, but uses a FakeMutableFileNode for the
backing store, so it doesn't go to the grid. The child data is still backing store, so it doesn't go to the grid. The child data is still
encrypted and serialized, so this isn't useful for tests that want to encrypted and serialized, so this isn't useful for tests that want to

View File

@ -37,7 +37,7 @@ class CLI(unittest.TestCase):
open("cli/test_options/node.url","w").write("http://localhost:8080/\n") open("cli/test_options/node.url","w").write("http://localhost:8080/\n")
filenode_uri = uri.WriteableSSKFileURI(writekey="\x00"*16, filenode_uri = uri.WriteableSSKFileURI(writekey="\x00"*16,
fingerprint="\x00"*32) fingerprint="\x00"*32)
private_uri = uri.NewDirectoryURI(filenode_uri).to_string() private_uri = uri.DirectoryURI(filenode_uri).to_string()
open("cli/test_options/private/root_dir.cap", "w").write(private_uri + "\n") open("cli/test_options/private/root_dir.cap", "w").write(private_uri + "\n")
o = cli.ListOptions() o = cli.ListOptions()
o.parseOptions(["--node-directory", "cli/test_options"]) o.parseOptions(["--node-directory", "cli/test_options"])
@ -62,7 +62,7 @@ class CLI(unittest.TestCase):
o = cli.ListOptions() o = cli.ListOptions()
other_filenode_uri = uri.WriteableSSKFileURI(writekey="\x11"*16, other_filenode_uri = uri.WriteableSSKFileURI(writekey="\x11"*16,
fingerprint="\x11"*32) fingerprint="\x11"*32)
other_uri = uri.NewDirectoryURI(other_filenode_uri).to_string() other_uri = uri.DirectoryURI(other_filenode_uri).to_string()
o.parseOptions(["--node-directory", "cli/test_options", o.parseOptions(["--node-directory", "cli/test_options",
"--dir-cap", other_uri]) "--dir-cap", other_uri])
self.failUnlessEqual(o['node-url'], "http://localhost:8080/") self.failUnlessEqual(o['node-url'], "http://localhost:8080/")
@ -199,7 +199,7 @@ class CLI(unittest.TestCase):
writekey = "\x01" * 16 writekey = "\x01" * 16
fingerprint = "\xfe" * 32 fingerprint = "\xfe" * 32
u1 = uri.WriteableSSKFileURI(writekey, fingerprint) u1 = uri.WriteableSSKFileURI(writekey, fingerprint)
u = uri.NewDirectoryURI(u1) u = uri.DirectoryURI(u1)
output = self._dump_cap(u.to_string()) output = self._dump_cap(u.to_string())
self.failUnless("Directory Writeable URI:" in output, output) self.failUnless("Directory Writeable URI:" in output, output)

View File

@ -7,7 +7,7 @@ from allmydata import uri, dirnode
from allmydata.client import Client from allmydata.client import Client
from allmydata.immutable import upload from allmydata.immutable import upload
from allmydata.interfaces import IURI, IClient, IMutableFileNode, \ from allmydata.interfaces import IURI, IClient, IMutableFileNode, \
INewDirectoryURI, IReadonlyNewDirectoryURI, IFileNode, \ IDirectoryURI, IReadonlyDirectoryURI, IFileNode, \
ExistingChildError, NoSuchChildError, \ ExistingChildError, NoSuchChildError, \
IDeepCheckResults, IDeepCheckAndRepairResults, CannotPackUnknownNodeError IDeepCheckResults, IDeepCheckAndRepairResults, CannotPackUnknownNodeError
from allmydata.mutable.filenode import MutableFileNode from allmydata.mutable.filenode import MutableFileNode
@ -83,8 +83,8 @@ class FakeClient:
if not u: if not u:
u = readcap u = readcap
u = IURI(u) u = IURI(u)
if (INewDirectoryURI.providedBy(u) if (IDirectoryURI.providedBy(u)
or IReadonlyNewDirectoryURI.providedBy(u)): or IReadonlyDirectoryURI.providedBy(u)):
return FakeDirectoryNode(self).init_from_uri(u) return FakeDirectoryNode(self).init_from_uri(u)
return Marker(u.to_string()) return Marker(u.to_string())
@ -929,7 +929,7 @@ class UCWEingMutableFileNode(MutableFileNode):
return res return res
d.addCallback(_ucwe) d.addCallback(_ucwe)
return d return d
class UCWEingNewDirectoryNode(dirnode.NewDirectoryNode): class UCWEingDirectoryNode(dirnode.DirectoryNode):
filenode_class = UCWEingMutableFileNode filenode_class = UCWEingMutableFileNode
@ -957,7 +957,7 @@ class Deleter(GridTestMixin, unittest.TestCase):
return dn.add_file(u"file", small) return dn.add_file(u"file", small)
d.addCallback(_created_dir) d.addCallback(_created_dir)
def _do_delete(ignored): def _do_delete(ignored):
n = UCWEingNewDirectoryNode(c0).init_from_uri(self.root_uri) n = UCWEingDirectoryNode(c0).init_from_uri(self.root_uri)
assert n._node.please_ucwe_after_next_upload == False assert n._node.please_ucwe_after_next_upload == False
n._node.please_ucwe_after_next_upload = True n._node.please_ucwe_after_next_upload = True
# This should succeed, not raise an exception # This should succeed, not raise an exception

View File

@ -185,11 +185,11 @@ class Invalid(unittest.TestCase):
class Constraint(unittest.TestCase): class Constraint(unittest.TestCase):
def test_constraint(self): def test_constraint(self):
good="http://127.0.0.1:3456/uri/URI%3ADIR2%3Agh3l5rbvnv2333mrfvalmjfr4i%3Alz6l7u3z3b7g37s4zkdmfpx5ly4ib4m6thrpbusi6ys62qtc6mma/" good="http://127.0.0.1:3456/uri/URI%3ADIR2%3Agh3l5rbvnv2333mrfvalmjfr4i%3Alz6l7u3z3b7g37s4zkdmfpx5ly4ib4m6thrpbusi6ys62qtc6mma/"
uri.NewDirectoryURI.init_from_human_encoding(good) uri.DirectoryURI.init_from_human_encoding(good)
self.failUnlessRaises(uri.BadURIError, uri.NewDirectoryURI.init_from_string, good) self.failUnlessRaises(uri.BadURIError, uri.DirectoryURI.init_from_string, good)
bad = good + '===' bad = good + '==='
self.failUnlessRaises(uri.BadURIError, uri.NewDirectoryURI.init_from_human_encoding, bad) self.failUnlessRaises(uri.BadURIError, uri.DirectoryURI.init_from_human_encoding, bad)
self.failUnlessRaises(uri.BadURIError, uri.NewDirectoryURI.init_from_string, bad) self.failUnlessRaises(uri.BadURIError, uri.DirectoryURI.init_from_string, bad)
fileURI = 'URI:CHK:gh3l5rbvnv2333mrfvalmjfr4i:lz6l7u3z3b7g37s4zkdmfpx5ly4ib4m6thrpbusi6ys62qtc6mma:3:10:345834' fileURI = 'URI:CHK:gh3l5rbvnv2333mrfvalmjfr4i:lz6l7u3z3b7g37s4zkdmfpx5ly4ib4m6thrpbusi6ys62qtc6mma:3:10:345834'
uri.CHKFileURI.init_from_string(fileURI) uri.CHKFileURI.init_from_string(fileURI)
@ -272,13 +272,13 @@ class NewDirnode(unittest.TestCase):
fingerprint = "\x02" * 32 fingerprint = "\x02" * 32
n = uri.WriteableSSKFileURI(writekey, fingerprint) n = uri.WriteableSSKFileURI(writekey, fingerprint)
u1 = uri.NewDirectoryURI(n) u1 = uri.DirectoryURI(n)
self.failIf(u1.is_readonly()) self.failIf(u1.is_readonly())
self.failUnless(u1.is_mutable()) self.failUnless(u1.is_mutable())
self.failUnless(IURI.providedBy(u1)) self.failUnless(IURI.providedBy(u1))
self.failIf(IFileURI.providedBy(u1)) self.failIf(IFileURI.providedBy(u1))
self.failUnless(IDirnodeURI.providedBy(u1)) self.failUnless(IDirnodeURI.providedBy(u1))
self.failUnless("NewDirectoryURI" in str(u1)) self.failUnless("DirectoryURI" in str(u1))
u1_filenode = u1.get_filenode_uri() u1_filenode = u1.get_filenode_uri()
self.failUnless(u1_filenode.is_mutable()) self.failUnless(u1_filenode.is_mutable())
self.failIf(u1_filenode.is_readonly()) self.failIf(u1_filenode.is_readonly())
@ -309,7 +309,7 @@ class NewDirnode(unittest.TestCase):
u3a = uri.from_string(u3.to_string()) u3a = uri.from_string(u3.to_string())
self.failUnlessIdentical(u3a, u3a.get_readonly()) self.failUnlessIdentical(u3a, u3a.get_readonly())
u4 = uri.ReadonlyNewDirectoryURI(u2._filenode_uri.get_readonly()) u4 = uri.ReadonlyDirectoryURI(u2._filenode_uri.get_readonly())
self.failUnlessEqual(u4.to_string(), u3.to_string()) self.failUnlessEqual(u4.to_string(), u3.to_string())
self.failUnless(u4.is_readonly()) self.failUnless(u4.is_readonly())
self.failUnless(u4.is_mutable()) self.failUnless(u4.is_mutable())
@ -324,8 +324,8 @@ class NewDirnode(unittest.TestCase):
verifiers = [u1.get_verify_cap(), u2.get_verify_cap(), verifiers = [u1.get_verify_cap(), u2.get_verify_cap(),
u3.get_verify_cap(), u4.get_verify_cap(), u3.get_verify_cap(), u4.get_verify_cap(),
IVerifierURI(u1.get_verify_cap().to_string()), IVerifierURI(u1.get_verify_cap().to_string()),
uri.NewDirectoryURIVerifier(n.get_verify_cap()), uri.DirectoryURIVerifier(n.get_verify_cap()),
uri.NewDirectoryURIVerifier(n.get_verify_cap().to_string()), uri.DirectoryURIVerifier(n.get_verify_cap().to_string()),
] ]
for v in verifiers: for v in verifiers:
self.failUnless(IVerifierURI.providedBy(v)) self.failUnless(IVerifierURI.providedBy(v))

View File

@ -18,9 +18,8 @@ from allmydata.util import fileutil, base32
from allmydata.util.assertutil import precondition from allmydata.util.assertutil import precondition
from allmydata.test.common import FakeDirectoryNode, FakeCHKFileNode, \ from allmydata.test.common import FakeDirectoryNode, FakeCHKFileNode, \
FakeMutableFileNode, create_chk_filenode, WebErrorMixin, ShouldFailMixin FakeMutableFileNode, create_chk_filenode, WebErrorMixin, ShouldFailMixin
from allmydata.interfaces import IURI, INewDirectoryURI, \ from allmydata.interfaces import IURI, IDirectoryURI, IReadonlyDirectoryURI, \
IReadonlyNewDirectoryURI, IFileURI, IMutableFileURI, IMutableFileNode, \ IFileURI, IMutableFileURI, IMutableFileNode, UnhandledCapTypeError
UnhandledCapTypeError
from allmydata.mutable import servermap, publish, retrieve from allmydata.mutable import servermap, publish, retrieve
import common_util as testutil import common_util as testutil
from allmydata.test.no_network import GridTestMixin from allmydata.test.no_network import GridTestMixin
@ -70,8 +69,7 @@ class FakeClient(service.MultiService):
auri = readcap auri = readcap
precondition(isinstance(auri, str), auri) precondition(isinstance(auri, str), auri)
u = uri.from_string(auri) u = uri.from_string(auri)
if (INewDirectoryURI.providedBy(u) if (IDirectoryURI.providedBy(u) or IReadonlyDirectoryURI.providedBy(u)):
or IReadonlyNewDirectoryURI.providedBy(u)):
return FakeDirectoryNode(self).init_from_uri(u) return FakeDirectoryNode(self).init_from_uri(u)
if IFileURI.providedBy(u): if IFileURI.providedBy(u):
return FakeCHKFileNode(u, self) return FakeCHKFileNode(u, self)
@ -1868,7 +1866,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, unittest.TestCase):
def test_POST_mkdir_no_parentdir_noredirect(self): def test_POST_mkdir_no_parentdir_noredirect(self):
d = self.POST("/uri?t=mkdir") d = self.POST("/uri?t=mkdir")
def _after_mkdir(res): def _after_mkdir(res):
uri.NewDirectoryURI.init_from_string(res) uri.DirectoryURI.init_from_string(res)
d.addCallback(_after_mkdir) d.addCallback(_after_mkdir)
return d return d

View File

@ -5,7 +5,7 @@ from twisted.python.components import registerAdapter
from allmydata.storage.server import si_a2b, si_b2a from allmydata.storage.server import si_a2b, si_b2a
from allmydata.util import base32, hashutil from allmydata.util import base32, hashutil
from allmydata.interfaces import IURI, IDirnodeURI, IFileURI, IImmutableFileURI, \ from allmydata.interfaces import IURI, IDirnodeURI, IFileURI, IImmutableFileURI, \
IVerifierURI, IMutableFileURI, INewDirectoryURI, IReadonlyNewDirectoryURI IVerifierURI, IMutableFileURI, IDirectoryURI, IReadonlyDirectoryURI
class BadURIError(Exception): class BadURIError(Exception):
pass pass
@ -330,7 +330,7 @@ class SSKVerifierURI(_BaseURI):
return 'URI:SSK-Verifier:%s:%s' % (si_b2a(self.storage_index), return 'URI:SSK-Verifier:%s:%s' % (si_b2a(self.storage_index),
base32.b2a(self.fingerprint)) base32.b2a(self.fingerprint))
class _NewDirectoryBaseURI(_BaseURI): class _DirectoryBaseURI(_BaseURI):
implements(IURI, IDirnodeURI) implements(IURI, IDirnodeURI)
def __init__(self, filenode_uri=None): def __init__(self, filenode_uri=None):
self._filenode_uri = filenode_uri self._filenode_uri = filenode_uri
@ -379,13 +379,13 @@ class _NewDirectoryBaseURI(_BaseURI):
return True return True
def get_verify_cap(self): def get_verify_cap(self):
return NewDirectoryURIVerifier(self._filenode_uri.get_verify_cap()) return DirectoryURIVerifier(self._filenode_uri.get_verify_cap())
def get_storage_index(self): def get_storage_index(self):
return self._filenode_uri.get_storage_index() return self._filenode_uri.get_storage_index()
class NewDirectoryURI(_NewDirectoryBaseURI): class DirectoryURI(_DirectoryBaseURI):
implements(INewDirectoryURI) implements(IDirectoryURI)
BASE_STRING='URI:DIR2:' BASE_STRING='URI:DIR2:'
BASE_STRING_RE=re.compile('^'+BASE_STRING) BASE_STRING_RE=re.compile('^'+BASE_STRING)
@ -395,16 +395,16 @@ class NewDirectoryURI(_NewDirectoryBaseURI):
def __init__(self, filenode_uri=None): def __init__(self, filenode_uri=None):
if filenode_uri: if filenode_uri:
assert not filenode_uri.is_readonly() assert not filenode_uri.is_readonly()
_NewDirectoryBaseURI.__init__(self, filenode_uri) _DirectoryBaseURI.__init__(self, filenode_uri)
def is_readonly(self): def is_readonly(self):
return False return False
def get_readonly(self): def get_readonly(self):
return ReadonlyNewDirectoryURI(self._filenode_uri.get_readonly()) return ReadonlyDirectoryURI(self._filenode_uri.get_readonly())
class ReadonlyNewDirectoryURI(_NewDirectoryBaseURI): class ReadonlyDirectoryURI(_DirectoryBaseURI):
implements(IReadonlyNewDirectoryURI) implements(IReadonlyDirectoryURI)
BASE_STRING='URI:DIR2-RO:' BASE_STRING='URI:DIR2-RO:'
BASE_STRING_RE=re.compile('^'+BASE_STRING) BASE_STRING_RE=re.compile('^'+BASE_STRING)
@ -414,7 +414,7 @@ class ReadonlyNewDirectoryURI(_NewDirectoryBaseURI):
def __init__(self, filenode_uri=None): def __init__(self, filenode_uri=None):
if filenode_uri: if filenode_uri:
assert filenode_uri.is_readonly() assert filenode_uri.is_readonly()
_NewDirectoryBaseURI.__init__(self, filenode_uri) _DirectoryBaseURI.__init__(self, filenode_uri)
def is_readonly(self): def is_readonly(self):
return True return True
@ -422,7 +422,7 @@ class ReadonlyNewDirectoryURI(_NewDirectoryBaseURI):
def get_readonly(self): def get_readonly(self):
return self return self
class NewDirectoryURIVerifier(_NewDirectoryBaseURI): class DirectoryURIVerifier(_DirectoryBaseURI):
implements(IVerifierURI) implements(IVerifierURI)
BASE_STRING='URI:DIR2-Verifier:' BASE_STRING='URI:DIR2-Verifier:'
@ -460,11 +460,11 @@ def from_string(s):
elif s.startswith('URI:SSK-Verifier:'): elif s.startswith('URI:SSK-Verifier:'):
return SSKVerifierURI.init_from_string(s) return SSKVerifierURI.init_from_string(s)
elif s.startswith('URI:DIR2:'): elif s.startswith('URI:DIR2:'):
return NewDirectoryURI.init_from_string(s) return DirectoryURI.init_from_string(s)
elif s.startswith('URI:DIR2-RO:'): elif s.startswith('URI:DIR2-RO:'):
return ReadonlyNewDirectoryURI.init_from_string(s) return ReadonlyDirectoryURI.init_from_string(s)
elif s.startswith('URI:DIR2-Verifier:'): elif s.startswith('URI:DIR2-Verifier:'):
return NewDirectoryURIVerifier.init_from_string(s) return DirectoryURIVerifier.init_from_string(s)
return UnknownURI(s) return UnknownURI(s)
registerAdapter(from_string, str, IURI) registerAdapter(from_string, str, IURI)