Description

MoinMoin sends two events for new accounts when you hit the "create + send email" button.

Steps to reproduce

  1. log in as superuser
  2. subscribe to new account notifications
  3. log out
  4. create new user and hit "create + send email" button
  5. see two notifications

Component selection

Details

Here are two stacktraces I captured:

  File "/usr/local/src/moin/MoinMoin/action/newaccount.py", line 180, in execute
    request.theme.add_msg(_create_user(request), "dialog")
  File "/usr/local/src/moin/MoinMoin/action/newaccount.py", line 84, in _create_user
    theuser.save()
  File "/usr/local/src/moin/MoinMoin/user.py", line 594, in save
    events.send_event(event)
  File "/usr/local/src/moin/MoinMoin/events/__init__.py", line 242, in send_event
    retval = handle(event)
  File "/usr/local/src/moin/MoinMoin/events/emailnotify.py", line 173, in handle
    return handle_user_created(event)
  File "/usr/local/src/moin/MoinMoin/events/emailnotify.py", line 125, in handle_user_created
    send_notification(request, from_address, [usr.email], data, trace=True)
  File "/usr/local/src/moin/MoinMoin/events/emailnotify.py", line 68, in send_notification
    txt += '\n' + ''.join(traceback.format_stack())

  File "/usr/local/src/moin/MoinMoin/action/newaccount.py", line 180, in execute
    request.theme.add_msg(_create_user(request), "dialog")
  File "/usr/local/src/moin/MoinMoin/action/newaccount.py", line 87, in _create_user
    theuser.mailAccountData()
  File "/usr/local/src/moin/MoinMoin/user.py", line 1019, in mailAccountData
    tok = self.generate_recovery_token()
  File "/usr/local/src/moin/MoinMoin/user.py", line 987, in generate_recovery_token
    self.save()
  File "/usr/local/src/moin/MoinMoin/user.py", line 594, in save
    events.send_event(event)
  File "/usr/local/src/moin/MoinMoin/events/__init__.py", line 242, in send_event
    retval = handle(event)
  File "/usr/local/src/moin/MoinMoin/events/emailnotify.py", line 173, in handle
    return handle_user_created(event)
  File "/usr/local/src/moin/MoinMoin/events/emailnotify.py", line 125, in handle_user_created
    send_notification(request, from_address, [usr.email], data, trace=True)
  File "/usr/local/src/moin/MoinMoin/events/emailnotify.py", line 68, in send_notification
    txt += '\n' + ''.join(traceback.format_stack())

MoinMoin Version

1.7 and 1.8

Workaround

N/A

Discussion

The problem appears to be that User.save() has the following check:

   1         if not self._loaded:
   2             event = events.UserCreatedEvent(self._request, self)
   3             events.send_event(event)

but the code in the newaccount action ends up saving the same user object twice, when obviously it doesn't have _loaded set to True. This should probably be called "_in_storage" instead of "_loaded" and set to True in .save() as well.

Another issue is that the "create + email" button is entirely useless because you only get password recovery instructions. And you've just set your password...

Plan


CategoryMoinMoinBugFixed

MoinMoin: MoinMoinBugs/DuplicateNewUserNotification (last edited 2008-07-14 11:20:27 by JohannesBerg)