[Testbot] Plone 4.3 - Python 2.6 - Build # 2062 - Fixed! - 0 failure(s)

jenkins at plone.org jenkins at plone.org
Fri May 9 17:13:17 UTC 2014


-------------------------------------------------------------------------------
Plone 4.3 - Python 2.6 - Build # 2062 - Fixed!
-------------------------------------------------------------------------------

http://jenkins.plone.org/job/plone-4.3-python-2.6/2062/


-------------------------------------------------------------------------------
CHANGES
-------------------------------------------------------------------------------

Repository: plone.app.textfield
Branch: refs/heads/master
Date: 2014-03-10T16:56:20-07:00
Author: Elizabeth Leddy (eleddy) <eleddy at umich.edu>
Commit: https://github.com/plone/plone.app.textfield/commit/867f0f6911b96772d1ce660711447aeefbc4a5c4

Do not give an error when the raw value is not unicode and isn't ascii. In that case, encode as unicode then decode as the proper string, bang head on desk.

Files changed:
M docs/HISTORY.txt
M plone/app/textfield/value.py

diff --git a/docs/HISTORY.txt b/docs/HISTORY.txt
index 05d9667..d8da17a 100644
--- a/docs/HISTORY.txt
+++ b/docs/HISTORY.txt
@@ -4,7 +4,10 @@ Changelog
 1.2.4 (unreleased)
 ------------------
 
-- Nothing changed yet.
+- Do not give an error when the raw value is not unicode and isn't
+  ascii. In that case, encode as unicode then decode as the proper
+  string, bang head on desk.
+  [eleddy]
 
 
 1.2.3 (2014-01-27)
diff --git a/plone/app/textfield/value.py b/plone/app/textfield/value.py
index 3f255e9..38479b1 100644
--- a/plone/app/textfield/value.py
+++ b/plone/app/textfield/value.py
@@ -51,8 +51,12 @@ def encoding(self):
     def raw_encoded(self):
         if self._raw_holder.value is None:
             return ''
-        return self._raw_holder.value.encode(self.encoding)
-    
+        try:
+            return self._raw_holder.value.encode(self.encoding)
+        except UnicodeDecodeError:  # unicode values getting saved as plain str
+            return unicode(self._raw_holder.value,
+                           self.encoding).encode(self.encoding, 'ignore')
+
     # the current mime type
     
     @property


Repository: plone.app.textfield
Branch: refs/heads/master
Date: 2014-03-10T17:27:20-07:00
Author: Elizabeth Leddy (eleddy) <eleddy at umich.edu>
Commit: https://github.com/plone/plone.app.textfield/commit/8418e8f82fc3977bb59337b9c9804664007b9fc1

fix this with safe_unicode, which is the shit and should be used forever and ever all the time.

Files changed:
M plone/app/textfield/value.py

diff --git a/plone/app/textfield/value.py b/plone/app/textfield/value.py
index 38479b1..b3e2052 100644
--- a/plone/app/textfield/value.py
+++ b/plone/app/textfield/value.py
@@ -4,9 +4,11 @@
 from zope.component.hooks import getSite
 
 from plone.app.textfield.interfaces import IRichTextValue, ITransformer, TransformError
+from Products.CMFPlone.utils import safe_unicode
 
 from persistent import Persistent
 
+
 LOG = logging.getLogger('plone.app.textfield')
 
 class RawValueHolder(Persistent):
@@ -51,11 +53,10 @@ def encoding(self):
     def raw_encoded(self):
         if self._raw_holder.value is None:
             return ''
-        try:
-            return self._raw_holder.value.encode(self.encoding)
-        except UnicodeDecodeError:  # unicode values getting saved as plain str
-            return unicode(self._raw_holder.value,
-                           self.encoding).encode(self.encoding, 'ignore')
+        happy_value = safe_unicode(self._raw_holder.value,
+                                   encoding=self.encoding)
+        return happy_value.encode(self.encoding, 'ignore')
+
 
     # the current mime type
     


