[Zope-CMF] Types, meta_type, content_meta_type, etc...

Florent Guillaume fg@nuxeo.com
Thu, 16 May 2002 13:33:31 +0000 (UTC)


Ok, because I don't want to deal with complex backward compatibility
issues right now (automatically upgrade allowed_content_types), I did a
workaround that actually make the Type Tool work (which it didn't if you
had a nonempty title != id and filtering on).

Here it is for review, I'll put it in CVS if it looks ok to you, or
someone else fell free to do it. If it could be in 1.3 final it would be
great.

--- TypesTool.py        8 Mar 2002 12:33:02 -0000       1.33
+++ TypesTool.py        16 May 2002 13:29:57 -0000
@@ -165,10 +165,27 @@
         """
         if not self.filter_content_types:
             ti = self.getTypeInfo( contentType )
-            return ti is None or ti.globalAllow() \
-                   or contentType in self.allowed_content_types
-        return contentType in self.allowed_content_types
-    
+            if ti is None or ti.globalAllow():
+                return 1
+
+        # XXX This needs to be fixed so that contentType is
+        # always a type id.
+
+        # When called from PortalFolder.allowedContentTypes,
+        # contentType is a Type(), which is compatible with what
+        # allowed_content_types contains.
+        if contentType in self.allowed_content_types:
+            return 1
+
+        # When called from PortalFolder.invokeFactory,
+        # contentType is a type id, which may be different
+        # from the Type() if the title is non-empty.
+        for t in self.listTypeInfo():
+            if t.getId() == contentType:
+                return t.Type() in self.allowed_content_types
+
+        return 0
+
     security.declarePublic('getId')
     def getId(self):
         return self.id



Florent


Shane Hathaway  <shane@zope.com> wrote:
> seb bacon wrote:
> >> The 'Type()' of a TypeInformation object is currently mis-defined
> >> to return the TIO's title/id;  this is *wrong*, because the Title
> >> of a TIO *is* presentation (it should be localizable, for instance).
> >> The *desired* implementation would be always to return the ID for
> >> a TIO's 'Type()', which should always be identical to the 'Type()'
> >> of instances which are created from it.
> > 
> > 
> > Hooray!  I've been worried about that for about a year, not being sure 
> > if I was right or not.
> > 
> > I wonder if there are any backwards-compatibility issues...?
> 
> I talked with Tres, and we agreed that we should be simply using the 
> getId() method of the type info object.  I think we also agreed that 
> TIO's shouldn't have a "Type" method at all, since that implies a 
> behavior TIO's don't have.
> 
> Shane
-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:fg@nuxeo.com