[gen] Performance improvements.
This commit is contained in:
parent
2f30730d3b
commit
701eae1b19
|
@ -61,32 +61,28 @@ class Page:
|
|||
res = Page(pageData[0], phase=pageData[1])
|
||||
return res
|
||||
|
||||
def isShowable(self, obj, layoutType, elem='page'):
|
||||
'''Must this page be shown for p_obj? "Show value" can be True, False
|
||||
def isShowable(self, obj, elem='page'):
|
||||
'''Must this page be shown for p_obj? The method can return True, False
|
||||
or 'view' (page is available only in "view" mode).
|
||||
|
||||
If p_elem is not "page", this method returns the fact that a
|
||||
sub-element is viewable or not (buttons "save", "cancel", etc).'''
|
||||
# Define what attribute to test for "showability".
|
||||
showAttr = 'show'
|
||||
if elem != 'page':
|
||||
showAttr = 'show%s' % elem.capitalize()
|
||||
attr = (elem == 'page') and 'show' or ('show%s' % elem.capitalize())
|
||||
# Get the value of the show attribute as identified above.
|
||||
show = getattr(self, showAttr)
|
||||
if callable(show):
|
||||
show = show(obj.appy())
|
||||
# Show value can be 'view', for example. Thanks to p_layoutType,
|
||||
# convert show value to a real final boolean value.
|
||||
res = show
|
||||
if res == 'view': res = layoutType == 'view'
|
||||
res = getattr(self, attr)
|
||||
if callable(res): res = res(obj.appy())
|
||||
return res
|
||||
|
||||
def getInfo(self, obj, layoutType):
|
||||
'''Gets information about this page, for p_obj, as an object.'''
|
||||
res = Object()
|
||||
for elem in Page.subElements:
|
||||
setattr(res, 'show%s' % elem.capitalize(), \
|
||||
self.isShowable(obj, layoutType, elem=elem))
|
||||
showable = self.isShowable(obj, elem)
|
||||
# "showable" can be True, False or "view"
|
||||
if layoutType == 'edit': showable = showable==True
|
||||
else: showable = bool(showable)
|
||||
setattr(res, 'show%s' % elem.capitalize(), showable)
|
||||
return res
|
||||
|
||||
def getLabel(self, zobj):
|
||||
|
|
|
@ -136,14 +136,13 @@ class Phase:
|
|||
if (field.page.name in self.pages) or \
|
||||
(field.page.name in self.hiddenPages): return
|
||||
# Add the page only if it must be shown.
|
||||
isShowableOnView = field.page.isShowable(obj, 'view')
|
||||
isShowableOnEdit = field.page.isShowable(obj, 'edit')
|
||||
if isShowableOnView or isShowableOnEdit:
|
||||
# The page must be added.
|
||||
showable = field.page.isShowable(obj)
|
||||
if showable:
|
||||
# The page must be added
|
||||
self.pages.append(field.page.name)
|
||||
# Create the dict about page information and add it in self.pageInfo
|
||||
pageInfo = Object(page=field.page, showOnView=isShowableOnView,
|
||||
showOnEdit=isShowableOnEdit, links=None)
|
||||
pageInfo = Object(page=field.page, showOnView=bool(showable),
|
||||
showOnEdit=showable==True, links=None)
|
||||
pageInfo.update(field.page.getInfo(obj, layoutType))
|
||||
self.pagesInfo[field.page.name] = pageInfo
|
||||
else:
|
||||
|
|
|
@ -25,7 +25,7 @@ msgstr "Kommentar"
|
|||
|
||||
#. Default: "Manager"
|
||||
msgid "role_Manager"
|
||||
msgstr ""
|
||||
msgstr "Systemmanager"
|
||||
|
||||
#. Default: "Anonymous"
|
||||
msgid "role_Anonymous"
|
||||
|
@ -37,7 +37,7 @@ msgstr ""
|
|||
|
||||
#. Default: "Owner"
|
||||
msgid "role_Owner"
|
||||
msgstr ""
|
||||
msgstr "Eigentümer"
|
||||
|
||||
#. Default: "Title"
|
||||
msgid "appy_title"
|
||||
|
@ -45,7 +45,7 @@ msgstr "Titel"
|
|||
|
||||
#. Default: "Ok"
|
||||
msgid "appy_ok"
|
||||
msgstr ""
|
||||
msgstr "OK"
|
||||
|
||||
#. Default: "Data change"
|
||||
msgid "data_change"
|
||||
|
|
|
@ -37,7 +37,7 @@ msgstr ""
|
|||
|
||||
#. Default: "Owner"
|
||||
msgid "role_Owner"
|
||||
msgstr ""
|
||||
msgstr "Proprietario"
|
||||
|
||||
#. Default: "Title"
|
||||
msgid "appy_title"
|
||||
|
|
|
@ -70,8 +70,8 @@ class AbstractWrapper(object):
|
|||
</tr>
|
||||
</table>
|
||||
<!-- Object phases and pages -->
|
||||
<x var="phases=zobj.getAppyPhases()"
|
||||
if="phases and zobj.mayNavigate()">:phases[0].pxAllPhases</x>''')
|
||||
<x if="zobj.mayNavigate()" var2="phases=zobj.getAppyPhases()">
|
||||
<x if="phases">:phases[0].pxAllPhases</x></x>''')
|
||||
|
||||
# The template PX for all pages.
|
||||
pxTemplate = Px('''
|
||||
|
|
Loading…
Reference in a new issue