diff options
Diffstat (limited to 'funcweb/funcweb')
-rw-r--r-- | funcweb/funcweb/tests/test_widget_automation.py | 10 | ||||
-rw-r--r-- | funcweb/funcweb/widget_automation.py | 47 |
2 files changed, 55 insertions, 2 deletions
diff --git a/funcweb/funcweb/tests/test_widget_automation.py b/funcweb/funcweb/tests/test_widget_automation.py index f841c43..5a2247d 100644 --- a/funcweb/funcweb/tests/test_widget_automation.py +++ b/funcweb/funcweb/tests/test_widget_automation.py @@ -4,7 +4,7 @@ from turbogears import testutil from funcweb.controllers import Root import cherrypy -from funcweb.widget_automation import WidgetListFactory +from funcweb.widget_automation import WidgetListFactory,RemoteFormAutomation cherrypy.root = Root() class TestWidgetListFactory(unittest.TestCase): @@ -44,7 +44,13 @@ class TestWidgetListFactory(unittest.TestCase): for argument_name in compare_with.keys(): assert hasattr(widget_list_object,argument_name) == True - #print getattr(widget_list_object,argument_name) + #print getattr(widget_list_object,argument_name) + + + def test_remote_form(self): + widget_list_object = self.widget_factory.get_widgetlist_object() + remote_form = RemoteFormAutomation(widget_list_object) + #print remote_form def get_test_default_args(self): return { diff --git a/funcweb/funcweb/widget_automation.py b/funcweb/funcweb/widget_automation.py index 36d8a5c..92ab7ab 100644 --- a/funcweb/funcweb/widget_automation.py +++ b/funcweb/funcweb/widget_automation.py @@ -143,3 +143,50 @@ class WidgetListFactory(object): #get the object back return widget_list_object + +#################################################################################################################### +from turbogears.widgets.base import CoreWD +from turbogears.widgets import RemoteForm +from turbogears import validators, expose + +class RemoteFormAutomation(CoreWD): + """ + Base class for ajaxian Form creation + """ + + name = "Ajaxian Minion Submit Form" + + template = """ + <div> + {for_widget.display()} + <div id="loading"></div> + <div id="post_data"></div> + </div> + """ + + full_class_name = "turbogears.widgets.RemoteForm" + + def __init__(self,generated_fields,*args,**kwarg): + """ + The constructor part same as normal one except + it takes a WidgetsList object into generated_fields + which is generated by WidgetListFactory + """ + #call the master :) + super(RemoteFormAutomation,self).__init__(*args,**kwarg) + self.for_widget = RemoteForm( + fields = generated_fields, + name = "minion_form", + update = "post_data", + before='getElement(\'loading\').innerHTML=\'Submiting form!\';', + on_complete='getElement(\'loading\' ).innerHTML=\'Done!\';', + action = "%s/post_form"%(self.full_class_name) + ) + + def post_form(self,**kw): + """ + Data processing part + """ + return "I got that data from the remote minion form :<br/>%r"%kw + + post_form = expose()(post_form) |