From 0dd8b72dcaf681e4d1d984d3fee205a1dfcc7484 Mon Sep 17 00:00:00 2001 From: Gaetan Delannay Date: Thu, 8 Mar 2012 20:56:14 +0100 Subject: [PATCH] appy.gen: bugfixes. --- __init__.py | 2 ++ gen/__init__.py | 24 +++++++++++------------- gen/model.py | 4 +--- gen/ui/appy.js | 2 +- gen/ui/widgets/list.pt | 2 +- gen/wrappers/ToolWrapper.py | 1 - 6 files changed, 16 insertions(+), 19 deletions(-) diff --git a/__init__.py b/__init__.py index 8f793ea..f759e96 100644 --- a/__init__.py +++ b/__init__.py @@ -36,4 +36,6 @@ class Object: res += u'%s= ' % attrName res = res.strip() + '>' return res.encode('utf-8') + def __nonzero__(self): + return bool(self.__dict__) # ------------------------------------------------------------------------------ diff --git a/gen/__init__.py b/gen/__init__.py index c93f05c..233d375 100644 --- a/gen/__init__.py +++ b/gen/__init__.py @@ -1346,21 +1346,19 @@ class String(Type): return value def getStorableValue(self, value): - if not self.isEmptyValue(value) and (self.transform != 'none'): - if isinstance(value, basestring): - return self.applyTransform(value) - else: - return [self.applyTransform(v) for v in value] - return value - - def store(self, obj, value): - if self.isMultiValued() and isinstance(value, basestring): - value = [value] + isString = isinstance(value, basestring) + # Apply transform if required + if isString and not self.isEmptyValue(value) and \ + (self.transform != 'none'): + value = self.applyTransform(value) # Truncate the result if longer than self.maxChars - if self.maxChars and isinstance(value, basestring) and \ - (len(value) > self.maxChars): + if isString and self.maxChars and (len(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): '''Index type varies depending on String parameters.''' diff --git a/gen/model.py b/gen/model.py index bde092e..fdcae24 100644 --- a/gen/model.py +++ b/gen/model.py @@ -192,7 +192,7 @@ toolFieldPrefixes = ('defaultValue', 'podTemplate', 'formats', 'resultColumns', defaultToolFields = ('title', 'users', 'groups', 'translations', 'enableNotifications', 'unoEnabledPython','openOfficePort', 'numberOfResultsPerPage', 'listBoxesMaximumWidth', - 'appyVersion', 'refreshSecurity') + 'appyVersion') class Tool(ModelClass): # In a ModelClass we need to declare attributes in the following list. @@ -207,8 +207,6 @@ class Tool(ModelClass): numberOfResultsPerPage = gen.Integer(default=30) listBoxesMaximumWidth = gen.Integer(default=100) 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). users = gen.Ref(User, multiplicity=(0,None), add=True, link=False, back=gen.Ref(attribute='toTool', show=False), diff --git a/gen/ui/appy.js b/gen/ui/appy.js index 7577dae..928df5a 100644 --- a/gen/ui/appy.js +++ b/gen/ui/appy.js @@ -502,7 +502,7 @@ function updateRowNumber(row, rowIndex, action) { with new p_rowIndex. If p_action is 'set', p_rowIndex becomes the new index. If p_action is 'add', new index becomes: existing index + p_rowIndex. */ - var tagTypes = ['input', 'select', 'img']; + var tagTypes = ['input', 'select', 'img', 'textarea']; var currentIndex = -1; for (var i=0; i < tagTypes.length; i++) { var widgets = row.getElementsByTagName(tagTypes[i]); diff --git a/gen/ui/widgets/list.pt b/gen/ui/widgets/list.pt index e435f7c..3cad885 100644 --- a/gen/ui/widgets/list.pt +++ b/gen/ui/widgets/list.pt @@ -1,5 +1,5 @@ Single row. -