bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From and...@apache.org
Subject svn commit: r1457457 - in /incubator/bloodhound/trunk/trac/trac: attachment.py tests/attachment.py ticket/model.py wiki/model.py wiki/tests/model.py
Date Sun, 17 Mar 2013 14:55:14 GMT
Author: andrej
Date: Sun Mar 17 14:55:13 2013
New Revision: 1457457

URL: http://svn.apache.org/r1457457
Log:
patching trac, make consistent behaivour of old_values parameter of IResourceChangeLisntener.resource_changed
method - towards #411

Modified:
    incubator/bloodhound/trunk/trac/trac/attachment.py
    incubator/bloodhound/trunk/trac/trac/tests/attachment.py
    incubator/bloodhound/trunk/trac/trac/ticket/model.py
    incubator/bloodhound/trunk/trac/trac/wiki/model.py
    incubator/bloodhound/trunk/trac/trac/wiki/tests/model.py

Modified: incubator/bloodhound/trunk/trac/trac/attachment.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/trac/trac/attachment.py?rev=1457457&r1=1457456&r2=1457457&view=diff
==============================================================================
--- incubator/bloodhound/trunk/trac/trac/attachment.py (original)
+++ incubator/bloodhound/trunk/trac/trac/attachment.py Sun Mar 17 14:55:13 2013
@@ -288,7 +288,11 @@ class Attachment(object):
         for listener in AttachmentModule(self.env).change_listeners:
             if hasattr(listener, 'attachment_reparented'):
                 listener.attachment_reparented(self, old_realm, old_id)
-        old_values = dict(parent_realm=old_realm, parent_id=old_id)
+        old_values = dict()
+        if self.parent_realm != old_realm:
+            old_values["parent_realm"] = old_realm
+        if self.parent_id != old_id:
+            old_values["parent_id"] = old_id
         ResourceSystem(self.env).resource_changed(self, old_values=old_values)
 
     def insert(self, filename, fileobj, size, t=None, db=None):

Modified: incubator/bloodhound/trunk/trac/trac/tests/attachment.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/trac/trac/tests/attachment.py?rev=1457457&r1=1457456&r2=1457457&view=diff
==============================================================================
--- incubator/bloodhound/trunk/trac/trac/tests/attachment.py (original)
+++ incubator/bloodhound/trunk/trac/trac/tests/attachment.py Sun Mar 17 14:55:13 2013
@@ -253,8 +253,7 @@ class AttachmentResourceChangeListenerTe
         self.assertEqual(attachment.filename, self.filename)
         self.assertEqual(attachment.parent_realm, self.parent_realm)
         self.assertEqual("SomePage", self.parent_id)
-        self.assertEqual(
-            self.DUMMY_PARENT_REALM, self.listener.old_values["parent_realm"])
+        self.assertNotIn("parent_realm", self.listener.old_values)
         self.assertEqual(
             self.DUMMY_PARENT_ID, self.listener.old_values["parent_id"])
 

Modified: incubator/bloodhound/trunk/trac/trac/ticket/model.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/trac/trac/ticket/model.py?rev=1457457&r1=1457456&r2=1457457&view=diff
==============================================================================
--- incubator/bloodhound/trunk/trac/trac/ticket/model.py (original)
+++ incubator/bloodhound/trunk/trac/trac/ticket/model.py Sun Mar 17 14:55:13 2013
@@ -770,7 +770,11 @@ class AbstractEnum(object):
                    (self.name, self._old_name))
             TicketSystem(self.env).reset_ticket_fields()
 
-        old_values = dict(name=self._old_name, value=self._old_value)
+        old_values = dict()
+        if self.name != self._old_name:
+            old_values["name"] = self._old_name
+        if self.value != self._old_value:
+            old_values["value"] = self._old_value
         self._old_name = self.name
         self._old_value = self.value
         ResourceSystem(self.env).resource_changed(self, old_values)
@@ -905,7 +909,10 @@ class Component(object):
                 self._old_name = self.name
             TicketSystem(self.env).reset_ticket_fields()
 
