(self)
Generate a new value for this ObjectId.
Generate a new value for this ObjectId.
Generate a new value for this ObjectId .
def __generate(self):
        """Generate a new value for this ObjectId.
        """

        # 4 bytes current time
        oid = struct.pack(">i", int(time.time()))

        # 3 bytes machine
        oid += ObjectId._machine_bytes

        # 2 bytes pid
        oid += struct.pack(">H", os.getpid() % 0xFFFF)

        # 3 bytes inc
        with ObjectId._inc_lock:
            oid += struct.pack(">i", ObjectId._inc)[1:4]
            ObjectId._inc = (ObjectId._inc + 1) % 0xFFFFFF

        self.__id = oid
def __generate ( self ) : # 4 bytes current time oid = struct . pack ( ">i" , int ( time . time ( ) ) ) # 3 bytes machine oid += ObjectId . _machine_bytes # 2 bytes pid oid += struct . pack ( ">H" , os . getpid ( ) % 0xFFFF ) # 3 bytes inc with ObjectId . _inc_lock : oid += struct . pack ( ">i" , ObjectId . _inc ) [ 1 : 4 ] ObjectId . _inc = ( ObjectId . _inc + 1 ) % 0xFFFFFF self . __id = oid