[CMF-checkins] CVS: Products/CMFCore - TypesTool.py:1.74.2.10

Jens Vagelpohl jens at dataflake.org
Fri Mar 25 07:54:21 EST 2005


Update of /cvs-repository/Products/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv23096/CMFCore

Modified Files:
      Tag: CMF-1_5-branch
	TypesTool.py 
Log Message:
- CMFCore.TypesTool: Added backwards compatibility code to the fix for
  collector issue 49 (http://collector.zope.org/CMF/49)


=== Products/CMFCore/TypesTool.py 1.74.2.9 => 1.74.2.10 ===
--- Products/CMFCore/TypesTool.py:1.74.2.9	Wed Mar 23 16:55:28 2005
+++ Products/CMFCore/TypesTool.py	Fri Mar 25 07:53:50 2005
@@ -766,10 +766,32 @@
         fti = None
         if typeinfo_name:
             info = self.listDefaultTypeInformation()
-            for (name, ft) in info:
-                if name == typeinfo_name:
-                    fti = ft
-                    break
+
+            # Nasty orkaround to stay backwards-compatible
+            # This workaround will disappear in CMF 1.7
+            if typeinfo_name.endswith(')'):
+                # This is a new-style name. Proceed normally.
+                for (name, ft) in info:
+                    if name == typeinfo_name:
+                        fti = ft
+                        break
+            else:
+                # Attempt to work around the old way
+                # This attempt harbors the problem that the first match on
+                # meta_type will be used. There could potentially be more
+                # than one TypeInformation sharing the same meta_type.
+                warn('Please switch to the new format for typeinfo names '
+                     '\"product_id: type_id (meta_type)\", the old '
+                     'spelling will disappear in CMF 1.7', DeprecationWarning)
+
+                ti_prod, ti_mt = [x.strip() for x in typeinfo_name.split(':')]
+
+                for name, ft in info:
+                    if ( name.startswith(ti_prod) and
+                         name.endswith('(%s)' % ti_mt) ):
+                        fti = ft
+                        break
+
             if fti is None:
                 raise BadRequest('%s not found.' % typeinfo_name)
             if not id:



More information about the CMF-checkins mailing list