#NEWLINE# def marshall( self , crypto_adaptor = None ) : #NEWLINE# #INDENT# 'Marshalls the gref into something renderable:\n        {\n            "thread": An ordered thread of UpdateObjects. Ordering is\n                      arbitraryish.\n            "roots": The root nodes of this gref.\n            "tips": The string names of the tips used to marshall\n        }\n        ' #NEWLINE# thread = [ ] #NEWLINE# root_nodes = [ ] #NEWLINE# visited_nodes = set ( ) #NEWLINE# tips = [ ] #NEWLINE# signatures = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# def _process( node ) : #NEWLINE# #INDENT# if ( node in visited_nodes ) : #NEWLINE# #INDENT# log . debug ( ( 'Bailing on visited node: %s' % node ) ) #NEWLINE# return #NEWLINE# #UNINDENT# visited_nodes . add ( node ) #NEWLINE# if crypto_adaptor : #NEWLINE# #INDENT# signature = self . get_signature ( node ) #NEWLINE# if signature : #NEWLINE# #INDENT# signatures [ node ] = crypto_adaptor . verify ( node , signature ) #NEWLINE# #UNINDENT# #UNINDENT# obj = object_factory . hydrate_object ( self . store [ node ] . data ) #NEWLINE# if isinstance ( obj , RootObject ) : #NEWLINE# #INDENT# root_nodes . append ( obj ) #NEWLINE# return #NEWLINE# #UNINDENT# for tip in obj . parents : #NEWLINE# #INDENT# _process ( tip ) #NEWLINE# #UNINDENT# thread . insert ( 0 , obj ) #NEWLINE# #UNINDENT# for tip in self : #NEWLINE# #INDENT# tips . append ( tip ) #NEWLINE# log . debug ( ( 'Descending into %s' % tip ) ) #NEWLINE# _process ( tip ) #NEWLINE# #UNINDENT# return { #NEWLINE# #INDENT# 'thread' : thread , #NEWLINE# 'roots' : root_nodes , #NEWLINE# 'tips' : tips , #NEWLINE# 'signatures' : signatures , #NEWLINE# #UNINDENT# }