diff options
author | makkalot <makkalot@gmail.com> | 2008-06-12 22:20:58 +0300 |
---|---|---|
committer | makkalot <makkalot@gmail.com> | 2008-06-12 22:20:58 +0300 |
commit | 0616b737922449af511bcf918f662c3e4f1c4f35 (patch) | |
tree | 67b99de09dd2a252238feb69c426ffbfd1b3c2f0 /funcweb/funcweb/widget_automation.py | |
parent | 90b17c280e33a9feeda71962e9f82ef53f774879 (diff) | |
download | func-0616b737922449af511bcf918f662c3e4f1c4f35.tar.gz func-0616b737922449af511bcf918f662c3e4f1c4f35.tar.xz func-0616b737922449af511bcf918f662c3e4f1c4f35.zip |
adding a RemoteForm automation to our widget factory
Diffstat (limited to 'funcweb/funcweb/widget_automation.py')
-rw-r--r-- | funcweb/funcweb/widget_automation.py | 47 |
1 files changed, 47 insertions, 0 deletions
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) |