Author: jmorliaguet
Date: Tue Jun  6 00:33:04 2006
New Revision: 3331

Modified:
   cpsskins/branches/paris-sprint-2006/elements/adapters.py
   cpsskins/branches/paris-sprint-2006/setup/README.txt
   cpsskins/branches/paris-sprint-2006/setup/adapters.py
   cpsskins/branches/paris-sprint-2006/setup/interfaces.py
   cpsskins/branches/paris-sprint-2006/setup/manager.py
   cpsskins/branches/paris-sprint-2006/setup/test/dummy.py
   cpsskins/branches/paris-sprint-2006/standard/io/preset.py
   cpsskins/branches/paris-sprint-2006/storage/storage.py
   cpsskins/branches/paris-sprint-2006/ui/screens/common/views.py
   cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/views.py
   cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py

Log:

- IType(o).getTypeName() is now the same as __str__()

  so we can call: str(IType(o))

  the 'name' property is still kept for path adapters in ZPT (obj/type:name)



Modified: cpsskins/branches/paris-sprint-2006/elements/adapters.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/elements/adapters.py    (original)
+++ cpsskins/branches/paris-sprint-2006/elements/adapters.py    Tue Jun  6 
00:33:04 2006
@@ -52,7 +52,7 @@
 
     def getURI(self):
         element = self.element
-        type_name = IType(element).getTypeName()
+        type_name = str(IType(element))
 
         relatable = IRelatable(element, None)
         if relatable is None:

Modified: cpsskins/branches/paris-sprint-2006/setup/README.txt
==============================================================================
--- cpsskins/branches/paris-sprint-2006/setup/README.txt        (original)
+++ cpsskins/branches/paris-sprint-2006/setup/README.txt        Tue Jun  6 
00:33:04 2006
@@ -350,8 +350,8 @@
 
 or as a string that can be passed in a URL or be written in JSON, XML.
 
-    >>> IType(resource).getTypeName()
-    u'canvas-portlet-standard.actions'
+    >>> print IType(resource)
+    canvas-portlet-standard.actions
 
 Note that there is a one-to-one relation between type signatures and type
 signature names:
@@ -428,8 +428,8 @@
     >>> resources.register(name=u'red', resource=color)
     <Preset: cpsskins://[EMAIL PROTECTED]>
 
-    >>> IType(color).getTypeName()
-    u'field-color'
+    >>> print IType(color)
+    field-color
 
     >>> res = resources.resolve(u'cpsskins://[EMAIL PROTECTED]', context=root)
 

Modified: cpsskins/branches/paris-sprint-2006/setup/adapters.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/setup/adapters.py       (original)
+++ cpsskins/branches/paris-sprint-2006/setup/adapters.py       Tue Jun  6 
00:33:04 2006
@@ -68,7 +68,7 @@
     def getURI(self):
         context = self.context
         resource = context.resource
