changeset 2493:f3e3ffa68a7f

Send UserCreatedEvent from user.save(), not the newaccount action.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Sun, 22 Jul 2007 04:16:05 +0200
parents 5b8e8e7db56f
children 7283062fce1a
files MoinMoin/action/newaccount.py MoinMoin/user.py
diffstat 2 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/newaccount.py	Sun Jul 22 04:15:26 2007 +0200
+++ b/MoinMoin/action/newaccount.py	Sun Jul 22 04:16:05 2007 +0200
@@ -83,9 +83,6 @@
     # save data
     theuser.save()
 
-    user_created = events.UserCreatedEvent(request, theuser)
-    events.send_event(user_created)
-
     if form.has_key('create_and_mail'):
         theuser.mailAccountData()
 
--- a/MoinMoin/user.py	Sun Jul 22 04:15:26 2007 +0200
+++ b/MoinMoin/user.py	Sun Jul 22 04:16:05 2007 +0200
@@ -24,7 +24,7 @@
 
 import os, time, sha, codecs
 
-from MoinMoin import config, caching, wikiutil, i18n
+from MoinMoin import config, caching, wikiutil, i18n, events
 from MoinMoin.util import timefuncs, filesys
 
 
@@ -325,6 +325,7 @@
         #self.edit_cols = 80
         self.tz_offset = int(float(self._cfg.tz_offset) * 3600)
         self.language = ""
+        self.loaded = False
         self.date_fmt = ""
         self.datetime_fmt = ""
         self.quicklinks = self._cfg.quicklinks_default
@@ -492,6 +493,9 @@
         if not self.disabled:
             self.valid = 1
 
+        # Mark this user as loaded from disk, so UserCreatedEvent is not sent
+        self.loaded = True
+
         # If user data has been changed, save fixed user data.
         if changed:
             self.save()
@@ -614,6 +618,10 @@
         if not self.disabled:
             self.valid = 1
 
+        if not self.loaded:
+            event = events.UserCreatedEvent(self._request, self)
+            events.send_event(event)
+
     # -----------------------------------------------------------------
     # Time and date formatting