[CMF-checkins] CVS: Products/CMFCore - DynamicType.py:1.24 PortalFolder.py:1.73 TypesTool.py:1.77

Yvo Schubbe y.2004_ at wcm-solutions.de
Tue Sep 7 04:49:08 EDT 2004


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

Modified Files:
	DynamicType.py PortalFolder.py TypesTool.py 
Log Message:
Merged yuppie-ti_aliases-redo-branch:
- replaced getMethodPath and getMethodURL by queryMethodID


=== Products/CMFCore/DynamicType.py 1.23 => 1.24 ===
--- Products/CMFCore/DynamicType.py:1.23	Thu Aug 12 11:07:39 2004
+++ Products/CMFCore/DynamicType.py	Tue Sep  7 04:48:37 2004
@@ -116,13 +116,12 @@
         stack = REQUEST['TraversalRequestNameStack']
         key = stack and stack[-1] or '(Default)'
         ti = self.getTypeInfo()
-        path = ti and ti.getMethodPath(key) or None
-        if path:
+        method_id = ti and ti.queryMethodID(key)
+        if method_id:
             if key != '(Default)':
                 stack.pop()
-            for id in path:
-                if id != '(Default)':
-                    stack.append(id)
+            if method_id != '(Default)':
+                stack.append(method_id)
             REQUEST._hacked_path = 1
 
 InitializeClass(DynamicType)


=== Products/CMFCore/PortalFolder.py 1.72 => 1.73 ===
--- Products/CMFCore/PortalFolder.py:1.72	Tue Aug 24 15:16:32 2004
+++ Products/CMFCore/PortalFolder.py	Tue Sep  7 04:48:37 2004
@@ -538,10 +538,10 @@
         a PortalFolder.
         """
         ti = self.getTypeInfo()
-        method = ti and ti.getMethodURL('mkdir') or None
-        if method:
+        method_id = ti and ti.queryMethodID('mkdir')
+        if method_id:
             # call it
-            getattr(self, method)(id=id)
+            getattr(self, method_id)(id=id)
         else:
             self.invokeFactory( type_name='Folder', id=id )
 


=== Products/CMFCore/TypesTool.py 1.76 => 1.77 ===
--- Products/CMFCore/TypesTool.py:1.76	Fri Sep  3 12:36:17 2004
+++ Products/CMFCore/TypesTool.py	Tue Sep  7 04:48:37 2004
@@ -272,12 +272,11 @@
 
     security.declarePublic('getActionById')
     def getActionById( self, id, default=_marker ):
-        """
-            Return the URL of the action whose ID is id.
+        """ Get method ID by action ID.
         """
         warn('getActionById() is deprecated and will be removed in CMF 1.6. '
              'Please use getActionInfo()[\'url\'] if you need an URL or '
-             'getMethodPath()[0] if you need a method.',
+             'queryMethodID() if you need a method ID.',
              DeprecationWarning)
         context = getActionContext( self )
         for action in self.listActions():
@@ -368,13 +367,13 @@
         """
         if not hasattr(self, '_aliases'):
             self._guessMethodAliases()
-        _dict = {}
         aliases = self._aliases
-        for k, v in aliases.items():
-            path = list(v)
-            path.reverse()
-            _dict[k] = '/'.join(path)
-        return _dict
+        # for aliases created with CMF 1.5.0beta
+        for key, method_id in aliases.items():
+            if isinstance(method_id, tuple):
+                aliases[key] = method_id[0]
+                self._p_changed = True
+        return aliases
 
     security.declareProtected(ManagePortal, 'setMethodAliases')
     def setMethodAliases(self, aliases):
@@ -384,31 +383,25 @@
         for k, v in aliases.items():
             v = v.strip()
             if v:
-                path = v.split('/')
-                path.reverse()
-                _dict[ k.strip() ] = tuple(path)
+                _dict[ k.strip() ] = v
         if not getattr(self, '_aliases', None) == _dict:
             self._aliases = _dict
-            return 1
+            return True
         else:
-            return 0
+            return False
 
-    security.declarePublic('getMethodPath')
-    def getMethodPath(self, key):
-        """ Get reverse relative method path by alias.
+    security.declarePublic('queryMethodID')
+    def queryMethodID(self, alias, default=None):
+        """ Query method ID by alias.
         """
         if not hasattr(self, '_aliases'):
             self._guessMethodAliases()
         aliases = self._aliases
-        return aliases.get( key, () )
-
-    security.declarePublic('getMethodURL')
-    def getMethodURL(self, key):
-        """ Get relative method URL by alias.
-        """
-        path = list( self.getMethodPath(key) )
-        path.reverse()
-        return '/'.join(path)
+        method_id = aliases.get(alias, default)
+        # for aliases created with CMF 1.5.0beta
+        if isinstance(method_id, tuple):
+            method_id = method_id[0]
+        return method_id
 
     security.declarePrivate('_guessMethodAliases')
     def _guessMethodAliases(self):



More information about the CMF-checkins mailing list