-        old_values = dict(name=old_name)
+        #todo:add support of old_values for owner and description fields
+        old_values = dict()
+        if self.name != old_name:
+            old_values["name"] = old_name
         ResourceSystem(self.env).resource_changed(self, old_values)
 
     @classmethod
@@ -1221,7 +1228,10 @@ class Version(object):
                 self._old_name = self.name
             TicketSystem(self.env).reset_ticket_fields()
 
-        old_values = dict(name=old_name)
+        #todo: add support of old_values for time and description fields
+        old_values = dict()
+        if self.name != old_name:
+            old_values["name"] = old_name
         ResourceSystem(self.env).resource_changed(self, old_values)
 
     @classmethod

Modified: incubator/bloodhound/trunk/trac/trac/wiki/model.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/trac/trac/wiki/model.py?rev=1457457&r1=1457456&r2=1457457&view=diff
==============================================================================
--- incubator/bloodhound/trunk/trac/trac/wiki/model.py (original)
+++ incubator/bloodhound/trunk/trac/trac/wiki/model.py Sun Mar 17 14:55:13 2013
@@ -166,18 +166,19 @@ class WikiPage(object):
             time=t,
             comment=comment,
             author=author,
-            remote_addr=remote_addr,
-            source_action="save")
+            remote_addr=remote_addr)
         if self.version == 1:
             ResourceSystem(self.env).resource_created(self, context)
         else:
+            old_values = dict()
+            if self.readonly != self.old_readonly:
+                old_values["readonly"] = self.old_readonly
+            if self.text != self.old_text:
+                old_values["text"] = self.old_text
             ResourceSystem(self.env).resource_changed(
                 self,
-                old_values=dict(
-                    name=self.name,
-                    readonly = self.old_readonly,
-                    text = self.old_text),
-                context = context)
+                old_values,
+                context)
 
         self.old_readonly = self.readonly
         self.old_text = self.text
@@ -217,11 +218,7 @@ class WikiPage(object):
 
         ResourceSystem(self.env).resource_changed(
             self,
-            old_values=dict(
-                name=old_name,
-                readonly = self.readonly,
-                text = self.text),
-            context=dict(source_action="rename")
+            dict(name=old_name)
         )
 
     def get_history(self, db=None):

Modified: incubator/bloodhound/trunk/trac/trac/wiki/tests/model.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/trac/trac/wiki/tests/model.py?rev=1457457&r1=1457456&r2=1457457&view=diff
==============================================================================
--- incubator/bloodhound/trunk/trac/trac/wiki/tests/model.py (original)
+++ incubator/bloodhound/trunk/trac/trac/wiki/tests/model.py Sun Mar 17 14:55:13 2013
@@ -299,10 +299,7 @@ class WikiResourceChangeListenerTestCase
         self.assertIsInstance(self.listener.resource, WikiPage)
         self.assertEqual(self.INITIAL_NAME, self.wiki_name)
         self.assertEqual(CHANGED_TEXT, self.wiki_text)
-        self.assertEqual(
-            dict(text=self.INITIAL_TEXT, readonly=0, name=self.INITIAL_NAME),
-            self.listener.old_values)
-        self.assertEqual("save", self.listener.context["source_action"])
+        self.assertEqual({"text":self.INITIAL_TEXT}, self.listener.old_values)
 
     def test_change_listener_renamed(self):
         wiki_page = self._create_wiki_page(self.INITIAL_NAME)
@@ -312,10 +309,7 @@ class WikiResourceChangeListenerTestCase
         self.assertIsInstance(self.listener.resource, WikiPage)
         self.assertEqual(CHANGED_NAME, self.wiki_name)
         self.assertEqual(self.INITIAL_TEXT, self.wiki_text)
-        self.assertEqual(
-            dict(text=self.INITIAL_TEXT, readonly=0, name=self.INITIAL_NAME),
-            self.listener.old_values)
-        self.assertEqual("rename", self.listener.context["source_action"])
+        self.assertEqual({"name":self.INITIAL_NAME}, self.listener.old_values)
 
     def test_change_listener_deleted(self):
         wiki_page = self._create_wiki_page(self.INITIAL_NAME)



Mime
View raw message