bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1456016 - in /incubator/bloodhound/branches/bep_0003_multiproduct: ./ bloodhound_dashboard/bhdashboard/ bloodhound_multiproduct/multiproduct/ bloodhound_multiproduct/tests/ trac/ trac/trac/ trac/trac/tests/ trac/trac/ticket/ trac/trac/tick...
Date Wed, 13 Mar 2013 16:06:24 GMT
Author: jure
Date: Wed Mar 13 16:06:23 2013
New Revision: 1456016

URL: http://svn.apache.org/r1456016
Log:
Sync merge from trunk


Modified:
    incubator/bloodhound/branches/bep_0003_multiproduct/   (props changed)
    incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/model.py
    incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/model.py
    incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/model.py
    incubator/bloodhound/branches/bep_0003_multiproduct/trac/   (props changed)
    incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/attachment.py
    incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/tests/attachment.py
    incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/ticket/model.py
    incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/ticket/tests/model.py
    incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/wiki/model.py

Propchange: incubator/bloodhound/branches/bep_0003_multiproduct/
------------------------------------------------------------------------------
  Merged /incubator/bloodhound/trunk:r1455901-1456015

Modified: incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/model.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/model.py?rev=1456016&r1=1456015&r2=1456016&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/model.py
(original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_dashboard/bhdashboard/model.py
Wed Mar 13 16:06:23 2013
@@ -18,7 +18,7 @@
 
 from trac.db import Table, Column
 from trac.core import TracError
-from trac.resource import ResourceNotFound
+from trac.resource import ResourceNotFound, ResourceSystem
 from trac.ticket.api import TicketSystem
 
 
@@ -133,9 +133,11 @@ class ModelBase(object):
         with self._env.db_transaction as db:
             db(sql, values)
             self._exists = False
-            self._data = dict([(k, None) for k in self._data.keys()])
-            self._old_data.update(self._data)
             TicketSystem(self._env).reset_ticket_fields()
+        ResourceSystem(self._env).resource_deleted(self)
+        self._data = dict([(k, None) for k in self._data.keys()])
+        self._old_data.update(self._data)
+
     
     def insert(self):
         """Create new record in the database"""
@@ -174,6 +176,7 @@ class ModelBase(object):
             self._exists = True
             self._old_data.update(self._data)
             TicketSystem(self._env).reset_ticket_fields()
+        ResourceSystem(self._env).resource_created(self)
 
     def _update_relations(self, db):
         """Extra actions due to update"""
@@ -202,11 +205,15 @@ class ModelBase(object):
         sdata.update(self._meta)
         sql = """UPDATE %(table_name)s SET %(values)s
                  WHERE %(where)s""" % sdata
+        old_data = self._old_data.copy()
         with self._env.db_transaction as db:
             db(sql, setvalues + values)
             self._update_relations(db)
             self._old_data.update(self._data)
             TicketSystem(self._env).reset_ticket_fields()
+
+        ResourceSystem(self._env).resource_changed(self, old_data)
+
     
     @classmethod
     def select(cls, env, db=None, where=None, limit=None):

Modified: incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/model.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/model.py?rev=1456016&r1=1456015&r2=1456016&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/model.py
(original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/multiproduct/model.py
Wed Mar 13 16:06:23 2013
@@ -58,9 +58,10 @@ class Product(ModelBase):
                 sdata.update(self._meta)
                 raise TracError('%(object_name)s %(new_table)s does not exist' %
                                 sdata)
+        original_prefix = self._data['prefix']
         super(Product, self).delete()
         #find and update all resources that should move
-        where = {'product_id':self._data['prefix']}
+        where = {'product_id':original_prefix}
         for prm in ProductResourceMap.select(self._env, where=where):
             prm._data['product_id'] = resources_to
             prm.update()

Modified: incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/model.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/model.py?rev=1456016&r1=1456015&r2=1456016&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/model.py
(original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/bloodhound_multiproduct/tests/model.py
Wed Mar 13 16:06:23 2013
@@ -28,9 +28,14 @@ from trac.core import TracError
 
 from multiproduct.model import Product
 from multiproduct.api import MultiProductSystem
+from trac.tests.resource import TestResourceChangeListener
 
 class ProductTestCase(unittest.TestCase):
     """Unit tests covering the Product model"""
+    INITIAL_PREFIX = 'tp'
+    INITIAL_NAME = 'test project'
+    INITIAL_DESCRIPTION = 'a test project'
+
     def setUp(self):
         self.env = EnvironmentStub(enable=['trac.*', 'multiproduct.*'])
         self.env.path = tempfile.mkdtemp('bh-product-tempenv')
@@ -42,18 +47,32 @@ class ProductTestCase(unittest.TestCase)
             # table remains but database version is deleted
             pass
         
-        self.default_data = {'prefix':'tp',
-                             'name':'test project',
-                             'description':'a test project'}
-        
-        product = Product(self.env)
-        product._data.update(self.default_data)
-        product.insert()
-    
+        self.listener = self._enable_resource_change_listener()
+        self.default_data = {'prefix':self.INITIAL_PREFIX,
+                             'name':self.INITIAL_NAME,
+                             'description':self.INITIAL_DESCRIPTION}
+        
+        self.product = Product(self.env)
+        self.product._data.update(self.default_data)
+        self.product.insert()
+
     def tearDown(self):
         shutil.rmtree(self.env.path)
         self.env.reset_db()
     
+    def _enable_resource_change_listener(self):
+        listener = TestResourceChangeListener(self.env)
+        listener.resource_type = Product
+        listener.callback = self.listener_callback
+        return listener
+
+    def listener_callback(self, action, resource, context, old_values = None):
+        # pylint: disable=unused-argument
+        # pylint: disable=attribute-defined-outside-init
+        self.prefix = resource.prefix
+        self.name = resource.name
+        self.description = resource.description
+
     def test_set_table_field(self):
         """tests that table.field style update works"""
         test = {'prefix': 'td',
@@ -91,10 +110,11 @@ class ProductTestCase(unittest.TestCase)
         
         products = list(Product.select(self.env, where={'prefix':'tp'}))
         self.assertEqual(1, len(products))
-        products = list(Product.select(self.env, where={'name':'test project'}))
+        products = list(Product.select(self.env,
+            where={'name':'test project'}))
         self.assertEqual(1, len(products))
-        products = list(Product.select(self.env, where={'prefix':'tp3',
-                                                        'name':'test project 3'}))
+        products = list(Product.select(self.env,
+            where={'prefix':'tp3', 'name':'test project 3'}))
         self.assertEqual(1, len(products))
     
     def test_update(self):
@@ -200,12 +220,44 @@ class ProductTestCase(unittest.TestCase)
         structure =  dict([(table.name, [col.name for col in table.columns])
                            for table in schema])
         tm1 = TestModel(self.env)
-        tm1._data.update({'id':1,'value':'value1'})
+        tm1._data.update({'id':1, 'value':'value1'})
         tm1.insert()
         tm2 = TestModel(self.env)
-        tm2._data.update({'id':2,'value':'value2'})
+        tm2._data.update({'id':2, 'value':'value2'})
         tm2.insert()
 
+    def test_change_listener_created(self):
+        self.assertEqual('created', self.listener.action)
+        self.assertIsInstance(self.listener.resource, Product)
+        self.assertEqual(self.INITIAL_PREFIX, self.prefix)
+        self.assertEqual(self.INITIAL_NAME, self.name)
+        self.assertEqual(self.INITIAL_DESCRIPTION, self.description)
+
+    def test_change_listener_changed(self):
+        CHANGED_NAME = "changed name"
+        self.product.name = CHANGED_NAME
+        self.product.update()
+        self.assertEqual('changed', self.listener.action)
+        self.assertIsInstance(self.listener.resource, Product)
+        self.assertEqual(CHANGED_NAME, self.name)
+        self.assertEqual(
+            self.INITIAL_PREFIX, self.listener.old_values["prefix"])
+        self.assertEqual(
+            self.INITIAL_NAME, self.listener.old_values["name"])
+        self.assertEqual(
+            self.INITIAL_DESCRIPTION, self.listener.old_values["description"])
+
+    def test_change_listener_deleted(self):
+        self.product.delete()
+        self.assertEqual('deleted', self.listener.action)
+        self.assertIsInstance(self.listener.resource, Product)
+        self.assertEqual(self.INITIAL_PREFIX, self.prefix)
+
+def suite():
+    test_suite = unittest.TestSuite()
+    test_suite.addTest(unittest.makeSuite(ProductTestCase, 'test'))
+    return test_suite
+
 if __name__ == '__main__':
     unittest.main()
 

Propchange: incubator/bloodhound/branches/bep_0003_multiproduct/trac/
------------------------------------------------------------------------------
  Merged /incubator/bloodhound/trunk/trac:r1455438-1456015

Modified: incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/attachment.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/attachment.py?rev=1456016&r1=1456015&r2=1456016&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/attachment.py (original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/attachment.py Wed Mar 13
16:06:23 2013
@@ -235,6 +235,8 @@ class Attachment(object):
 
         self.env.log.info("Attachment removed: %s" % self.title)
 
+        for listener in AttachmentModule(self.env).change_listeners:
+            listener.attachment_deleted(self)
         ResourceSystem(self.env).resource_deleted(self)
 
     def reparent(self, new_realm, new_id):
@@ -283,6 +285,9 @@ class Attachment(object):
 
         self.env.log.info("Attachment reparented: %s" % self.title)
 
+        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)
         ResourceSystem(self.env).resource_changed(self, old_values=old_values)
 
@@ -328,6 +333,8 @@ class Attachment(object):
                 self.env.log.info("New attachment: %s by %s", self.title,
                                   self.author)
 
+        for listener in AttachmentModule(self.env).change_listeners:
+            listener.attachment_added(self)
         ResourceSystem(self.env).resource_created(self)
 
 
@@ -1098,30 +1105,3 @@ class AttachmentAdmin(Component):
                 if destination is not None:
                     output.close()
 
-class ResourceToAttachmentChangeListenerAdapter(Component):
-    """
-    The class provides backward compatibility for components implementing
-    IAttachmentChangeListener interface.
-    """
-    implements(IResourceChangeListener)
-    def match_resource(self, resource):
-        return isinstance(resource, Attachment)
-
-    def resource_created(self, resource, context):
-        for listener in AttachmentModule(self.env).change_listeners:
-            listener.attachment_added(resource)
-
-    def resource_changed(self, resource, old_values, context):
-        for listener in AttachmentModule(self.env).change_listeners:
-            if hasattr(listener, 'attachment_reparented'):
-                listener.attachment_reparented(
-                    resource,
-                    old_values.get("parent_realm"),
-                    old_values.get("parent_id"))
-
-    def resource_deleted(self, resource, context):
-        for listener in AttachmentModule(self.env).change_listeners:
-            listener.attachment_deleted(resource)
-
-    def resource_version_deleted(self, resource, context):
-        pass

Modified: incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/tests/attachment.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/tests/attachment.py?rev=1456016&r1=1456015&r2=1456016&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/tests/attachment.py (original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/tests/attachment.py Wed
Mar 13 16:06:23 2013
@@ -6,8 +6,7 @@ from StringIO import StringIO
 import tempfile
 import unittest
 
-from trac.attachment import (Attachment, AttachmentModule,
-                             IAttachmentChangeListener)
+from trac.attachment import Attachment, AttachmentModule
 from trac.core import Component, implements, TracError
 from trac.perm import IPermissionPolicy, PermissionCache
 from trac.resource import Resource, resource_exists
@@ -30,24 +29,6 @@ hashes = {
     u'ÜberSicht': 'a16c6837f6d3d2cc3addd68976db1c55deb694c8',
 }
 
-class TestAttachmentChangeListener(Component):
-    implements(IAttachmentChangeListener)
-
-    def attachment_added(self, attachment):
-        self.action = "added"
-        self.attachment = attachment
-
-    def attachment_deleted(self, attachment):
-        self.action = "deleted"
-        self.attachment = attachment
-
-    def attachment_reparented(
-            self, attachment, old_parent_realm, old_parent_id):
-        self.action = "reparented"
-        self.attachment = attachment
-        self.old_parent_realm = old_parent_realm
-        self.old_parent_id = old_parent_id
-
 
 class TicketOnlyViewsTicket(Component):
     implements(IPermissionPolicy)
@@ -241,35 +222,6 @@ class AttachmentTestCase(unittest.TestCa
         att.insert('file.txt', StringIO(''), 1)
         self.assertTrue(resource_exists(self.env, att.resource))
 
-    def test_change_listener_created(self):
-        listener = TestAttachmentChangeListener(self.env)
-        attachment = self._create_attachment()
-        self.assertEqual('added', listener.action)
-        self.assertEqual(attachment, listener.attachment)
-
-    def test_change_listener_deleted(self):
-        listener = TestAttachmentChangeListener(self.env)
-        attachment = self._create_attachment()
-        attachment.delete()
-        self.assertEqual('deleted', listener.action)
-        self.assertEqual(attachment, listener.attachment)
-
-    def test_change_listener_deleted(self):
-        listener = TestAttachmentChangeListener(self.env)
-        attachment = self._create_attachment()
-        old_parent_realm = attachment.parent_realm
-        old_parent_id = attachment.parent_id
-        attachment.reparent("wiki", "SomePage")
-        self.assertEqual('reparented', listener.action)
-        self.assertEqual(attachment, listener.attachment)
-        self.assertEqual(old_parent_realm, listener.old_parent_realm)
-        self.assertEqual(old_parent_id, listener.old_parent_id)
-
-    def _create_attachment(self):
-        attachment = Attachment(self.env, 'wiki', 'WikiStart')
-        attachment.insert('file.txt', StringIO(''), 1)
-        return attachment
-
 
 class AttachmentResourceChangeListenerTestCase(unittest.TestCase):
     DUMMY_PARENT_REALM = "wiki"

Modified: incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/ticket/model.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/ticket/model.py?rev=1456016&r1=1456015&r2=1456016&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/ticket/model.py (original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/ticket/model.py Wed Mar
13 16:06:23 2013
@@ -25,9 +25,8 @@ from datetime import datetime
 from trac.attachment import Attachment
 from trac import core
 from trac.cache import cached
-from trac.core import TracError, implements
-from trac.resource import (Resource, ResourceNotFound, IResourceChangeListener,
-                           ResourceSystem)
+from trac.core import TracError
+from trac.resource import Resource, ResourceNotFound, ResourceSystem
 from trac.ticket.api import TicketSystem
 from trac.util import embedded_numbers, partition
 from trac.util.text import empty
@@ -253,6 +252,8 @@ class Ticket(object):
         self.resource = self.resource(id=tkt_id)
         self._old = {}
 
+        for listener in TicketSystem(self.env).change_listeners:
+            listener.ticket_created(self)
         ResourceSystem(self.env).resource_created(self)
 
         return self.id
@@ -361,6 +362,8 @@ class Ticket(object):
         self._old = {}
         self.values['changetime'] = when
 
+        for listener in TicketSystem(self.env).change_listeners:
+            listener.ticket_changed(self, comment, author, old_values)
         context = dict(comment=comment, author=author)
         ResourceSystem(self.env).resource_changed(self, old_values, context)
 
@@ -426,6 +429,8 @@ class Ticket(object):
             db("DELETE FROM ticket_change WHERE ticket=%s", (self.id,))
             db("DELETE FROM ticket_custom WHERE ticket=%s", (self.id,))
 
+        for listener in TicketSystem(self.env).change_listeners:
+            listener.ticket_deleted(self)
         ResourceSystem(self.env).resource_deleted(self)
 
     def get_change(self, cnum=None, cdate=None, db=None):
@@ -1037,6 +1042,8 @@ class Milestone(object):
             del self.cache.milestones
             TicketSystem(self.env).reset_ticket_fields()
 
+        for listener in TicketSystem(self.env).milestone_change_listeners:
+            listener.milestone_deleted(self)
         ResourceSystem(self.env).resource_deleted(self)
 
     def insert(self, db=None):
@@ -1058,6 +1065,8 @@ class Milestone(object):
             self.checkin()
             TicketSystem(self.env).reset_ticket_fields()
 
+        for listener in TicketSystem(self.env).milestone_change_listeners:
+            listener.milestone_created(self)
         ResourceSystem(self.env).resource_created(self)
 
     def update(self, db=None):
@@ -1096,6 +1105,8 @@ class Milestone(object):
 
         old_values = dict((k, v) for k, v in old.iteritems()
                           if getattr(self, k) != v)
+        for listener in TicketSystem(self.env).milestone_change_listeners:
+            listener.milestone_changed(self, old_values)
         ResourceSystem(self.env).resource_changed(self, old_values)
 
     @classmethod
@@ -1230,59 +1241,3 @@ class Version(object):
         def version_order(v):
             return (v.time or utcmax, embedded_numbers(v.name))
         return sorted(versions, key=version_order, reverse=True)
-
-class ResourceToMilestoneChangeListenerAdapter(core.Component):
-    """
-    The class provides backward compatibility for components implementing
-    IMilestoneChangeListener interface.
-    """
-    implements(IResourceChangeListener)
-
-    def match_resource(self, resource):
-        return isinstance(resource, Milestone)
-
-    def resource_created(self, resource, context):
-        for listener in TicketSystem(self.env).milestone_change_listeners:
-            listener.milestone_created(resource)
-
-    def resource_changed(self, resource, old_values, context):
-        for listener in TicketSystem(self.env).milestone_change_listeners:
-            listener.milestone_changed(resource, old_values)
-
-    def resource_deleted(self, resource, context):
-        for listener in TicketSystem(self.env).milestone_change_listeners:
-            listener.milestone_deleted(resource)
-
-    def resource_version_deleted(self, resource, context):
-        pass
-
-class ResourceToTicketChangeListenerAdapter(core.Component):
-    """
-    The class provides backward compatibility for components implementing
-    ITicketChangeListener interface.
-    """
-    implements(IResourceChangeListener)
-    def match_resource(self, resource):
-        return isinstance(resource, Ticket)
-
-    def resource_created(self, resource, context):
-        for listener in TicketSystem(self.env).change_listeners:
-            listener.ticket_created(resource)
-
-    def resource_changed(self, resource, old_values, context):
-        author = None
-        comment = None
-        if context:
-            comment = context.get("comment")
-            author = context.get("author")
-
-        for listener in TicketSystem(self.env).change_listeners:
-            listener.ticket_changed(resource, comment, author, old_values)
-
-    def resource_deleted(self, resource, context):
-        for listener in TicketSystem(self.env).change_listeners:
-            listener.ticket_deleted(resource)
-
-    def resource_version_deleted(self, resource, context):
-        pass
-

Modified: incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/ticket/tests/model.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/ticket/tests/model.py?rev=1456016&r1=1456015&r2=1456016&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/ticket/tests/model.py (original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/ticket/tests/model.py Wed
Mar 13 16:06:23 2013
@@ -15,12 +15,13 @@ from trac.ticket.model import (
     Ticket, Component, Milestone, Priority, Type, Version
 )
 from trac.ticket.api import (
-    IMilestoneChangeListener, ITicketChangeListener, TicketSystem,
+    IMilestoneChangeListener, ITicketChangeListener, TicketSystem
 )
 from trac.test import EnvironmentStub
 from trac.tests.resource import TestResourceChangeListener
 from trac.util.datefmt import from_utimestamp, to_utimestamp, utc
 
+
 class TestTicketChangeListener(core.Component):
     implements(ITicketChangeListener)
 
@@ -1005,6 +1006,7 @@ class MilestoneTestCase(unittest.TestCas
         self.assertEqual('deleted', listener.action)
         self.assertEqual(milestone, listener.milestone)
 
+
 class ComponentTestCase(unittest.TestCase):
 
     def setUp(self):

Modified: incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/wiki/model.py
URL: http://svn.apache.org/viewvc/incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/wiki/model.py?rev=1456016&r1=1456015&r2=1456016&view=diff
==============================================================================
--- incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/wiki/model.py (original)
+++ incubator/bloodhound/branches/bep_0003_multiproduct/trac/trac/wiki/model.py Wed Mar 13
16:06:23 2013
@@ -21,7 +21,7 @@ from __future__ import with_statement
 from datetime import datetime
 
 from trac.core import *
-from trac.resource import Resource, ResourceSystem, IResourceChangeListener
+from trac.resource import Resource, ResourceSystem
 from trac.util.datefmt import from_utimestamp, to_utimestamp, utc
 from trac.util.translation import _
 from trac.wiki.api import WikiSystem, validate_page_name
@@ -110,8 +110,13 @@ class WikiPage(object):
 
         # Let change listeners know about the deletion
         if not self.exists:
+            for listener in WikiSystem(self.env).change_listeners:
+                listener.wiki_page_deleted(self)
             ResourceSystem(self.env).resource_deleted(self)
         else:
+            for listener in WikiSystem(self.env).change_listeners:
+                if hasattr(listener, 'wiki_page_version_deleted'):
+                    listener.wiki_page_version_deleted(self)
             ResourceSystem(self.env).resource_version_deleted(self)
 
     def save(self, author, comment, remote_addr, t=None, db=None):
@@ -150,6 +155,12 @@ class WikiPage(object):
         self.comment = comment
         self.time = t
 
+        for listener in WikiSystem(self.env).change_listeners:
+            if self.version == 1:
+                listener.wiki_page_added(self)
+            else:
+                listener.wiki_page_changed(self, self.version, t, comment,
+                                           author, remote_addr)
         context=dict(
             version=self.version,
             time=t,
@@ -200,6 +211,9 @@ class WikiPage(object):
         self.name = new_name
         self.env.log.info('Renamed page %s to %s', old_name, new_name)
 
+        for listener in WikiSystem(self.env).change_listeners:
+            if hasattr(listener, 'wiki_page_renamed'):
+                listener.wiki_page_renamed(self, old_name)
 
         ResourceSystem(self.env).resource_changed(
             self,
@@ -221,42 +235,3 @@ class WikiPage(object):
                 WHERE name=%s AND version<=%s ORDER BY version DESC
                 """, (self.name, self.version)):
             yield version, from_utimestamp(ts), author, comment, ipnr
-
-class ResourceToWikiChangeListenerAdapter(Component):
-    """
-    The class provides backward compatibility for components implementing
-    IWikiChangeListener interface.
-    """
-    implements(IResourceChangeListener)
-    def match_resource(self, resource):
-        return isinstance(resource, WikiPage)
-
-    def resource_created(self, resource, context):
-        for listener in WikiSystem(self.env).change_listeners:
-            listener.wiki_page_added(resource)
-
-    def resource_changed(self, resource, old_values, context):
-        if context is not None and context.get("source_action") == "rename":
-            for listener in WikiSystem(self.env).change_listeners:
-                 if hasattr(listener, 'wiki_page_renamed'):
-                     listener.wiki_page_renamed(
-                         resource, old_values.get("name"))
-        else:
-            for listener in WikiSystem(self.env).change_listeners:
-                    listener.wiki_page_changed(
-                        resource,
-                        context.get("version"),
-                        context.get("time"),
-                        context.get("comment"),
-                        context.get("author"),
-                        context.get("remote_addr"),
-                    )
-
-    def resource_deleted(self, resource, context):
-        for listener in WikiSystem(self.env).change_listeners:
-            listener.wiki_page_deleted(resource)
-
-    def resource_version_deleted(self, resource, context):
-        for listener in WikiSystem(self.env).change_listeners:
-            if hasattr(listener, 'wiki_page_version_deleted'):
-                listener.wiki_page_version_deleted(resource)



Mime
View raw message