-        return u'cpsskins://[EMAIL PROTECTED]' % 
(IType(resource).getTypeName(),
+        return u'cpsskins://[EMAIL PROTECTED]' % (str(IType(resource)),
                                       context.name)
 
 class Type(object):
@@ -101,7 +101,7 @@
         return uniq([self.getElementType(), self.getResourceType(),
                      self.getContentType()])
 
-    def getTypeName(self):
+    def __str__(self):
         return '-'.join(uniq([self.elementname, self.resourcename,
                               self.contentname]))
 
@@ -111,5 +111,5 @@
 
     contentname = property(getContentName)
 
-    name = property(getTypeName)
+    name = __str__
 

Modified: cpsskins/branches/paris-sprint-2006/setup/interfaces.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/setup/interfaces.py     (original)
+++ cpsskins/branches/paris-sprint-2006/setup/interfaces.py     Tue Jun  6 
00:33:04 2006
@@ -59,7 +59,7 @@
         """Return the element's complete type as a tuple
         """
 
-    def getTypeName():
+    def __str__():
         """Return the element's complete type name
         """
 

Modified: cpsskins/branches/paris-sprint-2006/setup/manager.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/setup/manager.py        (original)
+++ cpsskins/branches/paris-sprint-2006/setup/manager.py        Tue Jun  6 
00:33:04 2006
@@ -136,7 +136,7 @@
             except KeyError:
                 logger.warning("no such identifier: %s", resource_id)
                 return None
-            obj_type = IType(obj).getTypeName()
+            obj_type = str(IType(obj))
             if type_name != obj_type:
                 raise TypeError("type mismatch: expected '%s' got '%s'." % \
                                 (obj_type, type_name))

Modified: cpsskins/branches/paris-sprint-2006/setup/test/dummy.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/setup/test/dummy.py     (original)
+++ cpsskins/branches/paris-sprint-2006/setup/test/dummy.py     Tue Jun  6 
00:33:04 2006
@@ -72,5 +72,5 @@
     def __init__(self, context):
         self.context = context
 
-    def getTypeName(self):
-        return u'dummy'
+    def __str__(self):
+        return 'dummy'

Modified: cpsskins/branches/paris-sprint-2006/standard/io/preset.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/standard/io/preset.py   (original)
+++ cpsskins/branches/paris-sprint-2006/standard/io/preset.py   Tue Jun  6 
00:33:04 2006
@@ -33,7 +33,7 @@
     def updateURIMapping(self):
         context = self.context
         resource = IResource(context).getResource()
-        uri = u'cpsskins://[EMAIL PROTECTED]' % (IType(resource).name,
+        uri = u'cpsskins://[EMAIL PROTECTED]' % (str(IType(resource)),
                                      self.node.getAttribute(u'name'))
         self.mapping.update({uri: context})
 
@@ -47,7 +47,7 @@
 
         preset_el = document.createElement(u'preset')
         preset_el.setAttribute(u'name', context.name)
-        preset_el.setAttribute(u'type', IType(resource).name)
+        preset_el.setAttribute(u'type', str(IType(resource)))
         node.appendChild(preset_el)
 
         # export the resource

Modified: cpsskins/branches/paris-sprint-2006/storage/storage.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/storage/storage.py      (original)
+++ cpsskins/branches/paris-sprint-2006/storage/storage.py      Tue Jun  6 
00:33:04 2006
@@ -41,7 +41,7 @@
         """Add an object to the storage.
         """
         if not name:
-            name = IType(object).name
+            name = str(IType(object))
         chooser = INameChooser(self)
         name = chooser.chooseName(name, object)
         self[name] = object

Modified: cpsskins/branches/paris-sprint-2006/ui/screens/common/views.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/screens/common/views.py      
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/common/views.py      Tue Jun 
 6 00:33:04 2006
@@ -106,8 +106,8 @@
                 'uri': IIdentifiable(context).getURI(),
                 'formattable': True,
                 'formats': [
-                    {'choice': IType(f).name,
-                     'label': _(IType(f).name),
+                    {'choice': str(IType(f)),
+                     'label': _(str(IType(f))),
                      'format': f.identifier,
                     } for f in formats
                 ],

Modified: cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/views.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/views.py       
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/elementeditor/views.py       
Tue Jun  6 00:33:04 2006
@@ -86,12 +86,12 @@
         # Element
         edited = context
         element_info = {
-            'name': IType(context).getTypeName(),
+            'name': str(IType(context)),
             'id': context.identifier,
             }
 
         # Display
-        display_name = IType(display).getTypeName()
+        display_name = str(IType(display))
         if tab == display_name:
             edited = display
 
@@ -107,7 +107,7 @@
             if is_preset:
                 f = IResource(f).getResource()
 
-            format_name = IType(f).getTypeName()
+            format_name = str(IType(f))
             selected = tab == format_name
 
             if selected:

Modified: cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py 
(original)
+++ cpsskins/branches/paris-sprint-2006/ui/screens/sitemanager/views.py Tue Jun 
 6 00:33:04 2006
@@ -53,7 +53,7 @@
         # get all presets
         for preset in resources.list(context=self.context):
             resource = IResource(preset).getResource()
-            info.setdefault(IType(resource).getTypeName(), []).append({
+            info.setdefault(str(IType(resource)), []).append({
                 'name': preset.name,
                 'uri': IIdentifiable(preset).getURI(),
                 'preset': preset,
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to