Commit 24686d50 authored by Aurel's avatar Aurel

use getChildDomainValueList to generate domains tree

get domains based on the path are they are now temporary and
dynamically generated
comment computation of time to render listbox as it is just overhead


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@5796 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a0a28f5f
...@@ -147,8 +147,11 @@ def makeTreeBody(form = None, root_dict = None, domain_path = '', ...@@ -147,8 +147,11 @@ def makeTreeBody(form = None, root_dict = None, domain_path = '',
#LOG('makeTreeBody', 0, 'root = %r, depth = %r, category = %r' % (root, depth, category)) #LOG('makeTreeBody', 0, 'root = %r, depth = %r, category = %r' % (root, depth, category))
tree_body = '' tree_body = ''
if root is None: return tree_body if root is None: return tree_body
if hasattr(root, 'getChildDomainValueList'):
for o in root.objectValues(): oblist = root.getChildDomainValueList(root)
else:
oblist = root.objectValues()
for o in oblist:
tree_body += '<TR>' + '<TD WIDTH="16" NOWRAP>' * depth tree_body += '<TR>' + '<TD WIDTH="16" NOWRAP>' * depth
relative_url = o.getRelativeUrl() relative_url = o.getRelativeUrl()
if base_category is not None and not relative_url.startswith(base_category + '/'): if base_category is not None and not relative_url.startswith(base_category + '/'):
...@@ -247,7 +250,11 @@ def makeTreeList(here, form, root_dict, report_path, base_category, depth, unfol ...@@ -247,7 +250,11 @@ def makeTreeList(here, form, root_dict, report_path, base_category, depth, unfol
else: else:
tree_list += [(o, 1, depth, 0, selection_domain, ())] # Summary (closed) tree_list += [(o, 1, depth, 0, selection_domain, ())] # Summary (closed)
else: else:
for o in root.objectValues(): if hasattr(root, 'getChildDomainValueList'):
oblist = root.getChildDomainValueList(root)
else:
oblist = root.objectValues()
for o in oblist:
new_root_dict = root_dict.copy() new_root_dict = root_dict.copy()
new_root_dict[None] = new_root_dict[base_category] = o new_root_dict[None] = new_root_dict[base_category] = o
selection_domain = DomainSelection(domain_dict = new_root_dict) selection_domain = DomainSelection(domain_dict = new_root_dict)
...@@ -487,7 +494,7 @@ class ListBoxWidget(Widget.Widget): ...@@ -487,7 +494,7 @@ class ListBoxWidget(Widget.Widget):
""" """
Returns Returns
""" """
if REQUEST is None: REQUEST=get_request() if REQUEST is None: REQUEST=get_request()
return self.render(field, key, value, REQUEST, render_format=render_format) return self.render(field, key, value, REQUEST, render_format=render_format)
def render(self, field, key, value, REQUEST, render_format='html'): def render(self, field, key, value, REQUEST, render_format='html'):
...@@ -518,7 +525,7 @@ class ListBoxWidget(Widget.Widget): ...@@ -518,7 +525,7 @@ class ListBoxWidget(Widget.Widget):
# First, grasp and intialize the variables we may need later # First, grasp and intialize the variables we may need later
# #
############################################################### ###############################################################
render_start = DateTime() #render_start = DateTime()
here = REQUEST['here'] here = REQUEST['here']
reset = REQUEST.get('reset', 0) reset = REQUEST.get('reset', 0)
form = field.aq_parent form = field.aq_parent
...@@ -863,7 +870,7 @@ class ListBoxWidget(Widget.Widget): ...@@ -863,7 +870,7 @@ class ListBoxWidget(Widget.Widget):
stat_method = None stat_method = None
show_stat = 0 show_stat = 0
#LOG('ListBox', 0, 'domain_tree = %s, selection.getDomainPath() = %s, selection.getDomainList() = %s' % (repr(domain_tree), repr(selection.getDomainPath()), repr(selection.getDomainList()))) #LOG('ListBox', 0, 'domain_tree = %s, selection.getDomainPath() = %s, selection.getDomainList() = %s' % (repr(domain_tree), repr(selection.getDomainPath()), repr(selection.getDomainList())))
if domain_tree: if domain_tree:
selection_domain_path = selection.getDomainPath() selection_domain_path = selection.getDomainPath()
selection_domain_current = selection.getDomainList() selection_domain_current = selection.getDomainList()
...@@ -878,15 +885,17 @@ class ListBoxWidget(Widget.Widget): ...@@ -878,15 +885,17 @@ class ListBoxWidget(Widget.Widget):
root = root_dict[base_category] = portal_categories.restrictedTraverse(domain) root = root_dict[base_category] = portal_categories.restrictedTraverse(domain)
if root is None and portal_domains is not None: if root is None and portal_domains is not None:
if base_category in portal_domains.objectIds(): if base_category in portal_domains.objectIds():
root = root_dict[base_category] = portal_domains.restrictedTraverse(domain) base_domain = portal_domains.getDomainByPath(domain)
root = base_domain
root_dict[base_category] = base_domain.getRelativeUrl()
if root is None: if root is None:
try: try:
root_dict[None] = portal_object.restrictedTraverse(domain) root_dict[None] = portal_object.restrictedTraverse(domain)
except KeyError: except KeyError:
root = None root = None
#LOG('domain_tree root aq_parent', 0, str(root_dict[base_category].aq_parent)) #LOG('domain_tree root aq_parent', 0, str(root_dict[base_category].aq_parent))
selection.edit(domain = DomainSelection(domain_dict = root_dict)) selection.edit(domain = DomainSelection(domain_dict = root_dict).__of__(here))
#LOG('selection.domain', 0, str(selection.domain.__dict__)) # LOG('selection.domain', 0, str(selection.domain.__dict__))
else: else:
selection.edit(domain = None) selection.edit(domain = None)
...@@ -2000,7 +2009,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setDomainRoot')"> ...@@ -2000,7 +2009,7 @@ onChange="submitAction(this.form,'%s/portal_selections/setDomainRoot')">
selection_name = selection_name) selection_name = selection_name)
except KeyError: except KeyError:
select_tree_body = '' select_tree_body = ''
select_tree_html = """<!-- Select Tree --> select_tree_html = """<!-- Select Tree -->
%s %s
<table cellpadding="0" border="0"> <table cellpadding="0" border="0">
...@@ -2017,9 +2026,9 @@ onChange="submitAction(this.form,'%s/portal_selections/setDomainRoot')"> ...@@ -2017,9 +2026,9 @@ onChange="submitAction(this.form,'%s/portal_selections/setDomainRoot')">
<!-- End of Table Wrapping for Select Tree --> <!-- End of Table Wrapping for Select Tree -->
</td></tr> </td></tr>
</table>""" % (select_tree_html,list_html) </table>""" % (select_tree_html,list_html)
render_end = DateTime() #render_end = DateTime()
result = (render_end-render_start) * 86400 #result = (render_end-render_start) * 86400
LOG('Listbox render end call', 0, result) #LOG('Listbox render end call', 0, result)
return list_html return list_html
ListBoxWidgetInstance = ListBoxWidget() ListBoxWidgetInstance = ListBoxWidget()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment