nodetype, d = parsed
assert nodetype == "dirnode"
self.mutable = d.get("mutable", False) # older nodes don't provide it
- self.children_d = d["children"]
+ self.children_d = dict( [(unicode(name),value)
+ for (name,value)
+ in d["children"].iteritems()] )
self.children = None
def init_from_parsed(self, parsed):
self.writecap = ascii_or_none(d.get("rw_uri"))
self.readcap = ascii_or_none(d.get("ro_uri"))
self.mutable = d.get("mutable", False) # older nodes don't provide it
- self.children_d = d["children"]
+ self.children_d = dict( [(unicode(name),value)
+ for (name,value)
+ in d["children"].iteritems()] )
self.children = None
def populate(self, recurse):
self.writecap = ascii_or_none(d.get("rw_uri"))
self.readcap = ascii_or_none(d.get("ro_uri"))
self.mutable = d.get("mutable", False) # older nodes don't provide it
- self.children_d = d["children"]
+ self.children_d = dict( [(unicode(name),value)
+ for (name,value)
+ in d["children"].iteritems()] )
self.children = None
def init_from_grid(self, writecap, readcap):
nodetype, d = parsed
assert nodetype == "dirnode"
self.mutable = d.get("mutable", False) # older nodes don't provide it
- self.children_d = d["children"]
+ self.children_d = dict( [(unicode(name),value)
+ for (name,value)
+ in d["children"].iteritems()] )
self.children = None
def just_created(self, writecap):
rows = []
for name in childnames:
+ name = unicode(name)
child = children[name]
childtype = child[0]
ctime = child[1]["metadata"].get("ctime")
data = urllib.urlopen(from_url + "?t=json").read()
nodetype, attrs = simplejson.loads(data)
cap = attrs.get("rw_uri") or attrs["ro_uri"]
- # simplejson always returns unicode, but we know that it's really just an
- # ASCII file-cap.
+ # simplejson sometimes returns unicode, but we know that it's really just
+ # an ASCII file-cap.
cap = str(cap)
# now get the target
assert nodetype == "dirnode"
global directories_read
directories_read += 1
- return d['children']
+ children = dict( [(unicode(name),value)
+ for (name,value)
+ in d["children"].iteritems()] )
+ return children
def choose_random_descendant(server_url, root, pathname=""):
def failUnlessIsBarJSON(self, res):
data = simplejson.loads(res)
self.failUnless(isinstance(data, list))
- self.failUnlessEqual(data[0], "filenode")
+ self.failUnlessEqual(data[0], u"filenode")
self.failUnless(isinstance(data[1], dict))
self.failIf(data[1]["mutable"])
self.failIf("rw_uri" in data[1]) # immutable
self.failUnlessEqual(data[1]["rw_uri"], self._foo_uri)
self.failUnlessEqual(data[1]["ro_uri"], self._foo_readonly_uri)
- kidnames = sorted(data[1]["children"])
+ kidnames = sorted([unicode(n) for n in data[1]["children"]])
self.failUnlessEqual(kidnames,
[u"bar.txt", u"blockingfile", u"empty",
u"n\u00fc.txt", u"sub"])
- kids = data[1]["children"]
+ kids = dict( [(unicode(name),value)
+ for (name,value)
+ in data[1]["children"].iteritems()] )
self.failUnlessEqual(kids[u"sub"][0], "dirnode")
self.failUnless("metadata" in kids[u"sub"][1])
self.failUnless("ctime" in kids[u"sub"][1]["metadata"])
def _check_page_json(res):
parsed = simplejson.loads(res)
self.failUnlessEqual(parsed[0], "dirnode")
- children = parsed[1]["children"]
+ children = dict( [(unicode(name),value)
+ for (name,value)
+ in parsed[1]["children"].iteritems()] )
self.failUnless("new.txt" in children)
new_json = children["new.txt"]
self.failUnlessEqual(new_json[0], "filenode")
raise
cs = []
for name, (file_or_dir, mddict) in children.iteritems():
+ name = unicode(name) # simplejson-2.0.1 returns str *or* unicode
cap = str(mddict.get('rw_uri') or mddict.get('ro_uri'))
cs.append((name, cap, mddict.get('metadata')))
d = self.node.set_children(cs, replace)