Logo Search packages:      
Sourcecode: zope-btreefolder2 version File versions  Download package

def BTreeFolder2::BTreeFolder2::BTreeFolder2Base::generateId (   self,
  prefix = 'item',
  suffix = '',
  rand_ceiling = 999999999 
)
Returns an ID not used yet by this folder.

The ID is unlikely to collide with other threads and clients.
The IDs are sequential to optimize access to objects
that are likely to have some relation.

Definition at line 466 of file BTreeFolder2.py.

                                                                          :
        """Returns an ID not used yet by this folder.

        The ID is unlikely to collide with other threads and clients.
        The IDs are sequential to optimize access to objects
        that are likely to have some relation.
        """
        tree = self._tree
        n = self._v_nextid
        attempt = 0
        while 1:
            if n % 4000 != 0 and n <= rand_ceiling:
                id = '%s%d%s' % (prefix, n, suffix)
                if not tree.has_key(id):
                    break
            n = randint(1, rand_ceiling)
            attempt = attempt + 1
            if attempt > MAX_UNIQUEID_ATTEMPTS:
                # Prevent denial of service
                raise ExhaustedUniqueIdsError
        self._v_nextid = n + 1
        return id


Generated by  Doxygen 1.6.0   Back to index