Repository: plone.app.textfield
Branch: refs/heads/master
Date: 2014-05-09T09:34:53-07:00
Author: Elizabeth Leddy (eleddy) <eleddy at umich.edu>
Commit: https://github.com/plone/plone.app.textfield/commit/e712829e5afbc0b41ff8092aaf598ca5288a449d

get pull up to date

Files changed:
M .gitignore
M docs/HISTORY.txt
M plone/app/textfield/__init__.py
M plone/app/textfield/browser.py
M plone/app/textfield/editor.py
M plone/app/textfield/interfaces.py
M plone/app/textfield/value.py
M plone/app/textfield/widget_input.pt

diff --git a/.gitignore b/.gitignore
index 837534d..74b79c6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
 plone.app.textfield.egg-info
 *.pyc
 *.pyo
+.pydevproject
+.project
diff --git a/docs/HISTORY.txt b/docs/HISTORY.txt
index d8da17a..4831d92 100644
--- a/docs/HISTORY.txt
+++ b/docs/HISTORY.txt
@@ -8,6 +8,8 @@ Changelog
   ascii. In that case, encode as unicode then decode as the proper
   string, bang head on desk.
   [eleddy]
+- Internationalization.
+  [thomasdesvenain]
 
 
 1.2.3 (2014-01-27)
diff --git a/plone/app/textfield/__init__.py b/plone/app/textfield/__init__.py
index 664c211..345df57 100644
--- a/plone/app/textfield/__init__.py
+++ b/plone/app/textfield/__init__.py
@@ -1,28 +1,33 @@
 from zope.interface import implements
 from zope.interface import Invalid
+from zope.i18nmessageid.message import MessageFactory
 from zope.schema import Object
 
 from zope.schema.interfaces import IFromUnicode
 from zope.schema.interfaces import WrongType
 from zope.schema._bootstrapinterfaces import ConstraintNotSatisfied
 
+_ = MessageFactory('plone')
+
 from plone.app.textfield.interfaces import IRichText, IRichTextValue
 from plone.app.textfield.value import RichTextValue
 
+
+
 class RichText(Object):
     """Text field that also stores MIME type
     """
-    
+
     implements(IRichText, IFromUnicode)
-    
+
     default_mime_type = 'text/html'
     output_mime_type = 'text/x-html-safe'
     allowed_mime_types = None
     max_length = None
