[Zope-CVS] CVS: Packages/Moztop/CMFMoztop - MoztopSupportTool.py:1.4

Sidnei da Silva sidnei@x3ng.com.br
Sun, 2 Mar 2003 14:51:13 -0500


Update of /cvs-repository/Packages/Moztop/CMFMoztop
In directory cvs.zope.org:/tmp/cvs-serv14362

Modified Files:
	MoztopSupportTool.py 
Log Message:
Added dc:identity

=== Packages/Moztop/CMFMoztop/MoztopSupportTool.py 1.3 => 1.4 ===
--- Packages/Moztop/CMFMoztop/MoztopSupportTool.py:1.3	Sat Mar  1 08:22:25 2003
+++ Packages/Moztop/CMFMoztop/MoztopSupportTool.py	Sun Mar  2 14:50:40 2003
@@ -80,7 +80,21 @@
         return ''.join(url.split('/')[path_size:-1])
 
     def _normalizePortalType(self, portal_type):
-        return ''.join(str(portal_type).split()).lower()
+        portal_type = ''.join(str(portal_type).split()).lower()
+        portal_type = ''.join(portal_type.split('-'))
+        portal_type = ''.join(portal_type.split('('))
+        portal_type = ''.join(portal_type.split(')'))
+        portal_type = ''.join(portal_type.split('_'))
+        return portal_type
+
+    def getIdentifierFor(self, obj):
+        url_tool = getToolByName(self, 'portal_url')
+        if type(obj) == type(''):
+            url = obj
+            portal_path = url_tool()
+            path_size = len(portal_path.split('/'))
+            return '/'.join(url.split('/')[path_size:])
+        return url_tool.getRelativeURL(obj)
 
     security.declareProtected(View, 'getResources')
     def getResources(self):
@@ -94,7 +108,8 @@
             results.append({'title':title, \
                             'type':self._normalizePortalType(r.portal_type), \
                             'path':self._resourcePath(r.getURL()), \
-                            'parentPath':self._resourceParentPath(r.getURL())})
+                            'parentPath':self._resourceParentPath(r.getURL()),
+                           'identifier':self.getIdentifierFor(r.getURL())})
 
         return results
 
@@ -135,7 +150,8 @@
         results.append({'title':title, \
                         'type':portal_type, \
                         'path':path, \
-                        'parentPath':parentPath})
+                        'parentPath':parentPath,
+                       'identifier':self.getIdentifierFor(skins_url)})
         for ob in skins_tool.objectValues():
             results.extend(self._recurseViewsResources(ob))
         return results
@@ -158,7 +174,8 @@
         results.append({'title':title, \
                         'type': portal_type, \
                         'path':path, \
-                        'parentPath':parentPath})
+                        'parentPath':parentPath,
+                       'identifier':self.getIdentifierFor(ob_path)})
         if hasattr(aq_base(ob), 'objectValues'):
             for subob in ob.objectValues():
                 results.extend(self._recurseViewsResources(subob))
@@ -177,7 +194,8 @@
         results.append({'title':title, \
                         'type':portal_type, \
                         'path':path, \
-                        'parentPath':parentPath})
+                        'parentPath':parentPath,
+                       'identifier':self.getIdentifierFor(types_url)})
         
         for t in types_tool.listTypeInfo():
             title = t.Title()
@@ -188,7 +206,8 @@
             results.append({'title':title, \
                             'type':portal_type, \
                             'path':path, \
-                            'parentPath':parentPath})
+                            'parentPath':parentPath,
+                           'identifier':self.getIdentifierFor(ob_path)})
 
         skins_tool = getToolByName(self, 'portal_skins')
         skins_url = skins_tool.absolute_url()
@@ -199,7 +218,8 @@
         results.append({'title':title, \
                         'type':portal_type, \
                         'path':path, \
-                        'parentPath':parentPath})
+                        'parentPath':parentPath,
+                       'identifier':self.getIdentifierFor(skins_url)})
         
         for skin in skins_tool.getSkinSelections():
             title = skin
@@ -211,7 +231,8 @@
             results.append({'title':title, \
                             'type':portal_type, \
                             'path':path, \
-                            'parentPath':parentPath})
+                            'parentPath':parentPath,
+                            'identifier':self.getIdentifierFor(ob_path)})
 
         wf_tool = getToolByName(self, 'portal_workflow')
         wf_url = wf_tool.absolute_url()
@@ -222,7 +243,8 @@
         results.append({'title':title, \
                         'type':portal_type, \
                         'path':path, \
-                        'parentPath':parentPath})
+                        'parentPath':parentPath,
+                        'identifier':self.getIdentifierFor(wf_url)})
 
         title = 'Available Workflows'
         portal_type = self._normalizePortalType('Folder')
@@ -232,7 +254,8 @@
         results.append({'title':title, \
                         'type':portal_type, \
                         'path':path, \
-                        'parentPath':parentPath})
+                        'parentPath':parentPath,
+                       'identifier':self.getIdentifierFor(ob_url)})
 
         title = 'Type -> Workflow Mappings'
         portal_type = self._normalizePortalType('Folder')
@@ -242,7 +265,8 @@
         results.append({'title':title, \
                         'type':portal_type, \
                         'path':path, \
-                        'parentPath':parentPath})
+                        'parentPath':parentPath,
+                        'identifier':self.getIdentifierFor(ob_url)})
         
         for wf_id in wf_tool.getWorkflowIds():
             ob = getattr(wf_tool, wf_id)
@@ -254,7 +278,8 @@
             results.append({'title':title, \
                             'type':portal_type, \
                             'path':path, \
-                            'parentPath':parentPath})
+                            'parentPath':parentPath,
+                            'identifier':self.getIdentifierFor(ob_path)})
 
         for t in wf_tool._listTypeInfo():
             title = t.Title()
@@ -265,7 +290,8 @@
             results.append({'title':title, \
                             'type':portal_type, \
                             'path':path, \
-                            'parentPath':parentPath})
+                            'parentPath':parentPath,
+                            'identifier':self.getIdentifierFor(ob_path)})
 
         return results
 
@@ -280,7 +306,7 @@
     security.declarePublic('getRealm')
     def getRealm(self):
         url_tool = getToolByName(self, 'portal_url')
-        portal_path = url_tool.getPortalObject().absolute_url()
+        portal_path = url_tool()
         hash = md5.new(portal_path).digest()
         func = lambda x: hex( ord( x ) )[2:]
         md5_sum = '0' + ''.join( map( func, hash ) )