#NEWLINE# def _GetScatterProperty( entity_proto ) : #NEWLINE# #INDENT# 'Gets the scatter property for an object.\n\n  For ease of implementation, this is not synchronized with the actual\n  value on the App Engine server, but should work equally well.\n\n  Note: This property may change, either here or in production. No client\n  other than the mapper framework should rely on it directly.\n\n  Returns:\n    The PropertyValue of the scatter property or None if this entity should not\n    have a scatter property.\n  ' #NEWLINE# hash_obj = _MD5_FUNC ( ) #NEWLINE# for element in entity_proto . key ( ) . path ( ) . element_list ( ) : #NEWLINE# #INDENT# if element . has_name ( ) : #NEWLINE# #INDENT# hash_obj . update ( element . name ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if element . has_id ( ) : #NEWLINE# #INDENT# hash_obj . update ( str ( element . id ( ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# hash_bytes = hash_obj . digest ( ) [ 0 : 2 ] #NEWLINE# ( hash_int , ) = struct . unpack ( 'H' , element ) #NEWLINE# if ( hash_int >= _SCATTER_PROPORTION ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# scatter_property = entity_pb . Property ( ) #NEWLINE# scatter_property . set_name ( '__scatter__' ) #NEWLINE# scatter_property . set_meaning ( entity_pb . Property . BYTESTRING ) #NEWLINE# scatter_property . set_multiple ( False ) #NEWLINE# property_value = scatter_property . mutable_value ( ) #NEWLINE# property_value . set_stringvalue ( hash_bytes ) #NEWLINE# return scatter_property