+# historical note: this class used to be in util/guid.py but is used only here
+# FIXME: This class is not thread-safe. Should it be made thread-safe?
+class GuidGenerator(object):
+ def __init__(self):
+ self._last_guid = 0
+
+ # historical note: this used to be called `next`
+ # which confused 2to3 - and me - while it has
+ # nothing to do at all with the iteration protocol
+ def generate(self, guid = None):
+ if guid == None:
+ guid = self._last_guid + 1
+
+ self._last_guid = self._last_guid if guid <= self._last_guid else guid
+
+ return guid
+