From 953e5205541f5083092b5a17858703370684840d Mon Sep 17 00:00:00 2001
From: Renaud Le Gac <legac@cppm.in2p3.fr>
Date: Wed, 31 Oct 2012 16:57:41 +0100
Subject: [PATCH] Rename the converter to_panelWithUrlSelector and improve it.

---
 controllers/reports.py           |  2 +-
 models/widgets_viewport.py       |  3 ++-
 modules/plugin_dbui/__init__.py  |  2 +-
 modules/plugin_dbui/converter.py | 37 ++++++++++++++++++--------------
 views/reports/report_2.html      |  5 +++--
 5 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/controllers/reports.py b/controllers/reports.py
index e52fc824..9b55ae3f 100644
--- a/controllers/reports.py
+++ b/controllers/reports.py
@@ -22,7 +22,7 @@ def report_2():
     """Return the url arguments
     
     """
-    selector = Selector(db, extfield='my_format')
+    selector = Selector(virtdb.foo1, extfield='my_format')
     
     # user request a file with a specific format (latex,...)
     iframe = selector.download()
diff --git a/models/widgets_viewport.py b/models/widgets_viewport.py
index 43171246..c7487409 100755
--- a/models/widgets_viewport.py
+++ b/models/widgets_viewport.py
@@ -23,7 +23,8 @@ reportNode = dbui.Node(T('Reports'))
 node = dbui.Panel(html="salut ma poule")
 reportNode.add_child(T('report_1'), node)
 
-node = dbui.to_panel_with_url_selector(virtdb.foo1, URL('reports', 'report_2'))
+node = dbui.to_panelWithUrlSelector(virtdb.foo1, 
+                                    baseUrl=URL('reports', 'report_2'))
 reportNode.add_child(T('report_2'), node)
 
 versionNode = dbui.Panel(autoLoad='/'+request.application+'/default/versions')
diff --git a/modules/plugin_dbui/__init__.py b/modules/plugin_dbui/__init__.py
index 2e983ed9..ab43acba 100755
--- a/modules/plugin_dbui/__init__.py
+++ b/modules/plugin_dbui/__init__.py
@@ -10,7 +10,7 @@ from converter import (to_field,
                        to_gridFilter,
                        to_gridPanel,
                        to_jsonstore,
-                       to_panel_with_url_selector,
+                       to_panelWithUrlSelector,
                        to_tree,
                        to_viewport)
 from dbsvc import DbSvc
diff --git a/modules/plugin_dbui/converter.py b/modules/plugin_dbui/converter.py
index 29d62fe7..f47f9b6f 100644
--- a/modules/plugin_dbui/converter.py
+++ b/modules/plugin_dbui/converter.py
@@ -586,32 +586,37 @@ def to_jsonstore(table, **kwargs):
     return cfg
 
 
-def to_panel_with_url_selector(table, url, is_mathjax=False):
-    """Build the configuration for a PanelWithUrlSelector
+def to_panelWithUrlSelector(table, **kwargs):
+    """Build the configuration for a simple PanelWithUrlSelector
     where the selector is a form derived from the database table.
-    
-    The selected values are send to a controller defined by the URL.
+
+    The selected values are send to a controller defined by the baseUrl.
     Values are processed and results will be published in the panel.
+    It is mandatory to specified the baseUrl.
+        
+    The others keyword arguments are the configuration parameters
+    of the PanelWithUrlSelector. By default is_mathjax is False, 
+    and panelCfg, selectorCfg, selectorCollapsible are defined.
     
-            table
-                gluon.dal.Table
-                
-            url
-                well form URL
-                
     """
+    if 'baseUrl' not in kwargs:
+        raise BaseException('The keyword argument basseUrl is missing.')
+
     # build the selector from the table
     fields = to_fields(table)
     selector = FieldSet(items=fields, 
                         plugins=['pFormToolTip'],
                         title=current.T('Select'))
-    
+
     # build the configuration for the PanelWithUrlSelector
-    cfg = PanelWithUrlSelector(baseUrl=url,
-                               isMathJax=is_mathjax,
-                               panelCfg=Panel(),
-                               selectorCfg=selector,
-                               selectorCollapsible=False)
+    default = dict(isMathJax=False,
+                   panelCfg=Panel(),
+                   selectorCfg=selector,
+                   selectorCollapsible=False)
+
+    default.update(kwargs)
+    cfg = PanelWithUrlSelector(**default)
+    
     return cfg
 
 
diff --git a/views/reports/report_2.html b/views/reports/report_2.html
index 5181b246..c082d94f 100644
--- a/views/reports/report_2.html
+++ b/views/reports/report_2.html
@@ -1,3 +1,4 @@
 <h3>Report_2</h3>
-{{for k in test:}}
-  <br>{{=k}}: {{=test[k]}}{{pass}}
+<hr>
+{{=BEAUTIFY(test)}}
+<hr>
\ No newline at end of file
-- 
GitLab