Management of floats with a given precision; XmlMarshaller can dump unicode or str result.
This commit is contained in:
parent
3bb907ca5d
commit
2e1c6a6999
5 changed files with 37 additions and 7 deletions
|
@ -262,6 +262,12 @@ class AbstractMixin:
|
|||
elif vType == 'Boolean':
|
||||
if v: return self.translate('yes', domain='plone')
|
||||
else: return self.translate('no', domain='plone')
|
||||
elif vType == 'Float':
|
||||
if appyType['precision'] == None:
|
||||
v = str(v)
|
||||
else:
|
||||
format = '%%.%df' % appyType['precision']
|
||||
v = format % v
|
||||
return v
|
||||
|
||||
def getAppyType(self, fieldName, forward=True, asDict=True):
|
||||
|
|
|
@ -121,6 +121,14 @@
|
|||
<span tal:replace="v"></span>
|
||||
</metal:showDate>
|
||||
|
||||
<metal:showFloat define-macro="showFloatField"
|
||||
tal:define="v python: contextObj.getAppyValue(field.getName(), appyType)">
|
||||
<span tal:condition="showLabel" tal:content="label"
|
||||
tal:attributes="class python: 'appyLabel ' + contextObj.getCssClasses(appyType, asSlave=False);
|
||||
id python: v"></span>
|
||||
<span tal:replace="v"></span>
|
||||
</metal:showFloat>
|
||||
|
||||
<metal:showString define-macro="showStringField"
|
||||
tal:define="v python: contextObj.getAppyValue(field.getName(), appyType);
|
||||
fmt python: appyType['format'];
|
||||
|
@ -179,7 +187,10 @@
|
|||
<tal:string condition="python: appyType['type'] == 'String'">
|
||||
<metal:showString use-macro="here/skyn/macros/macros/showStringField"/>
|
||||
</tal:string>
|
||||
<tal:simpleField condition="python: (appyType['type'] in ('Integer', 'Float', 'Boolean'))">
|
||||
<tal:float condition="python: appyType['type'] == 'Float'">
|
||||
<metal:showFloat use-macro="here/skyn/macros/macros/showFloatField"/>
|
||||
</tal:float>
|
||||
<tal:simpleField condition="python: (appyType['type'] in ('Integer', 'Boolean'))">
|
||||
<span tal:condition="showLabel" tal:content="label"
|
||||
tal:attributes="class python: 'appyLabel ' + contextObj.getCssClasses(appyType, asSlave=False);
|
||||
id python: field.getAccessor(contextObj)()"></span>
|
||||
|
|
|
@ -350,7 +350,8 @@ class AbstractWrapper:
|
|||
if toDisk and not at:
|
||||
at = getOsTempFolder() + '/' + self.o.UID() + '.xml'
|
||||
# Create the XML version of the object
|
||||
xml = XmlMarshaller(cdata=True).marshall(self.o, objectType='appy')
|
||||
xml = XmlMarshaller(cdata=True, dumpUnicode=True).marshall(
|
||||
self.o, objectType='appy')
|
||||
# Produce the desired result
|
||||
if toDisk:
|
||||
f = file(at, 'w')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue