- # set this to something realistic to trace down a given object(s)
- trace_type="Node"
- trace_ids=[]
- def trace (message):
- if classname == trace_type and peer_object_id in trace_ids:
- message_verbose('TRACE>>'+message)
+
+ # peer_object_id, peer_object and object are dynamically bound in the loop below...
+ # (local) object might be None if creating a new one
+ def message_focus (message):
+ if classname != focus_type: return
+ if peer_object_id in focus_ids or \
+ (object and primary_key in object and object[primary_key] in focus_ids):
+ # always show remote
+ message_verbose("peer_obj : %d [[%r]]"%(peer_object_id,peer_object),
+ header='FOCUS '+message)
+ # show local object if a match was found
+ if object: message_verbose("local_obj : <<%r>>"%(object),
+ header='FOCUS '+message);
+
+ # the function to compare a local object with its cadidate peer obj
+ # xxx probably faster when compatibility is False...
+ def equal_fields (object, peer_object, columns):
+ # fast version: must use __eq__() instead of == since
+ # peer_object may be a raw dict instead of a Peer object.
+ if not compatibility: return object.__eq__(peer_object)
+ else:
+ for column in columns:
+ if object[column] != peer_object[column]: return False
+ return True