-    
+
     def __init__(self,
         default_mime_type='text/html',
-        output_mime_type='text/x-html-safe', 
+        output_mime_type='text/x-html-safe',
         allowed_mime_types=None,
         max_length=None,
         schema=IRichTextValue,
@@ -32,29 +37,31 @@ def __init__(self,
         self.output_mime_type = output_mime_type
         self.allowed_mime_types = allowed_mime_types
         self.max_length = max_length
-        
+
         if 'default' in kw:
             default = kw['default']
             if isinstance(default, unicode):
                 kw['default'] = self.fromUnicode(default)
                 kw['default'].readonly = True
-        
+
         super(RichText, self).__init__(schema=schema, **kw)
 
-    def fromUnicode(self, str):
+    def fromUnicode(self, str_val):
         return RichTextValue(
-                raw=str,
+                raw=str_val,
                 mimeType=self.default_mime_type,
                 outputMimeType=self.output_mime_type,
                 encoding='utf-8',
             )
-        
+
     def _validate(self, value):
         if self.allowed_mime_types and value.mimeType not in self.allowed_mime_types:
             raise WrongType(value, self.allowed_mime_types)
 
         if self.max_length is not None and len(value.raw) > self.max_length:
-            raise Invalid(u'Text is too long. (Maximum %s characters.)' % self.max_length)
+            raise Invalid(_('msg_text_too_long',
+                          default=u'Text is too long. (Maximum ${max} characters.)',
+                          mapping={'max': self.max_length}))
 
         if not self.constraint(value):
             raise ConstraintNotSatisfied(value)
diff --git a/plone/app/textfield/browser.py b/plone/app/textfield/browser.py
index 0fbfd39..e2d3312 100644
--- a/plone/app/textfield/browser.py
+++ b/plone/app/textfield/browser.py
@@ -1,6 +1,3 @@
-from zope.interface import implements
-from zope.publisher.interfaces import IPublishTraverse
-
 from Acquisition import aq_inner
 from Products.Five.browser import BrowserView
 
@@ -8,24 +5,24 @@
 
 class Transform(BrowserView):
     """Invoke a transformation on a RichText field.
-    
+
     Invoke as:
-    
+
         context/@@text-transform/fieldname
-    
+
     Or:
-    
+
         context/@@text-transform/fieldname/major/minor
-    
+
     e.g.
-    
+
         context/@@text-transform/fieldname/text/plain
     """
-    
+
     fieldName = None
     major = None
     minor = None
-    
+
     def __getitem__(self, name):
         if self.fieldName is None:
             self.fieldName = name
@@ -34,21 +31,21 @@ def __getitem__(self, name):
         elif self.minor is None:
             self.minor = name
         return self
-        
+
     def __call__(self, value=None, fieldName=None, mimeType=None):
         context = aq_inner(self.context)
-        
+
         if fieldName is None:
             fieldName = self.fieldName
-        
+
         if value is None:
             value = getattr(context, fieldName)
-        
+
         if mimeType is None:
             if not self.major or not self.minor:
                 mimeType = value.outputMimeType
             else:
                 mimeType = "%s/%s" % (self.major, self.minor,)
-        
+
         transformer = ITransformer(context)
         return transformer(value, mimeType)
diff --git a/plone/app/textfield/editor.py b/plone/app/textfield/editor.py
index 4d6a998..b389ad3 100644
--- a/plone/app/textfield/editor.py
+++ b/plone/app/textfield/editor.py
@@ -2,9 +2,11 @@
 from zope.schema import interfaces as schema_ifaces
 from zope import schema
 
+from plone.schemaeditor.fields import FieldFactory
 from plone.app.textfield import interfaces
 from plone.app.textfield import RichText
-from plone.schemaeditor.fields import FieldFactory
+from plone.app.textfield import _
+
 
 try:
     import plone.app.vocabularies
@@ -17,7 +19,7 @@ class IRichText(interfaces.IRichText, schema_ifaces.IFromUnicode):
 
     if HAS_VOCABS:
         default_mime_type = schema.Choice(
-            title = u'Input format',
+            title = _(u'Input format'),
             vocabulary = 'plone.app.vocabularies.AllowedContentTypes',
             default = 'text/html',
             )
@@ -30,4 +32,4 @@ class IRichText(interfaces.IRichText, schema_ifaces.IFromUnicode):
     allowed_mime_types = Attribute('')
 
 
-RichTextFactory = FieldFactory(RichText, u'Rich Text')
+RichTextFactory = FieldFactory(RichText, _(u'Rich Text'))
diff --git a/plone/app/textfield/interfaces.py b/plone/app/textfield/interfaces.py
index 7e919fc..28eca3b 100644
--- a/plone/app/textfield/interfaces.py
+++ b/plone/app/textfield/interfaces.py
@@ -1,33 +1,35 @@
 from zope.interface import Interface
-
-from zope.schema.interfaces import IObject, IMinMaxLen
+from zope.schema.interfaces import IObject
 from zope import schema
 
+from plone.app.textfield import _
+
+
 class IRichText(IObject):
     """A text field that stores MIME type
     """
 
     default_mime_type = schema.ASCIILine(
-            title=u"Default MIME type",
+            title=_(u"Default MIME type"),
             default='text/html',
         )
-    
+
     output_mime_type = schema.ASCIILine(
-            title=u"Default output MIME type",
+            title=_(u"Default output MIME type"),
             default='text/x-html-safe'
         )
-    
+
     allowed_mime_types = schema.Tuple(
-            title=u"Allowed MIME types",
-            description=u"Set to None to disable checking",
+            title=_(u"Allowed MIME types"),
+            description=_(u"Set to None to disable checking"),
             default=None,
             required=False,
             value_type=schema.ASCIILine(title=u"MIME type"),
         )
 
     max_length = schema.Int(
-        title=u'Maximum length',
-        description=u'in characters',
+        title=_(u'Maximum length'),
+        description=_(u'in characters'),
         required=False,
         min=0,
         default=None,
@@ -36,74 +38,76 @@ class IRichText(IObject):
 
 class IRichTextValue(Interface):
     """The value actually stored in a RichText field.
-    
+
     This stores the following values on the parent object
-    
+
       - A separate persistent object with the original value
       - A cache of the value transformed to the default output type
-      
+
     The object is immutable.
     """
 
     raw = schema.Text(
-            title=u"Raw value in the original MIME type",
+            title=_(u"Raw value in the original MIME type"),
             readonly=True,
         )
-    
+
     mimeType = schema.ASCIILine(
-            title=u"MIME type",
+            title=_(u"MIME type"),
             readonly=True,
         )
-    
+
     outputMimeType = schema.ASCIILine(
-            title=u"Default output MIME type",
+            title=_(u"Default output MIME type"),
             readonly=True,
         )
-        
+
     encoding = schema.ASCIILine(
-            title=u"Default encoding for the value",
-            description=u"Mainly used internally",
+            title=_(u"Default encoding for the value"),
+            description=_(u"Mainly used internally"),
             readonly=True,
         )
 
     raw_encoded = schema.ASCII(
-            title=u"Get the raw value as an encoded string",
-            description=u"Mainly used internally",
+            title=_(u"Get the raw value as an encoded string"),
+            description=_(u"Mainly used internally"),
             readonly=True,
         )
-    
+
     output = schema.Text(
-            title=u"Transformed value in the target MIME type",
-            description=u"May be None if the transform cannot be completed",
+            title=_(u"Transformed value in the target MIME type"),
+            description=_(u"May be None if the transform cannot be completed"),
             readonly=True,
             required=False,
             missing_value=None,
         )
 
+
 class TransformError(Exception):
     """Exception raised if a value could not be transformed. This is normally
     caused by another exception. Inspect self.cause to find that.
     """
-    
+
     def __init__(self, message, cause=None):
         self.message = message
         self.cause = cause
-    
+
     def __str__(self):
         return self.message
 
+
 class ITransformer(Interface):
     """A simple abstraction for invoking a transformation from one MIME
     type to another.
-    
+
     This is not intended as a general transformations framework, but rather
     as a way to abstract away a dependency on the underlying transformation
     engine.
-    
+
     This interface will be implemented by an adapter onto the context where
     the value is stored.
     """
-    
+
     def __call__(value, mimeType):
         """Transform the IRichTextValue 'value' to the given MIME type.
         Return a unicode string. Raises TransformError if something went
diff --git a/plone/app/textfield/value.py b/plone/app/textfield/value.py
index b3e2052..fbe8259 100644
--- a/plone/app/textfield/value.py
+++ b/plone/app/textfield/value.py
@@ -2,10 +2,8 @@
 
 from zope.interface import implements
 from zope.component.hooks import getSite
-
-from plone.app.textfield.interfaces import IRichTextValue, ITransformer, TransformError
 from Products.CMFPlone.utils import safe_unicode
-
+from plone.app.textfield.interfaces import IRichTextValue, ITransformer
 from persistent import Persistent
 
 
@@ -15,34 +13,34 @@ class RawValueHolder(Persistent):
     """Place the raw value in a separate persistent object so that it does not
     get loaded when all we want is the output.
     """
-    
+
     def __init__(self, value):
         self.value = value
-        
+
     def __repr__(self):
         return u"<RawValueHolder: %s>" % self.value
 
 class RichTextValue(object):
     """The actual value.
-    
+
     Note that this is not a persistent object, to avoid a separate ZODB object
     being loaded.
     """
-    
+
     implements(IRichTextValue)
-    
+
     def __init__(self, raw=None, mimeType=None, outputMimeType=None, encoding='utf-8', output=None):
         self._raw_holder     = RawValueHolder(raw)
         self._mimeType       = mimeType
         self._outputMimeType = outputMimeType
         self._encoding       = encoding
-            
+
     # the raw value - stored in a separate persistent object
-    
+
     @property
     def raw(self):
         return self._raw_holder.value
-    
+
     # Encoded raw value
 
     @property
@@ -57,24 +55,22 @@ def raw_encoded(self):
                                    encoding=self.encoding)
         return happy_value.encode(self.encoding, 'ignore')
 
-
     # the current mime type
-    
     @property
     def mimeType(self):
         return self._mimeType
 
     # the default mime type
-    
+
     @property
     def outputMimeType(self):
         return self._outputMimeType
-    
+
     @property
     def output(self):
         site = getSite()
         return self.output_relative_to(site)
-    
+
     def output_relative_to(self, context):
         """Transforms the raw value to the output mimetype, within a specified context.
 
@@ -100,6 +96,6 @@ def output_relative_to(self, context):
                 return None
 
         return transformer(self, self.outputMimeType)
-    
+
     def __repr__(self):
         return u"RichTextValue object. (Did you mean <attribute>.raw or <attribute>.output?)"
diff --git a/plone/app/textfield/widget_input.pt b/plone/app/textfield/widget_input.pt
index 93af3fd..1c6720f 100644
--- a/plone/app/textfield/widget_input.pt
+++ b/plone/app/textfield/widget_input.pt
@@ -4,7 +4,7 @@
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
-     i18n:domain="plone.app.textfield"
+     i18n:domain="plone"
      tal:attributes="class view/klass;
                      style view/style;
                      title view/title;
@@ -68,5 +68,5 @@
             The WYSIWYG code
         </div>
     </tal:editor>
-  
+
 </div>


Repository: plone.app.textfield
Branch: refs/heads/master
Date: 2014-05-09T09:35:53-07:00
Author: Elizabeth Leddy (eleddy) <eleddy at eastofeaton.com>
Commit: https://github.com/plone/plone.app.textfield/commit/f2778ca8cadb98919163d33931ae55a7860bc1cc

Merge pull request #8 from ampsport/master

Do not give an error when the raw value is not unicode and isn't ascii. ...

Files changed:
M docs/HISTORY.txt
M plone/app/textfield/value.py

diff --git a/docs/HISTORY.txt b/docs/HISTORY.txt
index ef42bb4..4831d92 100644
--- a/docs/HISTORY.txt
+++ b/docs/HISTORY.txt
@@ -4,6 +4,10 @@ Changelog
 1.2.4 (unreleased)
 ------------------
 
+- Do not give an error when the raw value is not unicode and isn't
+  ascii. In that case, encode as unicode then decode as the proper
+  string, bang head on desk.
+  [eleddy]
 - Internationalization.
   [thomasdesvenain]
 
diff --git a/plone/app/textfield/value.py b/plone/app/textfield/value.py
index a61690d..fbe8259 100644
--- a/plone/app/textfield/value.py
+++ b/plone/app/textfield/value.py
@@ -2,11 +2,11 @@
 
 from zope.interface import implements
 from zope.component.hooks import getSite
-
+from Products.CMFPlone.utils import safe_unicode
 from plone.app.textfield.interfaces import IRichTextValue, ITransformer
-
 from persistent import Persistent
 
+
 LOG = logging.getLogger('plone.app.textfield')
 
 class RawValueHolder(Persistent):
@@ -51,10 +51,11 @@ def encoding(self):
     def raw_encoded(self):
         if self._raw_holder.value is None:
             return ''
-        return self._raw_holder.value.encode(self.encoding)
+        happy_value = safe_unicode(self._raw_holder.value,
+                                   encoding=self.encoding)
+        return happy_value.encode(self.encoding, 'ignore')
 
     # the current mime type
-
     @property
     def mimeType(self):
         return self._mimeType




-------------------------------------------------------------------------------


More information about the Testbot mailing list