[Erp5-report] r20822 - /experimental/Experimental/patches/DiscussionItem_patch.py

nobody at svn.erp5.org nobody at svn.erp5.org
Sat Apr 26 15:22:05 CEST 2008


Author: bartek
Date: Sat Apr 26 15:22:04 2008
New Revision: 20822

URL: http://svn.erp5.org?rev=20822&view=rev
Log:
initial import

Added:
    experimental/Experimental/patches/DiscussionItem_patch.py

Added: experimental/Experimental/patches/DiscussionItem_patch.py
URL: http://svn.erp5.org/experimental/Experimental/patches/DiscussionItem_patch.py?rev=20822&view=auto
==============================================================================
--- experimental/Experimental/patches/DiscussionItem_patch.py (added)
+++ experimental/Experimental/patches/DiscussionItem_patch.py Sat Apr 26 15:22:04 2008
@@ -1,0 +1,68 @@
+##############################################################################
+#
+# Copyright (c) 2007 ERP5 Polska. All Rights Reserved.
+#          Bartek Gorny <bartek at erp5.pl>
+#
+# WARNING: This program as such is intended to be used by professional
+# programmers who take the whole responsability of assessing all potential
+# consequences resulting from its eventual inadequacies and bugs
+# End users who are looking for a ready-to-use solution with commercial
+# garantees and support are strongly adviced to contract a Free Software
+# Service Company
+# This program is Free Software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+##############################################################################
+
+"""
+    This patches DiscussionItem and CMFCatalogAware to allow deleting DiscussionItems
+    (because DiscussionItems uses CMF base classes which are inconsistent with 
+    the ERP5Catalog API).
+
+    Required if you want to use erp5_discussion_experimental.
+  """
+
+from Products.CMFDefault.DiscussionItem import DiscussionItemContainer
+from Products.CMFCore.CMFCatalogAware import CMFCatalogAware
+from Products.CMFCore.utils import getToolByName
+
+def DiscussionItemContainer_deleteReply( self, reply_id ):
+  """ Remove a reply from this container """
+  if self._container.has_key( reply_id ):
+   reply = self._container.get( reply_id ).__of__( self )
+   my_replies = reply.talkback.getReplies()
+   for my_reply in my_replies:
+     my_reply_id = my_reply.getId()
+     if hasattr( my_reply, 'unindexObject' ):
+         my_reply.unindexObject()
+
+     del self._container[my_reply_id]
+
+   if hasattr( reply, 'unindexObject' ): # this line is modified because ERP5Catalog needs uid
+       reply.unindexObject(uid=reply.getUid())
+
+   del self._container[reply_id]
+
+DiscussionItemContainer.deleteReply = DiscussionItemContainer_deleteReply
+
+
+def CMFCatalogAware_unindexObject(self, uid):
+  """
+      Unindex the object from the portal catalog.
+  """
+  catalog = getToolByName(self, 'portal_catalog', None)
+  if catalog is not None:
+    catalog.unindexObject(self, uid=uid) # this line is modified because ERP5Catalog needs uid
+
+CMFCatalogAware.unindexObject = CMFCatalogAware_unindexObject




More information about the Erp5-report mailing list