Esempio n. 1
0
 def _restore(self, data, obj):
     """
     restores key, values from data into object
     Optionally decode form Pid specified keys
     """
     if obj is None: return None
     restore = self.context.restore
     reference = self.context.referenceObject
     for item in data[tags.ITEMS]:
         key,value = restore(item, reset=False)
         if key in self.encodedKeys and \
            reference is not None:
             obj[key] = pid.decodePid(reference, value)
         else:
             obj[key] = value
     #end for
     return obj
Esempio n. 2
0
 def restore(self, data):
     reference = self.context.referenceObject
     tree = ntu.NTtree(name=data['name'])
     self._restore(data, tree)
     for child in tree._children:
         if isinstance(child, pid.Pid) and \
            reference is not None and \
            isinstance(reference, Project.Project):
             childObj = pid.decodePid(reference, child)
         else:
             childObj = child
         #end if
         if childObj is not None:
             #establish backward and forward linkages
             tree[child.name] = childObj
             childObj._parent = tree
         #end if
     #end for
     return tree