def web2py_uuid(ctokens=UNPACKED_CTOKENS):
 rand_longs = (random.getrandbits(64), random.getrandbits(64))
 if HAVE_URANDOM:
  urand_longs = _struct_2_long_long.unpack(fast_urandom16())
  byte_s = _struct_2_long_long.pack(((rand_longs[0] ^ urand_longs[0]) ^ ctokens[0]), ((rand_longs[1] ^ urand_longs[1]) ^ ctokens[1]))
 else:
  byte_s = _struct_2_long_long.pack((rand_longs[0] ^ ctokens[0]), (rand_longs[1] ^ ctokens[1]))
 return str(uuid.UUID(bytes=byte_s, version=4))

def web2py_uuid ( ctokens = UNPACKED_CTOKENS ) : rand_longs = ( random . getrandbits ( 64 ) , random . getrandbits ( 64 ) ) if HAVE_URANDOM : urand_longs = _struct_2_long_long . unpack ( fast_urandom16 ( ) ) byte_s = _struct_2_long_long . pack ( ( ( rand_longs [ 0 ] ^ urand_longs [ 0 ] ) ^ ctokens [ 0 ] ) , ( ( rand_longs [ 1 ] ^ urand_longs [ 1 ] ) ^ ctokens [ 1 ] ) ) else : byte_s = _struct_2_long_long . pack ( ( rand_longs [ 0 ] ^ ctokens [ 0 ] ) , ( rand_longs [ 1 ] ^ ctokens [ 1 ] ) ) return str ( uuid . UUID ( bytes = byte_s , version = 4 ) )
this function follows from the following discussion: URL it works like uuid .