[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];
|
||||
name=fieldName|field.name;
|
||||
widgetName = isSearch and ('w_%s' % name) or name;
|
||||
sync=field.sync[layoutType];
|
||||
outerValue=value|None;
|
||||
rawValue=not isSearch and zobj.getFieldValue(name, \
|
||||
onlyIfSync=True, layoutType=layoutType, outerValue=outerValue);
|
||||
layoutType=layoutType, outerValue=outerValue);
|
||||
value=not isSearch and \
|
||||
field.getFormattedValue(zobj, rawValue, showChanges);
|
||||
requestValue=not isSearch and zobj.getRequestFieldValue(name);
|
||||
|
@ -108,7 +107,7 @@ class Field:
|
|||
def __init__(self, validator, multiplicity, default, show, page, group,
|
||||
layouts, move, indexed, searchable, specificReadPermission,
|
||||
specificWritePermission, width, height, maxChars, colspan,
|
||||
master, masterValue, focus, historized, sync, mapping, label,
|
||||
master, masterValue, focus, historized, mapping, label,
|
||||
sdefault, scolspan, swidth, sheight, persist):
|
||||
# The validator restricts which values may be defined. It can be an
|
||||
# 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"
|
||||
# must be set to True.
|
||||
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
|
||||
# translating the label, descr or help related to this field.
|
||||
self.mapping = self.formatMapping(mapping)
|
||||
|
@ -344,16 +340,6 @@ class Field:
|
|||
for r in reqValue:
|
||||
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):
|
||||
'''Creates a dict of mappings, one entry by label type (label, descr,
|
||||
help).'''
|
||||
|
|
|
@ -73,8 +73,8 @@ class Action(Field):
|
|||
Field.__init__(self, None, (0,1), default, show, page, group, layouts,
|
||||
move, indexed, False, specificReadPermission,
|
||||
specificWritePermission, width, height, None, colspan,
|
||||
master, masterValue, focus, historized, False, mapping,
|
||||
label, None, None, None, None, False)
|
||||
master, masterValue, focus, historized, mapping, label,
|
||||
None, None, None, None, False)
|
||||
self.validable = False
|
||||
|
||||
def getDefaultLayouts(self): return {'view': 'l-f', 'edit': 'lrv-f'}
|
||||
|
|
|
@ -65,8 +65,8 @@ class Boolean(Field):
|
|||
group, layouts, move, indexed, searchable,
|
||||
specificReadPermission, specificWritePermission, width,
|
||||
height, None, colspan, master, masterValue, focus,
|
||||
historized, True, mapping, label, sdefault, scolspan,
|
||||
swidth, sheight, persist)
|
||||
historized, mapping, label, sdefault, scolspan, swidth,
|
||||
sheight, persist)
|
||||
self.pythonType = bool
|
||||
|
||||
# Layout including a description
|
||||
|
|
|
@ -221,8 +221,8 @@ class Calendar(Field):
|
|||
Field.__init__(self, validator, (0,1), default, show, page, group,
|
||||
layouts, move, False, False, specificReadPermission,
|
||||
specificWritePermission, width, height, None, colspan,
|
||||
master, masterValue, focus, False, True, mapping, label,
|
||||
None, None, None, None, True)
|
||||
master, masterValue, focus, False, mapping, label, None,
|
||||
None, None, None, True)
|
||||
# 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
|
||||
# be a method that computes such a "dynamic" list or tuple. When
|
||||
|
|
|
@ -22,21 +22,8 @@ from appy.px import Px
|
|||
class Computed(Field):
|
||||
WRONG_METHOD = 'Wrong value "%s". Param "method" must contain a method ' \
|
||||
'or a PX.'
|
||||
|
||||
# Ajax-called view content of a non sync Computed field.
|
||||
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>''')
|
||||
pxView = pxCell = pxEdit = Px('''<x if="field.plainText">:value</x>
|
||||
<x if="not field.plainText">::value</x>''')
|
||||
|
||||
pxSearch = Px('''
|
||||
<input type="text" name=":'%s*string' % name" maxlength=":field.maxChars"
|
||||
|
@ -48,9 +35,8 @@ class Computed(Field):
|
|||
specificReadPermission=False, specificWritePermission=False,
|
||||
width=None, height=None, maxChars=None, colspan=1, method=None,
|
||||
plainText=False, master=None, masterValue=None, focus=False,
|
||||
historized=False, sync=True, mapping=None, label=None,
|
||||
sdefault='', scolspan=1, swidth=None, sheight=None,
|
||||
context=None):
|
||||
historized=False, mapping=None, label=None, sdefault='',
|
||||
scolspan=1, swidth=None, sheight=None, context=None):
|
||||
# The Python method used for computing the field value, or a PX.
|
||||
self.method = method
|
||||
if isinstance(self.method, basestring):
|
||||
|
@ -67,8 +53,8 @@ class Computed(Field):
|
|||
layouts, move, indexed, searchable,
|
||||
specificReadPermission, specificWritePermission, width,
|
||||
height, None, colspan, master, masterValue, focus,
|
||||
historized, sync, mapping, label, sdefault, scolspan,
|
||||
swidth, sheight, False)
|
||||
historized, mapping, label, sdefault, scolspan, swidth,
|
||||
sheight, False)
|
||||
self.validable = False
|
||||
|
||||
def getValue(self, obj):
|
||||
|
|
|
@ -182,8 +182,8 @@ class Date(Field):
|
|||
group, layouts, move, indexed, searchable,
|
||||
specificReadPermission, specificWritePermission, width,
|
||||
height, None, colspan, master, masterValue, focus,
|
||||
historized, True, mapping, label, sdefault, scolspan,
|
||||
swidth, sheight, persist)
|
||||
historized, mapping, label, sdefault, scolspan, swidth,
|
||||
sheight, persist)
|
||||
|
||||
def getCss(self, layoutType, res):
|
||||
# CSS files are only required if the calendar must be shown.
|
||||
|
|
|
@ -279,8 +279,8 @@ class File(Field):
|
|||
group, layouts, move, indexed, False,
|
||||
specificReadPermission, specificWritePermission, width,
|
||||
height, None, colspan, master, masterValue, focus,
|
||||
historized, True, mapping, label, sdefault, scolspan,
|
||||
swidth, sheight, True)
|
||||
historized, mapping, label, sdefault, scolspan, swidth,
|
||||
sheight, True)
|
||||
|
||||
@staticmethod
|
||||
def getFileObject(filePath, fileName=None, zope=False):
|
||||
|
|
|
@ -77,8 +77,8 @@ class Float(Field):
|
|||
group, layouts, move, indexed, False,
|
||||
specificReadPermission, specificWritePermission, width,
|
||||
height, maxChars, colspan, master, masterValue, focus,
|
||||
historized, True, mapping, label, sdefault, scolspan,
|
||||
swidth, sheight, persist)
|
||||
historized, mapping, label, sdefault, scolspan, swidth,
|
||||
sheight, persist)
|
||||
self.pythonType = float
|
||||
|
||||
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,
|
||||
move, indexed, False, specificReadPermission,
|
||||
specificWritePermission, width, height, None, colspan,
|
||||
master, masterValue, focus, historized, False, mapping,
|
||||
label, None, None, None, None, False)
|
||||
master, masterValue, focus, historized, mapping, label,
|
||||
None, None, None, None, False)
|
||||
self.validable = False
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
@ -58,8 +58,8 @@ class Integer(Field):
|
|||
group, layouts, move, indexed, searchable,
|
||||
specificReadPermission, specificWritePermission, width,
|
||||
height, maxChars, colspan, master, masterValue, focus,
|
||||
historized, True, mapping, label, sdefault, scolspan,
|
||||
swidth, sheight, persist)
|
||||
historized, mapping, label, sdefault, scolspan, swidth,
|
||||
sheight, persist)
|
||||
self.pythonType = long
|
||||
|
||||
def validateValue(self, obj, value):
|
||||
|
|
|
@ -83,8 +83,7 @@ class List(Field):
|
|||
group, layouts, move, indexed, False,
|
||||
specificReadPermission, specificWritePermission, width,
|
||||
height, None, colspan, master, masterValue, focus,
|
||||
historized, True, mapping, label, None, None, None, None,
|
||||
True)
|
||||
historized, mapping, label, None, None, None, None, True)
|
||||
self.validable = True
|
||||
# Tuples of (names, Field instances) determining the format of every
|
||||
# element in the list.
|
||||
|
|
|
@ -53,8 +53,8 @@ class Ogone(Field):
|
|||
Field.__init__(self, None, (0,1), None, show, page, group, layouts,
|
||||
move, False, False,specificReadPermission,
|
||||
specificWritePermission, width, height, None, colspan,
|
||||
master, masterValue, focus, False, True, mapping, label,
|
||||
None, None, None, None, False)
|
||||
master, masterValue, focus, False, mapping, label, None,
|
||||
None, None, None, False)
|
||||
# orderMethod must contain a method returning a dict containing info
|
||||
# about the order. Following keys are mandatory:
|
||||
# * 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,
|
||||
move, indexed, searchable, specificReadPermission,
|
||||
specificWritePermission, width, height, None, colspan,
|
||||
master, masterValue, focus, historized, False, mapping,
|
||||
label, None, None, None, None, True)
|
||||
master, masterValue, focus, historized, mapping, label,
|
||||
None, None, None, None, True)
|
||||
# Param "persist" is set to True but actually, persistence for a pod
|
||||
# field is determined by freezing.
|
||||
self.validable = False
|
||||
|
|
|
@ -398,8 +398,6 @@ class Ref(Field):
|
|||
self.sselect = sselect or self.select
|
||||
# Maximum number of referenced objects shown at once.
|
||||
self.maxPerPage = maxPerPage
|
||||
# Specifies sync
|
||||
sync = {'view': False, 'edit':True}
|
||||
# If param p_queryable is True, the user will be able to perform queries
|
||||
# from the UI within referenced objects.
|
||||
self.queryable = queryable
|
||||
|
@ -441,8 +439,8 @@ class Ref(Field):
|
|||
group, layouts, move, indexed, False,
|
||||
specificReadPermission, specificWritePermission, width,
|
||||
height, None, colspan, master, masterValue, focus,
|
||||
historized, sync, mapping, label, sdefault, scolspan,
|
||||
swidth, sheight, persist)
|
||||
historized, mapping, label, sdefault, scolspan, swidth,
|
||||
sheight, persist)
|
||||
self.validable = self.link
|
||||
|
||||
def getDefaultLayouts(self):
|
||||
|
|
|
@ -318,8 +318,8 @@ class String(Field):
|
|||
group, layouts, move, indexed, searchable,
|
||||
specificReadPermission, specificWritePermission, width,
|
||||
height, maxChars, colspan, master, masterValue, focus,
|
||||
historized, True, mapping, label, sdefault, scolspan,
|
||||
swidth, sheight, persist)
|
||||
historized, mapping, label, sdefault, scolspan, swidth,
|
||||
sheight, persist)
|
||||
self.isSelect = self.isSelection()
|
||||
# If self.isSelect, self.sdefault must be a list of value(s).
|
||||
if self.isSelect and not sdefault:
|
||||
|
|
|
@ -215,8 +215,8 @@ class ZopeInstaller:
|
|||
id=language, title=title)
|
||||
appyTool.log('Translation object created for "%s".' % language)
|
||||
|
||||
# Synchronize, if required, synchronise every Translation object with
|
||||
# the corresponding "po" file on disk.
|
||||
# Synchronizes, if required, every Translation object with the
|
||||
# corresponding "po" file on disk.
|
||||
if appyTool.loadTranslationsAtStartup:
|
||||
appFolder = self.config.diskFolder
|
||||
appName = self.config.PROJECTNAME
|
||||
|
|
|
@ -685,20 +685,15 @@ class BaseMixin:
|
|||
if self.isPrincipiaFolderish: return self
|
||||
return self.getParentNode()
|
||||
|
||||
def getFieldValue(self, name, onlyIfSync=False, layoutType=None,
|
||||
outerValue=None):
|
||||
'''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.'''
|
||||
def getFieldValue(self, name, layoutType=None, outerValue=None):
|
||||
'''Returns the database value of field named p_name for p_self.'''
|
||||
if layoutType == 'search': return # No object in search screens.
|
||||
field = self.getAppyType(name)
|
||||
if not onlyIfSync or (onlyIfSync and field.sync[layoutType]):
|
||||
# We must really get the field value.
|
||||
if '*' not in name: return field.getValue(self)
|
||||
# The field is an inner field from a List.
|
||||
listName, name, i = name.split('*')
|
||||
listType = self.getAppyType(listName)
|
||||
return listType.getInnerValue(self, outerValue, name, int(i))
|
||||
if '*' not in name: return field.getValue(self)
|
||||
# The field is an inner field from a List.
|
||||
listName, name, i = name.split('*')
|
||||
listType = self.getAppyType(listName)
|
||||
return listType.getInnerValue(self, outerValue, name, int(i))
|
||||
|
||||
def getRequestFieldValue(self, name):
|
||||
'''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
|
||||
notInit = ('id', 'type', 'pythonType', 'slaves', 'isSelect', 'hasLabel',
|
||||
'hasDescr', 'hasHelp', 'required', 'filterable', 'validable',
|
||||
'isBack', 'sync', 'pageName', 'masterName')
|
||||
'isBack', 'pageName', 'masterName')
|
||||
@classmethod
|
||||
def get(self, appyType):
|
||||
'''Returns a prototype instance for p_appyType.'''
|
||||
|
|
Loading…
Reference in a new issue