summaryrefslogtreecommitdiffstats
path: root/funcweb
diff options
context:
space:
mode:
authormakkalot <makkalot@gmail.com>2008-06-12 22:20:58 +0300
committermakkalot <makkalot@gmail.com>2008-06-12 22:20:58 +0300
commit0616b737922449af511bcf918f662c3e4f1c4f35 (patch)
tree67b99de09dd2a252238feb69c426ffbfd1b3c2f0 /funcweb
parent90b17c280e33a9feeda71962e9f82ef53f774879 (diff)
downloadfunc-0616b737922449af511bcf918f662c3e4f1c4f35.tar.gz
func-0616b737922449af511bcf918f662c3e4f1c4f35.tar.xz
func-0616b737922449af511bcf918f662c3e4f1c4f35.zip
adding a RemoteForm automation to our widget factory
Diffstat (limited to 'funcweb')
-rw-r--r--funcweb/funcweb/tests/test_widget_automation.py10
-rw-r--r--funcweb/funcweb/widget_automation.py47
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)