]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
rename NewDirectoryNode to DirectoryNode, NewDirectoryURI to DirectoryURI trac-4000
authorBrian Warner <warner@lothar.com>
Fri, 17 Jul 2009 01:01:03 +0000 (20:01 -0500)
committerBrian Warner <warner@lothar.com>
Fri, 17 Jul 2009 22:15:49 +0000 (17:15 -0500)
src/allmydata/client.py
src/allmydata/dirnode.py
src/allmydata/interfaces.py
src/allmydata/scripts/debug.py
src/allmydata/test/bench_dirnode.py
src/allmydata/test/common.py
src/allmydata/test/test_cli.py
src/allmydata/test/test_dirnode.py
src/allmydata/test/test_uri.py
src/allmydata/test/test_web.py
src/allmydata/uri.py

index 35f55c0988b3ffa71036069096a10c35ee4ab049..6d9b2280e0db08104cb093f4f5985bc97f74ad9b 100644 (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.time_format import parse_duration, parse_date
 from allmydata.uri import LiteralFileURI, UnknownURI
-from allmydata.dirnode import NewDirectoryNode
+from allmydata.dirnode import DirectoryNode
 from allmydata.mutable.filenode import MutableFileNode
 from allmydata.unknown import UnknownNode
 from allmydata.stats import StatsProvider
 from allmydata.history import History
-from allmydata.interfaces import IURI, INewDirectoryURI, IStatsProducer, \
-     IReadonlyNewDirectoryURI, IFileURI, IMutableFileURI, RIStubClient, \
+from allmydata.interfaces import IURI, IDirectoryURI, IStatsProducer, \
+     IReadonlyDirectoryURI, IFileURI, IMutableFileURI, RIStubClient, \
      UnhandledCapTypeError
 
 KiB=1024
@@ -419,12 +419,12 @@ class Client(node.Node, pollmixin.PollMixin):
             return UnknownNode(writecap, readcap)
         u_s = u.to_string()
         if u_s not in self._node_cache:
-            if IReadonlyNewDirectoryURI.providedBy(u):
-                # new-style read-only dirnodes
-                node = NewDirectoryNode(self).init_from_uri(u)
-            elif INewDirectoryURI.providedBy(u):
-                # new-style dirnodes
-                node = NewDirectoryNode(self).init_from_uri(u)
+            if IReadonlyDirectoryURI.providedBy(u):
+                # read-only dirnodes
+                node = DirectoryNode(self).init_from_uri(u)
+            elif IDirectoryURI.providedBy(u):
+                # dirnodes
+                node = DirectoryNode(self).init_from_uri(u)
             elif IFileURI.providedBy(u):
                 if isinstance(u, LiteralFileURI):
                     node = LiteralFileNode(u, self) # LIT
@@ -439,7 +439,7 @@ class Client(node.Node, pollmixin.PollMixin):
 
     def create_empty_dirnode(self):
         d = self.create_mutable_file()
-        d.addCallback(NewDirectoryNode.create_with_mutablefile, self)
+        d.addCallback(DirectoryNode.create_with_mutablefile, self)
         return d
 
     def create_mutable_file(self, contents="", keysize=None):
index 83a96ece0984e25660d2400ce53e5d1f6a68312f..b06836f323c5d8eec3a8d5b43c6e76a091b8c315 100644 (file)
@@ -18,7 +18,7 @@ from allmydata.monitor import Monitor
 from allmydata.util import hashutil, mathutil, base32, log
 from allmydata.util.assertutil import _assert, precondition
 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
 
 class CachingDict(dict):
@@ -140,7 +140,7 @@ class Adder:
         new_contents = self.node._pack_contents(children)
         return new_contents
 
-class NewDirectoryNode:
+class DirectoryNode:
     implements(IDirectoryNode, ICheckable, IDeepCheckable)
     filenode_class = MutableFileNode
 
@@ -175,7 +175,7 @@ class NewDirectoryNode:
         d.addCallback(self._filenode_created)
         return d
     def _filenode_created(self, res):
-        self._uri = NewDirectoryURI(IMutableFileURI(self._node.get_uri()))
+        self._uri = DirectoryURI(IMutableFileURI(self._node.get_uri()))
         return self
 
     def get_size(self):
index e2df33051a54802edd927efef658b0217bfea936..67de6165f2d3f1cd6a2c288593b1c801e886d82e 100644 (file)
@@ -467,9 +467,9 @@ class IImmutableFileURI(IFileURI):
 
 class IMutableFileURI(Interface):
     """I am a URI which represents a mutable filenode."""
-class INewDirectoryURI(Interface):
+class IDirectoryURI(Interface):
     pass
-class IReadonlyNewDirectoryURI(Interface):
+class IReadonlyDirectoryURI(Interface):
     pass
 
 class CannotPackUnknownNodeError(Exception):
@@ -2023,7 +2023,7 @@ class IClient(Interface):
                  IFileNode or IMutableFileNode -providing instances, like
                  FileNode, LiteralFileNode, or MutableFileNode.
                  Directory-specifying URIs will result in
-                 IDirectoryNode-providing instances, like NewDirectoryNode.
+                 IDirectoryNode-providing instances, like DirectoryNode.
         """
 
 class IClientStatus(Interface):
index 618a556f73573d8274780121f0f1974d1361796c..c85bfca305652cebb0cf4f745d1d2db96bd15ab1 100644 (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, " fingerprint:", base32.b2a(u.fingerprint)
 
-    elif isinstance(u, uri.NewDirectoryURI):
+    elif isinstance(u, uri.DirectoryURI):
         if show_header:
             print >>out, "Directory Writeable URI:"
         dump_uri_instance(u._filenode_uri, nodeid, secret, out, False)
-    elif isinstance(u, uri.ReadonlyNewDirectoryURI):
+    elif isinstance(u, uri.ReadonlyDirectoryURI):
         if show_header:
             print >>out, "Directory Read-only URI:"
         dump_uri_instance(u._filenode_uri, nodeid, secret, out, False)
-    elif isinstance(u, uri.NewDirectoryURIVerifier):
+    elif isinstance(u, uri.DirectoryURIVerifier):
         if show_header:
             print >>out, "Directory Verifier URI:"
         dump_uri_instance(u._filenode_uri, nodeid, secret, out, False)
index e5f969a6cdc492fd5a02cc0a2a120a6ad70da635..df534345b18d8a5aff1d054dff2b667774b58bab 100644 (file)
@@ -25,19 +25,19 @@ class FakeMutableFileNode(mut_filenode.MutableFileNode):
         mut_filenode.MutableFileNode.__init__(self, client)
         self._uri = uri.WriteableSSKFileURI(randutil.insecurerandstr(16), randutil.insecurerandstr(32))
 
-class FakeDirectoryNode(dirnode.NewDirectoryNode):
+class FakeDirectoryNode(dirnode.DirectoryNode):
     def __init__(self, client):
-        dirnode.NewDirectoryNode.__init__(self, client)
+        dirnode.DirectoryNode.__init__(self, client)
         mutfileuri = uri.WriteableSSKFileURI(randutil.insecurerandstr(16), randutil.insecurerandstr(32))
-        myuri = uri.NewDirectoryURI(mutfileuri)
+        myuri = uri.DirectoryURI(mutfileuri)
         self.init_from_uri(myuri)
 
 
 children = [] # tuples of (k, v) (suitable for passing to dict())
 packstr = None
 fakeclient = FakeClient()
-testdirnode = dirnode.NewDirectoryNode(fakeclient)
-testdirnode.init_from_uri(uri.NewDirectoryURI(uri.WriteableSSKFileURI(randutil.insecurerandstr(16), randutil.insecurerandstr(32))))
+testdirnode = dirnode.DirectoryNode(fakeclient)
+testdirnode.init_from_uri(uri.DirectoryURI(uri.WriteableSSKFileURI(randutil.insecurerandstr(16), randutil.insecurerandstr(32))))
 
 def random_unicode(l):
     while True:
index 97f4bc3f5ee18f3be4760595def6e608d30d2096..dfd88388bb551f9625eb4c83243f492b7edfadb1 100644 (file)
@@ -290,7 +290,7 @@ def make_verifier_uri():
     return uri.SSKVerifierURI(storage_index=os.urandom(16),
                               fingerprint=os.urandom(32))
 
-class FakeDirectoryNode(dirnode.NewDirectoryNode):
+class FakeDirectoryNode(dirnode.DirectoryNode):
     """This offers IDirectoryNode, but uses a FakeMutableFileNode for the
     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
index 8efccb2bf23196ad95cfb7420ea3288cea815d6f..a2179a48905ee021c9e25be4980c38cbca25fc32 100644 (file)
@@ -37,7 +37,7 @@ class CLI(unittest.TestCase):
         open("cli/test_options/node.url","w").write("http://localhost:8080/\n")
         filenode_uri = uri.WriteableSSKFileURI(writekey="\x00"*16,
                                                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")
         o = cli.ListOptions()
         o.parseOptions(["--node-directory", "cli/test_options"])
@@ -62,7 +62,7 @@ class CLI(unittest.TestCase):
         o = cli.ListOptions()
         other_filenode_uri = uri.WriteableSSKFileURI(writekey="\x11"*16,
                                                      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",
                         "--dir-cap", other_uri])
         self.failUnlessEqual(o['node-url'], "http://localhost:8080/")
@@ -199,7 +199,7 @@ class CLI(unittest.TestCase):
         writekey = "\x01" * 16
         fingerprint = "\xfe" * 32
         u1 = uri.WriteableSSKFileURI(writekey, fingerprint)
-        u = uri.NewDirectoryURI(u1)
+        u = uri.DirectoryURI(u1)
 
         output = self._dump_cap(u.to_string())
         self.failUnless("Directory Writeable URI:" in output, output)
index 346a18533dbc35d5c57cc3711a633eae3e181aad..7ed41b2e82180883b3f396e072eabb7835a8edbe 100644 (file)
@@ -7,7 +7,7 @@ from allmydata import uri, dirnode
 from allmydata.client import Client
 from allmydata.immutable import upload
 from allmydata.interfaces import IURI, IClient, IMutableFileNode, \
-     INewDirectoryURI, IReadonlyNewDirectoryURI, IFileNode, \
+     IDirectoryURI, IReadonlyDirectoryURI, IFileNode, \
      ExistingChildError, NoSuchChildError, \
      IDeepCheckResults, IDeepCheckAndRepairResults, CannotPackUnknownNodeError
 from allmydata.mutable.filenode import MutableFileNode
@@ -83,8 +83,8 @@ class FakeClient:
         if not u:
             u = readcap
         u = IURI(u)
-        if (INewDirectoryURI.providedBy(u)
-            or IReadonlyNewDirectoryURI.providedBy(u)):
+        if (IDirectoryURI.providedBy(u)
+            or IReadonlyDirectoryURI.providedBy(u)):
             return FakeDirectoryNode(self).init_from_uri(u)
         return Marker(u.to_string())
 
@@ -929,7 +929,7 @@ class UCWEingMutableFileNode(MutableFileNode):
             return res
         d.addCallback(_ucwe)
         return d
-class UCWEingNewDirectoryNode(dirnode.NewDirectoryNode):
+class UCWEingDirectoryNode(dirnode.DirectoryNode):
     filenode_class = UCWEingMutableFileNode
 
 
@@ -957,7 +957,7 @@ class Deleter(GridTestMixin, unittest.TestCase):
             return dn.add_file(u"file", small)
         d.addCallback(_created_dir)
         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
             n._node.please_ucwe_after_next_upload = True
             # This should succeed, not raise an exception
index 0898530d2f07a36e4fe5289f3f4b198e4bd04736..6dd95a29c11da8fbe49df6947a672a0341b3caab 100644 (file)
@@ -185,11 +185,11 @@ class Invalid(unittest.TestCase):
 class Constraint(unittest.TestCase):
     def test_constraint(self):
        good="http://127.0.0.1:3456/uri/URI%3ADIR2%3Agh3l5rbvnv2333mrfvalmjfr4i%3Alz6l7u3z3b7g37s4zkdmfpx5ly4ib4m6thrpbusi6ys62qtc6mma/"
-       uri.NewDirectoryURI.init_from_human_encoding(good)
-       self.failUnlessRaises(uri.BadURIError, uri.NewDirectoryURI.init_from_string, good)
+       uri.DirectoryURI.init_from_human_encoding(good)
+       self.failUnlessRaises(uri.BadURIError, uri.DirectoryURI.init_from_string, good)
        bad = good + '==='
-       self.failUnlessRaises(uri.BadURIError, uri.NewDirectoryURI.init_from_human_encoding, bad)
-       self.failUnlessRaises(uri.BadURIError, uri.NewDirectoryURI.init_from_string, bad)
+       self.failUnlessRaises(uri.BadURIError, uri.DirectoryURI.init_from_human_encoding, bad)
+       self.failUnlessRaises(uri.BadURIError, uri.DirectoryURI.init_from_string, bad)
        fileURI = 'URI:CHK:gh3l5rbvnv2333mrfvalmjfr4i:lz6l7u3z3b7g37s4zkdmfpx5ly4ib4m6thrpbusi6ys62qtc6mma:3:10:345834'
        uri.CHKFileURI.init_from_string(fileURI)
 
@@ -272,13 +272,13 @@ class NewDirnode(unittest.TestCase):
         fingerprint = "\x02" * 32
 
         n = uri.WriteableSSKFileURI(writekey, fingerprint)
-        u1 = uri.NewDirectoryURI(n)
+        u1 = uri.DirectoryURI(n)
         self.failIf(u1.is_readonly())
         self.failUnless(u1.is_mutable())
         self.failUnless(IURI.providedBy(u1))
         self.failIf(IFileURI.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()
         self.failUnless(u1_filenode.is_mutable())
         self.failIf(u1_filenode.is_readonly())
@@ -309,7 +309,7 @@ class NewDirnode(unittest.TestCase):
         u3a = uri.from_string(u3.to_string())
         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.failUnless(u4.is_readonly())
         self.failUnless(u4.is_mutable())
@@ -324,8 +324,8 @@ class NewDirnode(unittest.TestCase):
         verifiers = [u1.get_verify_cap(), u2.get_verify_cap(),
                      u3.get_verify_cap(), u4.get_verify_cap(),
                      IVerifierURI(u1.get_verify_cap().to_string()),
-                     uri.NewDirectoryURIVerifier(n.get_verify_cap()),
-                     uri.NewDirectoryURIVerifier(n.get_verify_cap().to_string()),
+                     uri.DirectoryURIVerifier(n.get_verify_cap()),
+                     uri.DirectoryURIVerifier(n.get_verify_cap().to_string()),
                      ]
         for v in verifiers:
             self.failUnless(IVerifierURI.providedBy(v))
index f7d45da064076050417df3984ff7e3d8493b1ea7..23de764d70c9e0bf52b28a6ed5b178cc0d6672f3 100644 (file)
@@ -18,9 +18,8 @@ from allmydata.util import fileutil, base32
 from allmydata.util.assertutil import precondition
 from allmydata.test.common import FakeDirectoryNode, FakeCHKFileNode, \
      FakeMutableFileNode, create_chk_filenode, WebErrorMixin, ShouldFailMixin
-from allmydata.interfaces import IURI, INewDirectoryURI, \
-     IReadonlyNewDirectoryURI, IFileURI, IMutableFileURI, IMutableFileNode, \
-     UnhandledCapTypeError
+from allmydata.interfaces import IURI, IDirectoryURI, IReadonlyDirectoryURI, \
+     IFileURI, IMutableFileURI, IMutableFileNode, UnhandledCapTypeError
 from allmydata.mutable import servermap, publish, retrieve
 import common_util as testutil
 from allmydata.test.no_network import GridTestMixin
@@ -70,8 +69,7 @@ class FakeClient(service.MultiService):
             auri = readcap
         precondition(isinstance(auri, str), auri)
         u = uri.from_string(auri)
-        if (INewDirectoryURI.providedBy(u)
-            or IReadonlyNewDirectoryURI.providedBy(u)):
+        if (IDirectoryURI.providedBy(u) or IReadonlyDirectoryURI.providedBy(u)):
             return FakeDirectoryNode(self).init_from_uri(u)
         if IFileURI.providedBy(u):
             return FakeCHKFileNode(u, self)
@@ -1868,7 +1866,7 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, unittest.TestCase):
     def test_POST_mkdir_no_parentdir_noredirect(self):
         d = self.POST("/uri?t=mkdir")
         def _after_mkdir(res):
-            uri.NewDirectoryURI.init_from_string(res)
+            uri.DirectoryURI.init_from_string(res)
         d.addCallback(_after_mkdir)
         return d
 
index b37ea8ca5b5c3e2040477decc4939b453920bcfc..43aafc5ab059e9b986b838f364ab9b5d0e8d6b8f 100644 (file)
@@ -5,7 +5,7 @@ from twisted.python.components import registerAdapter
 from allmydata.storage.server import si_a2b, si_b2a
 from allmydata.util import base32, hashutil
 from allmydata.interfaces import IURI, IDirnodeURI, IFileURI, IImmutableFileURI, \
-    IVerifierURI, IMutableFileURI, INewDirectoryURI, IReadonlyNewDirectoryURI
+    IVerifierURI, IMutableFileURI, IDirectoryURI, IReadonlyDirectoryURI
 
 class BadURIError(Exception):
     pass
@@ -330,7 +330,7 @@ class SSKVerifierURI(_BaseURI):
         return 'URI:SSK-Verifier:%s:%s' % (si_b2a(self.storage_index),
                                            base32.b2a(self.fingerprint))
 
-class _NewDirectoryBaseURI(_BaseURI):
+class _DirectoryBaseURI(_BaseURI):
     implements(IURI, IDirnodeURI)
     def __init__(self, filenode_uri=None):
         self._filenode_uri = filenode_uri
@@ -379,13 +379,13 @@ class _NewDirectoryBaseURI(_BaseURI):
         return True
 
     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):
         return self._filenode_uri.get_storage_index()
 
