Bugfixes in appyObj.dump and in master/slave relationships.

This commit is contained in:
Gaetan Delannay 2010-05-10 11:04:59 +02:00
parent 74d28a76c0
commit 309ea921fa
4 changed files with 14 additions and 8 deletions

View file

@ -217,13 +217,18 @@ class AbstractMixin:
else: params = '?' + params else: params = '?' + params
return rq.RESPONSE.redirect(url+params) return rq.RESPONSE.redirect(url+params)
def getAppyValue(self, name, appyType=None, useParamValue=False,value=None): def getAppyValue(self, name, appyType=None, useParamValue=False,
value=None, forMasterId=False):
'''Returns the value of field (or method) p_name for this object '''Returns the value of field (or method) p_name for this object
(p_self). If p_appyType (the corresponding Appy type) is provided, (p_self). If p_appyType (the corresponding Appy type) is provided,
it gives additional information about the way to render the value. it gives additional information about the way to render the value.
If p_useParamValue is True, the method uses p_value instead of the If p_useParamValue is True, the method uses p_value instead of the
real field value (useful for rendering a value from the object real field value (useful for rendering a value from the object
history, for example).''' history, for example).
If p_forMasterId is True, it returns the value as will be needed to
produce an identifier used within HTML pages for master/slave
relationships.'''
# Which value will we use ? # Which value will we use ?
if useParamValue: v = value if useParamValue: v = value
else: else:
@ -243,7 +248,7 @@ class AbstractMixin:
res += ' %s' % v.strftime('%H:%M') res += ' %s' % v.strftime('%H:%M')
return res return res
elif vType == 'String': elif vType == 'String':
if not v: return v if not v or forMasterId: return v
if appyType['isSelect']: if appyType['isSelect']:
validator = appyType['validator'] validator = appyType['validator']
if isinstance(validator, Selection): if isinstance(validator, Selection):

View file

@ -72,6 +72,7 @@
<div metal:define-macro="showComputedField"> <div metal:define-macro="showComputedField">
<span class="appyLabel" tal:condition="showLabel" tal:content="label"></span> <span class="appyLabel" tal:condition="showLabel" tal:content="label"></span>
<span class="formHelp" tal:content="structure description"></span>
<tal:showValue define="theValue python: contextObj.getComputedValue(appyType)"> <tal:showValue define="theValue python: contextObj.getComputedValue(appyType)">
<span tal:condition="appyType/plainText" tal:replace="theValue"/> <span tal:condition="appyType/plainText" tal:replace="theValue"/>
<span tal:condition="not: appyType/plainText" tal:replace="structure theValue"/> <span tal:condition="not: appyType/plainText" tal:replace="structure theValue"/>
@ -80,7 +81,7 @@
<div metal:define-macro="showInfoField"> <div metal:define-macro="showInfoField">
<span class="appyLabel" tal:content="structure label"></span> <span class="appyLabel" tal:content="structure label"></span>
<span tal:content="structure description"></span> <span class="formHelp" tal:content="structure description"></span>
</div> </div>
<div metal:define-macro="showActionField"> <div metal:define-macro="showActionField">
@ -122,7 +123,7 @@
<tal:simpleString condition="python: fmt in (0, 3)"> <tal:simpleString condition="python: fmt in (0, 3)">
<span tal:condition="showLabel" tal:content="label" class="appyLabel" <span tal:condition="showLabel" tal:content="label" class="appyLabel"
tal:attributes="class python: 'appyLabel ' + contextObj.getCssClasses(appyType, asSlave=False); tal:attributes="class python: 'appyLabel ' + contextObj.getCssClasses(appyType, asSlave=False);
id python: v"></span> id python: contextObj.getAppyValue(field.getName(), appyType, forMasterId=True)"></span>
<ul class="appyList" tal:condition="python: v and severalValues"> <ul class="appyList" tal:condition="python: v and severalValues">
<li class="appyBullet" tal:repeat="sv v"><i tal:content="structure sv"></i></li> <li class="appyBullet" tal:repeat="sv v"><i tal:content="structure sv"></i></li>
</ul> </ul>
@ -223,7 +224,7 @@
<tal:masterString condition="python: isEdit and (appyType['type'] in ('String', 'Boolean')) and (appyType['slaves'])"> <tal:masterString condition="python: isEdit and (appyType['type'] in ('String', 'Boolean')) and (appyType['slaves'])">
<metal:mf use-macro="here/skyn/macros/macros/editField" /> <metal:mf use-macro="here/skyn/macros/macros/editField" />
</tal:masterString> </tal:masterString>
<tal:infoField condition="python: (not isEdit) and (appyType['type'] == 'Info')"> <tal:infoField condition="python: appyType['type'] == 'Info'">
<metal:af use-macro="here/skyn/macros/macros/showInfoField" /> <metal:af use-macro="here/skyn/macros/macros/showInfoField" />
</tal:infoField> </tal:infoField>
<tal:podField condition="python: (not isEdit) and (appyType['type'] == 'Pod')"> <tal:podField condition="python: (not isEdit) and (appyType['type'] == 'Pod')">

View file

@ -421,7 +421,7 @@ class FileWrapper:
OpenOffice in server mode.''' OpenOffice in server mode.'''
if not filePath: if not filePath:
filePath = '%s/file%f.%s' % (getOsTempFolder(), time.time(), filePath = '%s/file%f.%s' % (getOsTempFolder(), time.time(),
self.name) normalizeString(self.name))
f = file(filePath, 'w') f = file(filePath, 'w')
if self.content.__class__.__name__ == 'Pdata': if self.content.__class__.__name__ == 'Pdata':
# The file content is splitted in several chunks. # The file content is splitted in several chunks.

View file

@ -91,7 +91,7 @@ def normalizeString(s, usage='fileName'):
elif not isinstance(s, unicode): s = unicode(s) elif not isinstance(s, unicode): s = unicode(s)
if usage == 'fileName': if usage == 'fileName':
# Remove any char that can't be found within a file name under # Remove any char that can't be found within a file name under
# Windows. # Windows or that could lead to problems with OpenOffice.
res = '' res = ''
for char in s: for char in s:
if char not in unwantedChars: if char not in unwantedChars: