Bugfixes while dumping and converting a file from database to disk; bugfix and minor improvement in layouts.
This commit is contained in:
parent
502c86dab8
commit
0e83a6f490
|
@ -576,10 +576,7 @@ class Type:
|
||||||
if not layouts:
|
if not layouts:
|
||||||
# Get the default layouts as defined by the subclass
|
# Get the default layouts as defined by the subclass
|
||||||
areDefault = True
|
areDefault = True
|
||||||
layouts = self.getDefaultLayouts()
|
layouts = self.computeDefaultLayouts()
|
||||||
if not layouts:
|
|
||||||
# Get the global default layouts
|
|
||||||
layouts = copy.deepcopy(defaultFieldLayouts)
|
|
||||||
else:
|
else:
|
||||||
if isinstance(layouts, basestring):
|
if isinstance(layouts, basestring):
|
||||||
# The user specified a single layoutString (the "edit" one)
|
# The user specified a single layoutString (the "edit" one)
|
||||||
|
@ -588,19 +585,24 @@ class Type:
|
||||||
# Idem, but with a Table instance
|
# Idem, but with a Table instance
|
||||||
layouts = {'edit': Table(other=layouts)}
|
layouts = {'edit': Table(other=layouts)}
|
||||||
else:
|
else:
|
||||||
layouts = copy.deepcopy(layouts)
|
|
||||||
# Here, we make a copy of the layouts, because every layout can
|
# Here, we make a copy of the layouts, because every layout can
|
||||||
# be different, even if the user decides to reuse one from one
|
# be different, even if the user decides to reuse one from one
|
||||||
# field to another. This is because we modify every layout for
|
# field to another. This is because we modify every layout for
|
||||||
# adding master/slave-related info, focus-related info, etc,
|
# adding master/slave-related info, focus-related info, etc,
|
||||||
# which can be different from one field to the other.
|
# which can be different from one field to the other.
|
||||||
|
layouts = copy.deepcopy(layouts)
|
||||||
|
if 'edit' not in layouts:
|
||||||
|
defEditLayout = self.computeDefaultLayouts()
|
||||||
|
if type(defEditLayout) == dict:
|
||||||
|
defEditLayout = defEditLayout['edit']
|
||||||
|
layouts['edit'] = defEditLayout
|
||||||
# We have now a dict of layouts in p_layouts. Ensure now that a Table
|
# We have now a dict of layouts in p_layouts. Ensure now that a Table
|
||||||
# instance is created for every layout (=value from the dict). Indeed,
|
# instance is created for every layout (=value from the dict). Indeed,
|
||||||
# a layout could have been expressed as a simple layout string.
|
# a layout could have been expressed as a simple layout string.
|
||||||
for layoutType in layouts.iterkeys():
|
for layoutType in layouts.iterkeys():
|
||||||
if isinstance(layouts[layoutType], basestring):
|
if isinstance(layouts[layoutType], basestring):
|
||||||
layouts[layoutType] = Table(layouts[layoutType])
|
layouts[layoutType] = Table(layouts[layoutType])
|
||||||
# Create the "view" layout from the "edit" layout if not specified
|
# Derive "view" and "cell" layouts from the "edit" layout when relevant
|
||||||
if 'view' not in layouts:
|
if 'view' not in layouts:
|
||||||
layouts['view'] = Table(other=layouts['edit'], derivedType='view')
|
layouts['view'] = Table(other=layouts['edit'], derivedType='view')
|
||||||
# Create the "cell" layout from the 'view' layout if not specified.
|
# Create the "cell" layout from the 'view' layout if not specified.
|
||||||
|
@ -656,6 +658,15 @@ class Type:
|
||||||
default layouts. If None is returned, a global set of default layouts
|
default layouts. If None is returned, a global set of default layouts
|
||||||
will be used.'''
|
will be used.'''
|
||||||
|
|
||||||
|
def computeDefaultLayouts(self):
|
||||||
|
'''This method gets the default layouts from an Appy type, or a copy
|
||||||
|
from the global default field layouts when they are not available.'''
|
||||||
|
res = self.getDefaultLayouts()
|
||||||
|
if not res:
|
||||||
|
# Get the global default layouts
|
||||||
|
res = copy.deepcopy(defaultFieldLayouts)
|
||||||
|
return res
|
||||||
|
|
||||||
def getCss(self, layoutType):
|
def getCss(self, layoutType):
|
||||||
'''This method returns a list of CSS files that are required for
|
'''This method returns a list of CSS files that are required for
|
||||||
displaying widgets of self's type on a given p_layoutType.'''
|
displaying widgets of self's type on a given p_layoutType.'''
|
||||||
|
|
|
@ -123,7 +123,7 @@ class Table(LayoutElement):
|
||||||
'''Represents a table where to dispose graphical elements.'''
|
'''Represents a table where to dispose graphical elements.'''
|
||||||
simpleParams = ('style', 'css_class', 'cellpadding', 'cellspacing', 'width',
|
simpleParams = ('style', 'css_class', 'cellpadding', 'cellspacing', 'width',
|
||||||
'align')
|
'align')
|
||||||
derivedRepls = {'view': 'hrv', 'cell': 'ld'}
|
derivedRepls = {'view': 'hrvd', 'cell': 'ld'}
|
||||||
def __init__(self, layoutString=None, style=None, css_class='',
|
def __init__(self, layoutString=None, style=None, css_class='',
|
||||||
cellpadding=0, cellspacing=0, width='100%', align='left',
|
cellpadding=0, cellspacing=0, width='100%', align='left',
|
||||||
other=None, derivedType=None):
|
other=None, derivedType=None):
|
||||||
|
|
|
@ -35,7 +35,8 @@
|
||||||
size python: isMultiple and widget['height'] or 1">
|
size python: isMultiple and widget['height'] or 1">
|
||||||
<option tal:repeat="possibleValue possibleValues"
|
<option tal:repeat="possibleValue possibleValues"
|
||||||
tal:attributes="value python: possibleValue[0];
|
tal:attributes="value python: possibleValue[0];
|
||||||
selected python:contextObj.fieldValueSelected(name, possibleValue[0], rawValue)"
|
selected python:contextObj.fieldValueSelected(name, possibleValue[0], rawValue);
|
||||||
|
title python: possibleValue[1]"
|
||||||
tal:content="python:tool.truncateValue(possibleValue[1], widget)"></option>
|
tal:content="python:tool.truncateValue(possibleValue[1], widget)"></option>
|
||||||
</select>
|
</select>
|
||||||
</tal:choice>
|
</tal:choice>
|
||||||
|
@ -100,7 +101,8 @@
|
||||||
<tal:comment replace="nothing">The list of values</tal:comment>
|
<tal:comment replace="nothing">The list of values</tal:comment>
|
||||||
<select tal:attributes="name widgetName" multiple="multiple" size="5">
|
<select tal:attributes="name widgetName" multiple="multiple" size="5">
|
||||||
<option tal:repeat="v python:tool.getPossibleValues(name, withTranslations=True, withBlankValue=False, className=contentType)"
|
<option tal:repeat="v python:tool.getPossibleValues(name, withTranslations=True, withBlankValue=False, className=contentType)"
|
||||||
tal:attributes="value python:v[0]" tal:content="python: tool.truncateValue(v[1], widget)">
|
tal:attributes="value python:v[0]; title python: v[1]"
|
||||||
|
tal:content="python: tool.truncateValue(v[1], widget)">
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
</tal:selectSearch><br/>
|
</tal:selectSearch><br/>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
import re, os, os.path, time
|
import re, os, os.path, time
|
||||||
from appy.shared.utils import getOsTempFolder, normalizeString
|
import appy.pod
|
||||||
|
from appy.shared.utils import getOsTempFolder, normalizeString, executeCommand
|
||||||
sequenceTypes = (list, tuple)
|
sequenceTypes = (list, tuple)
|
||||||
|
|
||||||
# Classes used by edit/view templates for accessing information ----------------
|
# Classes used by edit/view templates for accessing information ----------------
|
||||||
|
|
Loading…
Reference in a new issue