[gen] Added field dict, similar to List but that stores dicts in the database, with a set of keys given in method field.keys.

This commit is contained in:
Gaetan Delannay 2015-03-16 12:08:13 +01:00
parent 424c0521de
commit 7e7d0933f5
7 changed files with 117 additions and 14 deletions

View file

@ -29,6 +29,7 @@ from appy.fields.float import Float
from appy.fields.info import Info
from appy.fields.integer import Integer
from appy.fields.list import List
from appy.fields.dict import Dict
from appy.fields.pod import Pod
from appy.fields.ref import Ref, autoref
from appy.fields.string import String, Selection

View file

@ -319,6 +319,7 @@ class FieldDescriptor:
self.i18n('%s_descr' % label, ' ')
if field.hasHelp:
self.i18n('%s_help' % label, ' ')
walkDict = walkList # Same i18n labels for a dict
def walkCalendar(self):
# Add i18n-specific messages

View file

@ -256,12 +256,12 @@ class BaseMixin:
return dbFolder, path
def view(self):
'''Returns the view PX.'''
'''Returns the view PX'''
obj = self.appy()
return obj.pxView({'obj': obj, 'tool': obj.tool})
def edit(self):
'''Returns the edit PX.'''
'''Returns the edit PX'''
obj = self.appy()
return obj.pxEdit({'obj': obj, 'tool': obj.tool})
@ -347,8 +347,8 @@ class BaseMixin:
setattr(errors, field.name, message)
else:
setattr(values, field.name, field.getStorableValue(self, value))
# Validate sub-fields within Lists
if field.type != 'List': continue
# Validate sub-fields within Lists/Dicts
if field.type not in ('List', 'Dict'): continue
i = -1
for row in value:
i += 1
@ -710,7 +710,7 @@ class BaseMixin:
field = self.getAppyType(name)
if field.type == 'Pod': return
if '*' not in name: return field.getValue(self)
# The field is an inner field from a List.
# The field is an inner field from a List/Dict
listName, name, i = name.split('*')
listType = self.getAppyType(listName)
return listType.getInnerValue(self, outerValue, name, int(i))

View file

@ -124,7 +124,7 @@ td.search { padding-top: 8px }
.compact th, .compact td { padding: 0px 3px 0px 3px }
.grid th { font-style: italic; font-weight: normal;
border-bottom: 5px solid #fdfdfd; padding: 3px 5px 0 5px }
.grid td { padding: 3px 3px 0 3px }
.grid td { padding: 0 3px }
.timeline { font-size: 85%; color: #555555 }
.timeline td { text-align: center; padding: 1px }
.timeline th { padding: 1px }