-class NewDirectoryURI(_NewDirectoryBaseURI):
-    implements(INewDirectoryURI)
+class DirectoryURI(_DirectoryBaseURI):
+    implements(IDirectoryURI)
 
     BASE_STRING='URI:DIR2:'
     BASE_STRING_RE=re.compile('^'+BASE_STRING)
@@ -395,16 +395,16 @@ class NewDirectoryURI(_NewDirectoryBaseURI):
     def __init__(self, filenode_uri=None):
         if filenode_uri:
             assert not filenode_uri.is_readonly()
-        _NewDirectoryBaseURI.__init__(self, filenode_uri)
+        _DirectoryBaseURI.__init__(self, filenode_uri)
 
     def is_readonly(self):
         return False
 
     def get_readonly(self):
-        return ReadonlyNewDirectoryURI(self._filenode_uri.get_readonly())
+        return ReadonlyDirectoryURI(self._filenode_uri.get_readonly())
 
-class ReadonlyNewDirectoryURI(_NewDirectoryBaseURI):
-    implements(IReadonlyNewDirectoryURI)
+class ReadonlyDirectoryURI(_DirectoryBaseURI):
+    implements(IReadonlyDirectoryURI)
 
     BASE_STRING='URI:DIR2-RO:'
     BASE_STRING_RE=re.compile('^'+BASE_STRING)
