from Products.ERP5Type.Core.Folder import FolderMixIn
from thread import get_ident
from DateTime import DateTime

def _generatePerThreadId(self):
  """
  Generate the id based on the thread_id so that we can avoid conflict errors
  when there are a lot of write access in the Folder.
  """
  thread_id = get_ident()
  current_month = DateTime().strftime('%Y%m')
  my_id = self._generateRandomId()
  return "%s%s-%s" %(current_month, thread_id, my_id)

FolderMixIn._generatePerThreadId = _generatePerThreadId
