appy.gen: bugfixes.

This commit is contained in:
Gaetan Delannay 2012-03-08 20:56:14 +01:00
parent 7b0b7e147d
commit 0dd8b72dca
6 changed files with 16 additions and 19 deletions

View file

@ -36,4 +36,6 @@ class Object:
res += u'%s=<encoding problem> ' % attrName res += u'%s=<encoding problem> ' % attrName
res = res.strip() + '>' res = res.strip() + '>'
return res.encode('utf-8') return res.encode('utf-8')
def __nonzero__(self):
return bool(self.__dict__)
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------

View file

@ -1346,21 +1346,19 @@ class String(Type):
return value return value
def getStorableValue(self, value): def getStorableValue(self, value):
if not self.isEmptyValue(value) and (self.transform != 'none'): isString = isinstance(value, basestring)
if isinstance(value, basestring): # Apply transform if required
return self.applyTransform(value) if isString and not self.isEmptyValue(value) and \
else: (self.transform != 'none'):
return [self.applyTransform(v) for v in value] value = self.applyTransform(value)
return value
def store(self, obj, value):
if self.isMultiValued() and isinstance(value, basestring):
value = [value]
# Truncate the result if longer than self.maxChars # Truncate the result if longer than self.maxChars
if self.maxChars and isinstance(value, basestring) and \ if isString and self.maxChars and (len(value) > self.maxChars):
(len(value) > self.maxChars):
value = value[:self.maxChars] value = value[:self.maxChars]
exec 'obj.%s = value' % self.name # Get a multivalued value if required.
if value and self.isMultiValued() and \
(type(value) not in sequenceTypes):
value = [value]
return value
def getIndexType(self): def getIndexType(self):
'''Index type varies depending on String parameters.''' '''Index type varies depending on String parameters.'''

View file

@ -192,7 +192,7 @@ toolFieldPrefixes = ('defaultValue', 'podTemplate', 'formats', 'resultColumns',
defaultToolFields = ('title', 'users', 'groups', 'translations', defaultToolFields = ('title', 'users', 'groups', 'translations',
'enableNotifications', 'unoEnabledPython','openOfficePort', 'enableNotifications', 'unoEnabledPython','openOfficePort',
'numberOfResultsPerPage', 'listBoxesMaximumWidth', 'numberOfResultsPerPage', 'listBoxesMaximumWidth',
'appyVersion', 'refreshSecurity') 'appyVersion')
class Tool(ModelClass): class Tool(ModelClass):
# In a ModelClass we need to declare attributes in the following list. # In a ModelClass we need to declare attributes in the following list.
@ -207,8 +207,6 @@ class Tool(ModelClass):
numberOfResultsPerPage = gen.Integer(default=30) numberOfResultsPerPage = gen.Integer(default=30)
listBoxesMaximumWidth = gen.Integer(default=100) listBoxesMaximumWidth = gen.Integer(default=100)
appyVersion = gen.String(show=False, layouts='f') appyVersion = gen.String(show=False, layouts='f')
def refreshSecurity(self): pass # Real method in the wrapper
refreshSecurity = gen.Action(action=refreshSecurity, confirm=True)
# Ref(User) will maybe be transformed into Ref(CustomUserClass). # Ref(User) will maybe be transformed into Ref(CustomUserClass).
users = gen.Ref(User, multiplicity=(0,None), add=True, link=False, users = gen.Ref(User, multiplicity=(0,None), add=True, link=False,
back=gen.Ref(attribute='toTool', show=False), back=gen.Ref(attribute='toTool', show=False),

View file

@ -502,7 +502,7 @@ function updateRowNumber(row, rowIndex, action) {
with new p_rowIndex. If p_action is 'set', p_rowIndex becomes the new with new p_rowIndex. If p_action is 'set', p_rowIndex becomes the new
index. If p_action is 'add', new index becomes: index. If p_action is 'add', new index becomes:
existing index + p_rowIndex. */ existing index + p_rowIndex. */
var tagTypes = ['input', 'select', 'img']; var tagTypes = ['input', 'select', 'img', 'textarea'];
var currentIndex = -1; var currentIndex = -1;
for (var i=0; i < tagTypes.length; i++) { for (var i=0; i < tagTypes.length; i++) {
var widgets = row.getElementsByTagName(tagTypes[i]); var widgets = row.getElementsByTagName(tagTypes[i]);

View file

@ -1,5 +1,5 @@
<tal:comment replace="nothing">Single row.</tal:comment> <tal:comment replace="nothing">Single row.</tal:comment>
<tr metal:define-macro="row" <tr metal:define-macro="row" valign="top"
tal:attributes="style python: (rowIndex==-1) and 'display: none' or ''"> tal:attributes="style python: (rowIndex==-1) and 'display: none' or ''">
<td align="center" tal:repeat="fieldInfo widget/fieldsd"> <td align="center" tal:repeat="fieldInfo widget/fieldsd">
<tal:show define="widget python: fieldInfo[1]; <tal:show define="widget python: fieldInfo[1];

View file

@ -133,5 +133,4 @@ class ToolWrapper(AbstractWrapper):
expression="ctx['nb'] += int(obj.o.refreshSecurity())") expression="ctx['nb'] += int(obj.o.refreshSecurity())")
msg = 'Security refresh: %d object(s) updated.' % context['nb'] msg = 'Security refresh: %d object(s) updated.' % context['nb']
self.log(msg) self.log(msg)
self.say(msg)
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------