@@ -414,7 +414,7 @@ class ReadonlyNewDirectoryURI(_NewDirectoryBaseURI):
     def __init__(self, filenode_uri=None):
         if filenode_uri:
             assert filenode_uri.is_readonly()
-        _NewDirectoryBaseURI.__init__(self, filenode_uri)
+        _DirectoryBaseURI.__init__(self, filenode_uri)
 
     def is_readonly(self):
         return True
@@ -422,7 +422,7 @@ class ReadonlyNewDirectoryURI(_NewDirectoryBaseURI):
     def get_readonly(self):
         return self
 
-class NewDirectoryURIVerifier(_NewDirectoryBaseURI):
+class DirectoryURIVerifier(_DirectoryBaseURI):
     implements(IVerifierURI)
 
     BASE_STRING='URI:DIR2-Verifier:'
@@ -460,11 +460,11 @@ def from_string(s):
     elif s.startswith('URI:SSK-Verifier:'):
         return SSKVerifierURI.init_from_string(s)
     elif s.startswith('URI:DIR2:'):
-        return NewDirectoryURI.init_from_string(s)
+        return DirectoryURI.init_from_string(s)
     elif s.startswith('URI:DIR2-RO:'):
-        return ReadonlyNewDirectoryURI.init_from_string(s)
+        return ReadonlyDirectoryURI.init_from_string(s)
     elif s.startswith('URI:DIR2-Verifier:'):
-        return NewDirectoryURIVerifier.init_from_string(s)
+        return DirectoryURIVerifier.init_from_string(s)
     return UnknownURI(s)
 
 registerAdapter(from_string, str, IURI)