changeset 2174:7421e91056a1

pass info to the receivers of item_modified signal
author Ana Balica <ana.balica@gmail.com>
date Mon, 12 Aug 2013 21:31:06 +0300
parents c9beccffb132
children d7842de4dbb2
files MoinMoin/apps/frontend/views.py MoinMoin/items/__init__.py MoinMoin/signalling/log.py MoinMoin/util/notifications.py
diffstat 4 files changed, 17 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/views.py	Mon Aug 12 21:24:11 2013 +0300
+++ b/MoinMoin/apps/frontend/views.py	Mon Aug 12 21:31:06 2013 +0300
@@ -737,7 +737,7 @@
         item = Item.create(item_name)
         revid, size = item.modify({}, data, contenttype_guessed=contenttype)
         item_modified.send(app._get_current_object(),
-                           item_name=item_name)
+                           item_name=item_name, action=ACTION_SAVE)
         return jsonify(name=subitem_name,
                        size=size,
                        url=url_for('.show_item', item_name=item_name, rev=revid),
--- a/MoinMoin/items/__init__.py	Mon Aug 12 21:24:11 2013 +0300
+++ b/MoinMoin/items/__init__.py	Mon Aug 12 21:31:06 2013 +0300
@@ -54,6 +54,7 @@
 from MoinMoin.constants.itemtypes import (
     ITEMTYPE_NONEXISTENT, ITEMTYPE_USERPROFILE, ITEMTYPE_DEFAULT,
 )
+from MoinMoin.util.notifications import DESTROY_REV, DESTROY_ALL
 
 from .content import content_registry, Content, NonExistentContent, Draw
 
@@ -393,6 +394,9 @@
         else:
             # just destroy this revision
             self.rev.item.destroy_revision(self.rev.revid)
+        action = DESTROY_ALL if destroy_item else DESTROY_REV
+        item_modified.send(app._get_current_object(), item_name=self.name, action=action, meta=self.meta,
+                           content=self.content)
 
     def modify(self, meta, data, comment=u'', contenttype_guessed=None, **update_meta):
         meta = dict(meta)  # we may get a read-only dict-like, copy it
@@ -517,7 +521,7 @@
                                              contenttype_guessed=contenttype_guessed,
                                              return_rev=True,
                                              )
-        item_modified.send(app._get_current_object(), item_name=name)
+        item_modified.send(app, item_name=name, action=action)
         return newrev.revid, newrev.meta[SIZE]
 
     @property
--- a/MoinMoin/signalling/log.py	Mon Aug 12 21:24:11 2013 +0300
+++ b/MoinMoin/signalling/log.py	Mon Aug 12 21:31:06 2013 +0300
@@ -20,7 +20,7 @@
 
 
 @item_modified.connect_via(ANY)
-def log_item_modified(app, item_name):
+def log_item_modified(app, item_name, **kwargs):
     wiki_name = app.cfg.interwikiname
     logging.info(u"item {0}:{1} modified".format(wiki_name, item_name))
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/util/notifications.py	Mon Aug 12 21:31:06 2013 +0300
@@ -0,0 +1,10 @@
+# Copyright: 2013 MoinMoin:AnaBalica
+# License: GNU GPL v2 (or any later version), see LICENSE.txt for details.
+
+"""
+    MoinMoin - Notifications
+"""
+
+# destroy types
+DESTROY_REV = u"DESTROY_REV"
+DESTROY_ALL = u"DESTROY_ALL"