[Erp5-report] r14158 - in /erp5/trunk/products/ERP5Type: ./ patches/

nobody at svn.erp5.org nobody at svn.erp5.org
Sun Apr 22 23:23:31 CEST 2007


Author: seb
Date: Sun Apr 22 23:23:27 2007
New Revision: 14158

URL: http://svn.erp5.org?rev=14158&view=rev
Log:
make allowedContentTypes working 1000 times faster on important projects

Added:
    erp5/trunk/products/ERP5Type/patches/CMFBTreeFolder.py
Modified:
    erp5/trunk/products/ERP5Type/ZopePatch.py

Modified: erp5/trunk/products/ERP5Type/ZopePatch.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/ZopePatch.py?rev=14158&r1=14157&r2=14158&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/ZopePatch.py (original)
+++ erp5/trunk/products/ERP5Type/ZopePatch.py Sun Apr 22 23:23:27 2007
@@ -45,6 +45,7 @@
 from Products.ERP5Type.patches import PropertySheets
 from Products.ERP5Type.patches import CMFCoreSkinnable
 from Products.ERP5Type.patches import CMFCoreSkinsTool
+from Products.ERP5Type.patches import CMFBTreeFolder
 from Products.ERP5Type.patches import OFSFolder
 from Products.ERP5Type.patches import HTTPRequest
 from Products.ERP5Type.patches import Connection

Added: erp5/trunk/products/ERP5Type/patches/CMFBTreeFolder.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/patches/CMFBTreeFolder.py?rev=14158&view=auto
==============================================================================
--- erp5/trunk/products/ERP5Type/patches/CMFBTreeFolder.py (added)
+++ erp5/trunk/products/ERP5Type/patches/CMFBTreeFolder.py Sun Apr 22 23:23:27 2007
@@ -1,0 +1,59 @@
+##############################################################################
+#
+# Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
+# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
+#from Products.CMFCore.PortalFolder import PortalFolder
+#from Products.CMFCore.PortalFolder import PortalFolder
+try:
+  from Products.CMFCore.CMFBTreeFolder import CMFBTreeFolder
+except ImportError:
+  from Products.BTreeFolder2.CMFBTreeFolder import CMFBTreeFolder
+from Products.CMFCore.utils import getToolByName
+
+"""
+  This patch tries to give only portal types that are defined
+  in the allowed content types field. This will make the
+  speed of allowed content type in almost O(1) instead of O(n),
+  where n is the number of portal types in types tool.
+"""
+
+def CMFBTreeFolder_allowedContentTypes(self):
+  """
+      List type info objects for types which can be added in
+      this folder.
+  """
+  result = []
+  portal_types = getToolByName(self, 'portal_types')
+  myType = portal_types.getTypeInfo(self)
+
+  if myType is not None:
+    allowed_types_to_check = []
+    if myType.filter_content_types:
+      result = [portal_types.getTypeInfo(x) for x in 
+                   myType.allowed_content_types]
+    else:
+      if myType is not None:
+          for contentType in portal_types.listTypeInfo(self):
+              if myType.allowType( contentType.getId() ):
+                  result.append( contentType )
+  else:
+      result = portal_types.listTypeInfo()
+
+  return filter( lambda typ, container=self:
+                    typ.isConstructionAllowed( container )
+               , result )
+
+
+
+CMFBTreeFolder.allowedContentTypes = CMFBTreeFolder_allowedContentTypes
+




More information about the Erp5-report mailing list