[kupu-checkins] r46958 - in kupu/trunk/kupu/plone: . kupu_references

duncan at codespeak.net duncan at codespeak.net
Thu Sep 27 15:30:54 CEST 2007


Author: duncan
Date: Thu Sep 27 15:30:52 2007
New Revision: 46958

Modified:
   kupu/trunk/kupu/plone/kupu_references/referencebrowser.pt
   kupu/trunk/kupu/plone/plonedrawers.py
Log:
Re-fixed Plone ticket #7140: kupu fails with danish letters in title, and cleaned up translated labels.


Modified: kupu/trunk/kupu/plone/kupu_references/referencebrowser.pt
==============================================================================
--- kupu/trunk/kupu/plone/kupu_references/referencebrowser.pt	(original)
+++ kupu/trunk/kupu/plone/kupu_references/referencebrowser.pt	Thu Sep 27 15:30:52 2007
@@ -85,15 +85,15 @@
         <div metal:fill-slot="widget_body"
              tal:define="multiVal python:test(field.multiValued, 1, 0);
                          fieldName fieldName;
-                         rFieldName python:repr(repr((isinstance(fieldName,unicode) or unicode(fieldName, 'utf8', 'replace')) and fieldName))[1:];
+                         rFieldName python:repr(unicode(fieldName))[1:];
                          fieldRealName field/getName;
                          portal_type context/portal_type;
                          kupu here/kupu_library_tool;
                          lookupObject nocall:here/reference_catalog/lookupObject;
                          resource_type string:$portal_type.$fieldName;
                          rt python:kupu.getResourceType(resource_type);
-                         label widget/Label|widget/label;
-                         rLabel python:repr(repr((isinstance(label,unicode) or unicode(label, 'utf8', 'replace')) and label))[1:];
+                         label python:kupu.getLabelFromWidget(widget);
+                         rLabel python:repr(label)[1:];
                          uids python:same_type(value, []) and value or [value];
                          uids python:[u for u in uids if u];
                          types_param python:','.join(field.allowed_types);

Modified: kupu/trunk/kupu/plone/plonedrawers.py
==============================================================================
--- kupu/trunk/kupu/plone/plonedrawers.py	(original)
+++ kupu/trunk/kupu/plone/plonedrawers.py	Thu Sep 27 15:30:52 2007
@@ -781,6 +781,14 @@
         return (getattr(field, 'default_output_type', None) in
             ('text/x-html-safe', 'text/x-html-captioned'))
 
+    security.declarePublic("getLabelFromWidget")
+    def getLabelFromWidget(self, widget):
+        """Get the label for a widget converting from i18n message if needed"""
+        label = util.translate(widget.Label(self), self.REQUEST)
+        if isinstance(label, str):
+            label = label.decode('utf8', 'replace')
+        return label
+
     security.declareProtected("View", "getKupuFields")
     def getKupuFields(self, filter=1):
         """Returns a list of all kupu editable fields"""
@@ -788,7 +796,7 @@
         for t,f,pt in self._getKupuFields():
             if html2captioned.sanitize_portal_type(pt) in inuse or not filter:
                 yield dict(type=t, name=f.getName(), portal_type=pt,
-                           label=util.translate(f.widget.Label(self), self.REQUEST))
+                           label=self.getLabelFromWidget(f.widget))
 
     def _getKupuFields(self):
         """Yield all fields which are editable using kupu"""
@@ -806,13 +814,13 @@
     security.declareProtected("View", "supportedCaptioning")
     def supportedCaptioning(self):
         """Returns a list of document/fields which have support for captioning"""
-        supported = [t+'/'+util.translate(f.widget.Label(self), self.REQUEST) for (t,f,pt) in self._getKupuFields() if self.canCaption(f) ]
+        supported = [t+'/'+self.getLabelFromWidget(f.widget) for (t,f,pt) in self._getKupuFields() if self.canCaption(f) ]
         return str.join(', ', supported)
 
     security.declareProtected("View", "unsupportedCaptioning")
     def unsupportedCaptioning(self):
         """Returns a list of document/fields which do not have support for captioning"""
-        unsupp = [t+'/'+util.translate(f.widget.Label(self), self.REQUEST) for (t,f,pt) in self._getKupuFields() if not self.canCaption(f) ]
+        unsupp = [t+'/'+self.getLabelFromWidget(f.widget) for (t,f,pt) in self._getKupuFields() if not self.canCaption(f) ]
         return str.join(', ', unsupp)
 
     security.declareProtected("View", "transformIsEnabled")


More information about the kupu-checkins mailing list