[gen] Removed obsolete attribute Field.sync.
This commit is contained in:
parent
5bea4e728b
commit
b98da33d47
|
@ -55,10 +55,9 @@ class Field:
|
||||||
layout=field.layouts[layoutType];
|
layout=field.layouts[layoutType];
|
||||||
name=fieldName|field.name;
|
name=fieldName|field.name;
|
||||||
widgetName = isSearch and ('w_%s' % name) or name;
|
widgetName = isSearch and ('w_%s' % name) or name;
|
||||||
sync=field.sync[layoutType];
|
|
||||||
outerValue=value|None;
|
outerValue=value|None;
|
||||||
rawValue=not isSearch and zobj.getFieldValue(name, \
|
rawValue=not isSearch and zobj.getFieldValue(name, \
|
||||||
onlyIfSync=True, layoutType=layoutType, outerValue=outerValue);
|
layoutType=layoutType, outerValue=outerValue);
|
||||||
value=not isSearch and \
|
value=not isSearch and \
|
||||||
field.getFormattedValue(zobj, rawValue, showChanges);
|
field.getFormattedValue(zobj, rawValue, showChanges);
|
||||||
requestValue=not isSearch and zobj.getRequestFieldValue(name);
|
requestValue=not isSearch and zobj.getRequestFieldValue(name);
|
||||||
|
@ -108,7 +107,7 @@ class Field:
|
||||||
def __init__(self, validator, multiplicity, default, show, page, group,
|
def __init__(self, validator, multiplicity, default, show, page, group,
|
||||||
layouts, move, indexed, searchable, specificReadPermission,
|
layouts, move, indexed, searchable, specificReadPermission,
|
||||||
specificWritePermission, width, height, maxChars, colspan,
|
specificWritePermission, width, height, maxChars, colspan,
|
||||||
master, masterValue, focus, historized, sync, mapping, label,
|
master, masterValue, focus, historized, mapping, label,
|
||||||
sdefault, scolspan, swidth, sheight, persist):
|
sdefault, scolspan, swidth, sheight, persist):
|
||||||
# The validator restricts which values may be defined. It can be an
|
# The validator restricts which values may be defined. It can be an
|
||||||
# interval (1,None), a list of string values ['choice1', 'choice2'],
|
# interval (1,None), a list of string values ['choice1', 'choice2'],
|
||||||
|
@ -185,9 +184,6 @@ class Field:
|
||||||
# If we must keep track of changes performed on a field, "historized"
|
# If we must keep track of changes performed on a field, "historized"
|
||||||
# must be set to True.
|
# must be set to True.
|
||||||
self.historized = historized
|
self.historized = historized
|
||||||
# self.sync below determines if the field representations will be
|
|
||||||
# retrieved in a synchronous way by the browser or not (Ajax).
|
|
||||||
self.sync = self.formatSync(sync)
|
|
||||||
# Mapping is a dict of contexts that, if specified, are given when
|
# Mapping is a dict of contexts that, if specified, are given when
|
||||||
# translating the label, descr or help related to this field.
|
# translating the label, descr or help related to this field.
|
||||||
self.mapping = self.formatMapping(mapping)
|
self.mapping = self.formatMapping(mapping)
|
||||||
|
@ -344,16 +340,6 @@ class Field:
|
||||||
for r in reqValue:
|
for r in reqValue:
|
||||||
if m == r: return True
|
if m == r: return True
|
||||||
|
|
||||||
def formatSync(self, sync):
|
|
||||||
'''Creates a dictionary indicating, for every layout type, if the field
|
|
||||||
value must be retrieved synchronously or not.'''
|
|
||||||
if isinstance(sync, bool):
|
|
||||||
sync = {'edit': sync, 'view': sync, 'cell': sync, 'search': sync}
|
|
||||||
for layoutType in ('edit', 'view', 'search', 'cell'):
|
|
||||||
if layoutType not in sync:
|
|
||||||
sync[layoutType] = False
|
|
||||||
return sync
|
|
||||||
|
|
||||||
def formatMapping(self, mapping):
|
def formatMapping(self, mapping):
|
||||||
'''Creates a dict of mappings, one entry by label type (label, descr,
|
'''Creates a dict of mappings, one entry by label type (label, descr,
|
||||||
help).'''
|
help).'''
|
||||||
|
|
|
@ -73,8 +73,8 @@ class Action(Field):
|
||||||
Field.__init__(self, None, (0,1), default, show, page, group, layouts,
|
Field.__init__(self, None, (0,1), default, show, page, group, layouts,
|
||||||
move, indexed, False, specificReadPermission,
|
move, indexed, False, specificReadPermission,
|
||||||
specificWritePermission, width, height, None, colspan,
|
specificWritePermission, width, height, None, colspan,
|
||||||
master, masterValue, focus, historized, False, mapping,
|
master, masterValue, focus, historized, mapping, label,
|
||||||
label, None, None, None, None, False)
|
None, None, None, None, False)
|
||||||
self.validable = False
|
self.validable = False
|
||||||
|
|
||||||
def getDefaultLayouts(self): return {'view': 'l-f', 'edit': 'lrv-f'}
|
def getDefaultLayouts(self): return {'view': 'l-f', 'edit': 'lrv-f'}
|
||||||
|
|
|
@ -65,8 +65,8 @@ class Boolean(Field):
|
||||||
group, layouts, move, indexed, searchable,
|
group, layouts, move, indexed, searchable,
|
||||||
specificReadPermission, specificWritePermission, width,
|
specificReadPermission, specificWritePermission, width,
|
||||||
height, None, colspan, master, masterValue, focus,
|
height, None, colspan, master, masterValue, focus,
|
||||||
historized, True, mapping, label, sdefault, scolspan,
|
historized, mapping, label, sdefault, scolspan, swidth,
|
||||||
swidth, sheight, persist)
|
sheight, persist)
|
||||||
self.pythonType = bool
|
self.pythonType = bool
|
||||||
|
|
||||||
# Layout including a description
|
# Layout including a description
|
||||||
|
|
|
@ -221,8 +221,8 @@ class Calendar(Field):
|
||||||
Field.__init__(self, validator, (0,1), default, show, page, group,
|
Field.__init__(self, validator, (0,1), default, show, page, group,
|
||||||
layouts, move, False, False, specificReadPermission,
|
layouts, move, False, False, specificReadPermission,
|
||||||
specificWritePermission, width, height, None, colspan,
|
specificWritePermission, width, height, None, colspan,
|
||||||
master, masterValue, focus, False, True, mapping, label,
|
master, masterValue, focus, False, mapping, label, None,
|
||||||
None, None, None, None, True)
|
None, None, None, True)
|
||||||
# eventTypes can be a "static" list or tuple of strings that identify
|
# eventTypes can be a "static" list or tuple of strings that identify
|
||||||
# the types of events that are supported by this calendar. It can also
|
# the types of events that are supported by this calendar. It can also
|
||||||
# be a method that computes such a "dynamic" list or tuple. When
|
# be a method that computes such a "dynamic" list or tuple. When
|
||||||
|
|
|
@ -22,21 +22,8 @@ from appy.px import Px
|
||||||
class Computed(Field):
|
class Computed(Field):
|
||||||
WRONG_METHOD = 'Wrong value "%s". Param "method" must contain a method ' \
|
WRONG_METHOD = 'Wrong value "%s". Param "method" must contain a method ' \
|
||||||
'or a PX.'
|
'or a PX.'
|
||||||
|
pxView = pxCell = pxEdit = Px('''<x if="field.plainText">:value</x>
|
||||||
# Ajax-called view content of a non sync Computed field.
|
<x if="not field.plainText">::value</x>''')
|
||||||
pxViewContent = Px('''
|
|
||||||
<x var="value=zobj.getFieldValue(name); sync=True">:field.pxView</x>''')
|
|
||||||
|
|
||||||
pxView = pxCell = pxEdit = Px('''<x>
|
|
||||||
<x if="sync">
|
|
||||||
<x if="field.plainText">:value</x><x if="not field.plainText">::value</x>
|
|
||||||
</x>
|
|
||||||
<div if="not sync" var2="ajaxHookId=zobj.UID() + name" id="ajaxHookId">
|
|
||||||
<script type="text/javascript">:'askComputedField(%s, %s, %s)' % \
|
|
||||||
(q(ajaxHookId), q(zobj.absolute_url()), q(name))">
|
|
||||||
</script>
|
|
||||||
</div>
|
|
||||||
</x>''')
|
|
||||||
|
|
||||||
pxSearch = Px('''
|
pxSearch = Px('''
|
||||||
<input type="text" name=":'%s*string' % name" maxlength=":field.maxChars"
|
<input type="text" name=":'%s*string' % name" maxlength=":field.maxChars"
|
||||||
|
@ -48,9 +35,8 @@ class Computed(Field):
|
||||||
specificReadPermission=False, specificWritePermission=False,
|
specificReadPermission=False, specificWritePermission=False,
|
||||||
width=None, height=None, maxChars=None, colspan=1, method=None,
|
width=None, height=None, maxChars=None, colspan=1, method=None,
|
||||||
plainText=False, master=None, masterValue=None, focus=False,
|
plainText=False, master=None, masterValue=None, focus=False,
|
||||||
historized=False, sync=True, mapping=None, label=None,
|
historized=False, mapping=None, label=None, sdefault='',
|
||||||
sdefault='', scolspan=1, swidth=None, sheight=None,
|
scolspan=1, swidth=None, sheight=None, context=None):
|
||||||
context=None):
|
|
||||||
# The Python method used for computing the field value, or a PX.
|
# The Python method used for computing the field value, or a PX.
|
||||||
self.method = method
|
self.method = method
|
||||||
if isinstance(self.method, basestring):
|
if isinstance(self.method, basestring):
|
||||||
|
@ -67,8 +53,8 @@ class Computed(Field):
|
||||||
layouts, move, indexed, searchable,
|
layouts, move, indexed, searchable,
|
||||||
specificReadPermission, specificWritePermission, width,
|
specificReadPermission, specificWritePermission, width,
|
||||||
height, None, colspan, master, masterValue, focus,
|
height, None, colspan, master, masterValue, focus,
|
||||||
historized, sync, mapping, label, sdefault, scolspan,
|
historized, mapping, label, sdefault, scolspan, swidth,
|
||||||
swidth, sheight, False)
|
sheight, False)
|
||||||
self.validable = False
|
self.validable = False
|
||||||
|
|
||||||
def getValue(self, obj):
|
def getValue(self, obj):
|
||||||
|
|
|
@ -182,8 +182,8 @@ class Date(Field):
|
||||||
group, layouts, move, indexed, searchable,
|
group, layouts, move, indexed, searchable,
|
||||||
specificReadPermission, specificWritePermission, width,
|
specificReadPermission, specificWritePermission, width,
|
||||||
height, None, colspan, master, masterValue, focus,
|
height, None, colspan, master, masterValue, focus,
|
||||||
historized, True, mapping, label, sdefault, scolspan,
|
historized, mapping, label, sdefault, scolspan, swidth,
|
||||||
swidth, sheight, persist)
|
sheight, persist)
|
||||||
|
|
||||||
def getCss(self, layoutType, res):
|
def getCss(self, layoutType, res):
|
||||||
# CSS files are only required if the calendar must be shown.
|
# CSS files are only required if the calendar must be shown.
|
||||||
|
|
|
@ -279,8 +279,8 @@ class File(Field):
|
||||||
group, layouts, move, indexed, False,
|
group, layouts, move, indexed, False,
|
||||||
specificReadPermission, specificWritePermission, width,
|
specificReadPermission, specificWritePermission, width,
|
||||||
height, None, colspan, master, masterValue, focus,
|
height, None, colspan, master, masterValue, focus,
|
||||||
historized, True, mapping, label, sdefault, scolspan,
|
historized, mapping, label, sdefault, scolspan, swidth,
|
||||||
swidth, sheight, True)
|
sheight, True)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getFileObject(filePath, fileName=None, zope=False):
|
def getFileObject(filePath, fileName=None, zope=False):
|
||||||
|
|
|
@ -77,8 +77,8 @@ class Float(Field):
|
||||||
group, layouts, move, indexed, False,
|
group, layouts, move, indexed, False,
|
||||||
specificReadPermission, specificWritePermission, width,
|
specificReadPermission, specificWritePermission, width,
|
||||||
height, maxChars, colspan, master, masterValue, focus,
|
height, maxChars, colspan, master, masterValue, focus,
|
||||||
historized, True, mapping, label, sdefault, scolspan,
|
historized, mapping, label, sdefault, scolspan, swidth,
|
||||||
swidth, sheight, persist)
|
sheight, persist)
|
||||||
self.pythonType = float
|
self.pythonType = float
|
||||||
|
|
||||||
def getFormattedValue(self, obj, value, showChanges=False):
|
def getFormattedValue(self, obj, value, showChanges=False):
|
||||||
|
|
|
@ -33,7 +33,7 @@ class Info(Field):
|
||||||
Field.__init__(self, None, (0,1), default, show, page, group, layouts,
|
Field.__init__(self, None, (0,1), default, show, page, group, layouts,
|
||||||
move, indexed, False, specificReadPermission,
|
move, indexed, False, specificReadPermission,
|
||||||
specificWritePermission, width, height, None, colspan,
|
specificWritePermission, width, height, None, colspan,
|
||||||
master, masterValue, focus, historized, False, mapping,
|
master, masterValue, focus, historized, mapping, label,
|
||||||
label, None, None, None, None, False)
|
None, None, None, None, False)
|
||||||
self.validable = False
|
self.validable = False
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
|
@ -58,8 +58,8 @@ class Integer(Field):
|
||||||
group, layouts, move, indexed, searchable,
|
group, layouts, move, indexed, searchable,
|
||||||
specificReadPermission, specificWritePermission, width,
|
specificReadPermission, specificWritePermission, width,
|
||||||
height, maxChars, colspan, master, masterValue, focus,
|
height, maxChars, colspan, master, masterValue, focus,
|
||||||
historized, True, mapping, label, sdefault, scolspan,
|
historized, mapping, label, sdefault, scolspan, swidth,
|
||||||
swidth, sheight, persist)
|
sheight, persist)
|
||||||
self.pythonType = long
|
self.pythonType = long
|
||||||
|
|
||||||
def validateValue(self, obj, value):
|
def validateValue(self, obj, value):
|
||||||
|
|
|
@ -83,8 +83,7 @@ class List(Field):
|
||||||
group, layouts, move, indexed, False,
|
group, layouts, move, indexed, False,
|
||||||
specificReadPermission, specificWritePermission, width,
|
specificReadPermission, specificWritePermission, width,
|
||||||
height, None, colspan, master, masterValue, focus,
|
height, None, colspan, master, masterValue, focus,
|
||||||
historized, True, mapping, label, None, None, None, None,
|
historized, mapping, label, None, None, None, None, True)
|
||||||
True)
|
|
||||||
self.validable = True
|
self.validable = True
|
||||||
# Tuples of (names, Field instances) determining the format of every
|
# Tuples of (names, Field instances) determining the format of every
|
||||||
# element in the list.
|
# element in the list.
|
||||||
|
|
|
@ -53,8 +53,8 @@ class Ogone(Field):
|
||||||
Field.__init__(self, None, (0,1), None, show, page, group, layouts,
|
Field.__init__(self, None, (0,1), None, show, page, group, layouts,
|
||||||
move, False, False,specificReadPermission,
|
move, False, False,specificReadPermission,
|
||||||
specificWritePermission, width, height, None, colspan,
|
specificWritePermission, width, height, None, colspan,
|
||||||
master, masterValue, focus, False, True, mapping, label,
|
master, masterValue, focus, False, mapping, label, None,
|
||||||
None, None, None, None, False)
|
None, None, None, False)
|
||||||
# orderMethod must contain a method returning a dict containing info
|
# orderMethod must contain a method returning a dict containing info
|
||||||
# about the order. Following keys are mandatory:
|
# about the order. Following keys are mandatory:
|
||||||
# * orderID An identifier for the order. Don't use the object UID
|
# * orderID An identifier for the order. Don't use the object UID
|
||||||
|
|
|
@ -83,8 +83,8 @@ class Pod(Field):
|
||||||
Field.__init__(self, None, (0,1), default, show, page, group, layouts,
|
Field.__init__(self, None, (0,1), default, show, page, group, layouts,
|
||||||
move, indexed, searchable, specificReadPermission,
|
move, indexed, searchable, specificReadPermission,
|
||||||
specificWritePermission, width, height, None, colspan,
|
specificWritePermission, width, height, None, colspan,
|
||||||
master, masterValue, focus, historized, False, mapping,
|
master, masterValue, focus, historized, mapping, label,
|
||||||
label, None, None, None, None, True)
|
None, None, None, None, True)
|
||||||
# Param "persist" is set to True but actually, persistence for a pod
|
# Param "persist" is set to True but actually, persistence for a pod
|
||||||
# field is determined by freezing.
|
# field is determined by freezing.
|
||||||
self.validable = False
|
self.validable = False
|
||||||
|
|
|
@ -398,8 +398,6 @@ class Ref(Field):
|
||||||
self.sselect = sselect or self.select
|
self.sselect = sselect or self.select
|
||||||
# Maximum number of referenced objects shown at once.
|
# Maximum number of referenced objects shown at once.
|
||||||
self.maxPerPage = maxPerPage
|
self.maxPerPage = maxPerPage
|
||||||
# Specifies sync
|
|
||||||
sync = {'view': False, 'edit':True}
|
|
||||||
# If param p_queryable is True, the user will be able to perform queries
|
# If param p_queryable is True, the user will be able to perform queries
|
||||||
# from the UI within referenced objects.
|
# from the UI within referenced objects.
|
||||||
self.queryable = queryable
|
self.queryable = queryable
|
||||||
|
@ -441,8 +439,8 @@ class Ref(Field):
|
||||||
group, layouts, move, indexed, False,
|
group, layouts, move, indexed, False,
|
||||||
specificReadPermission, specificWritePermission, width,
|
specificReadPermission, specificWritePermission, width,
|
||||||
height, None, colspan, master, masterValue, focus,
|
height, None, colspan, master, masterValue, focus,
|
||||||
historized, sync, mapping, label, sdefault, scolspan,
|
historized, mapping, label, sdefault, scolspan, swidth,
|
||||||
swidth, sheight, persist)
|
sheight, persist)
|
||||||
self.validable = self.link
|
self.validable = self.link
|
||||||
|
|
||||||
def getDefaultLayouts(self):
|
def getDefaultLayouts(self):
|
||||||
|
|
|
@ -318,8 +318,8 @@ class String(Field):
|
||||||
group, layouts, move, indexed, searchable,
|
group, layouts, move, indexed, searchable,
|
||||||
specificReadPermission, specificWritePermission, width,
|
specificReadPermission, specificWritePermission, width,
|
||||||
height, maxChars, colspan, master, masterValue, focus,
|
height, maxChars, colspan, master, masterValue, focus,
|
||||||
historized, True, mapping, label, sdefault, scolspan,
|
historized, mapping, label, sdefault, scolspan, swidth,
|
||||||
swidth, sheight, persist)
|
sheight, persist)
|
||||||
self.isSelect = self.isSelection()
|
self.isSelect = self.isSelection()
|
||||||
# If self.isSelect, self.sdefault must be a list of value(s).
|
# If self.isSelect, self.sdefault must be a list of value(s).
|
||||||
if self.isSelect and not sdefault:
|
if self.isSelect and not sdefault:
|
||||||
|
|
|
@ -215,8 +215,8 @@ class ZopeInstaller:
|
||||||
id=language, title=title)
|
id=language, title=title)
|
||||||
appyTool.log('Translation object created for "%s".' % language)
|
appyTool.log('Translation object created for "%s".' % language)
|
||||||
|
|
||||||
# Synchronize, if required, synchronise every Translation object with
|
# Synchronizes, if required, every Translation object with the
|
||||||
# the corresponding "po" file on disk.
|
# corresponding "po" file on disk.
|
||||||
if appyTool.loadTranslationsAtStartup:
|
if appyTool.loadTranslationsAtStartup:
|
||||||
appFolder = self.config.diskFolder
|
appFolder = self.config.diskFolder
|
||||||
appName = self.config.PROJECTNAME
|
appName = self.config.PROJECTNAME
|
||||||
|
|
|
@ -685,20 +685,15 @@ class BaseMixin:
|
||||||
if self.isPrincipiaFolderish: return self
|
if self.isPrincipiaFolderish: return self
|
||||||
return self.getParentNode()
|
return self.getParentNode()
|
||||||
|
|
||||||
def getFieldValue(self, name, onlyIfSync=False, layoutType=None,
|
def getFieldValue(self, name, layoutType=None, outerValue=None):
|
||||||
outerValue=None):
|
'''Returns the database value of field named p_name for p_self.'''
|
||||||
'''Returns the database value of field named p_name for p_self.
|
|
||||||
If p_onlyIfSync is True, it returns the value only if appyType can be
|
|
||||||
retrieved in synchronous mode.'''
|
|
||||||
if layoutType == 'search': return # No object in search screens.
|
if layoutType == 'search': return # No object in search screens.
|
||||||
field = self.getAppyType(name)
|
field = self.getAppyType(name)
|
||||||
if not onlyIfSync or (onlyIfSync and field.sync[layoutType]):
|
if '*' not in name: return field.getValue(self)
|
||||||
# We must really get the field value.
|
# The field is an inner field from a List.
|
||||||
if '*' not in name: return field.getValue(self)
|
listName, name, i = name.split('*')
|
||||||
# The field is an inner field from a List.
|
listType = self.getAppyType(listName)
|
||||||
listName, name, i = name.split('*')
|
return listType.getInnerValue(self, outerValue, name, int(i))
|
||||||
listType = self.getAppyType(listName)
|
|
||||||
return listType.getInnerValue(self, outerValue, name, int(i))
|
|
||||||
|
|
||||||
def getRequestFieldValue(self, name):
|
def getRequestFieldValue(self, name):
|
||||||
'''Gets the value of field p_name as may be present in the request.'''
|
'''Gets the value of field p_name as may be present in the request.'''
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Protos:
|
||||||
# List of attributes that can't be given to a Type constructor
|
# List of attributes that can't be given to a Type constructor
|
||||||
notInit = ('id', 'type', 'pythonType', 'slaves', 'isSelect', 'hasLabel',
|
notInit = ('id', 'type', 'pythonType', 'slaves', 'isSelect', 'hasLabel',
|
||||||
'hasDescr', 'hasHelp', 'required', 'filterable', 'validable',
|
'hasDescr', 'hasHelp', 'required', 'filterable', 'validable',
|
||||||
'isBack', 'sync', 'pageName', 'masterName')
|
'isBack', 'pageName', 'masterName')
|
||||||
@classmethod
|
@classmethod
|
||||||
def get(self, appyType):
|
def get(self, appyType):
|
||||||
'''Returns a prototype instance for p_appyType.'''
|
'''Returns a prototype instance for p_appyType.'''
|
||||||
|
|
Loading…
Reference in a new issue