1. toscawidgets
  2. tw.dynforms

Commits

paul.paj  committed 9b7a534

[svn] Updates to work with latest toscawidgets

  • Participants
  • Parent commits 48c2a8e
  • Branches trunk

Comments (0)

Files changed (2)

File dyndemo/dyndemo/controllers.py

View file
 import turbogears as tg
 from turbogears import controllers, expose, flash
 import toscawidgets.widgets.dynforms as twd
-import toscawidgets.widgets.forms as twf
+import tw.forms as twf
 from dyndemo import model
-import formencode as fe, toscawidgets.api as tw
+import formencode as fe
 # import logging
 # log = logging.getLogger("dyndemo.controllers")
 
 orderlist = OrderList('fred', None)
 
 orderform = twf.TableForm('order', action='save_order', validator=FilteringSchema, children=[
-    tw.Child(twf.LabelHiddenField, 'id'),
-    tw.Child(twf.TextField, 'title'),
-    tw.Child(twd.OtherSingleSelectField, 'cust_id', dataobj=model.Customer, field='name'),
-    tw.Child(twf.TextField, 'service'),
-    tw.Child(twf.TextField, 'value', validator=fe.validators.Int),
-    tw.Child(twd.HidingSingleSelectField, 'ordtype', options=[('',''), (1,'Hardware'), (2,'Software')], mapping={1:['location'], 2:['os']}),
-    tw.Child(twf.TextField, 'location'),
-    tw.Child(twf.TextField, 'os'),
-    tw.Child(twd.WriteOnlyTextField, 'ccnum'),
-    tw.Child(twd.GrowableTableFieldSet, 'parts', children = [
-        tw.Child(twf.TextField, 'name'),
-        tw.Child(twf.TextField, 'detail'),
-        tw.Child(twf.TextField, 'price', validator=fe.validators.Int),
+    twf.LabelHiddenField('id'),
+    twf.TextField('title'),
+    twd.OtherSingleSelectField('cust_id', dataobj=model.Customer, field='name'),
+    twf.TextField('service'),
+    twf.TextField('value', validator=fe.validators.Int),
+    twd.HidingSingleSelectField('ordtype', options=[('',''), (1,'Hardware'), (2,'Software')], mapping={1:['location'], 2:['os']}),
+    twf.TextField('location'),
+    twf.TextField('os'),
+    twd.WriteOnlyTextField('ccnum'),
+    twd.GrowableTableFieldSet('parts', children = [
+        twf.TextField('name'),
+        twf.TextField('detail'),
+        twf.TextField('price', validator=fe.validators.Int),
     ]),    
 ])   
 

File toscawidgets/widgets/dynforms/widgets.py

View file
     validator = StripGrow
 
     def __new__(cls, id=None, parent=None, children=[], **kw):        
-        #children.append(tw.api.Child(DelUndo, 'delundo'))
-        #children.append(tw.api.Child(twf.HiddenField, 'id', validator=fe.validators.Int))
+        #children.append(DelUndo('delundo'))
+        #children.append(twf.HiddenField('id', validator=fe.validators.Int))
         children.append(DelUndo('delundo'))
         children.append(twf.HiddenField('id', validator=fe.validators.Int))
-        children = [tw.api.Child(StrippingFieldRepeater, 'grow', widget=TrFieldSet('row', children=children))]
+        children = [StrippingFieldRepeater('grow', widget=TrFieldSet('row', children=children))]
         return twf.FieldSet.__new__(cls, id, parent, children, **kw)
 
 class GrowableTableForm(GrowableTableFieldSet):
 
     def __new__(cls, id=None, parent=None, children=[], widget=None, **kw):
         children = [
-            tw.api.Child(twf.FormFieldRepeater, 'rep', widget=widget, extra=0, repetitions=1, max_repetitions=10),                        
-            tw.api.Child(widget, 'spare'),
-            tw.api.Child(twf.Button, 'add', default=cls.button_text, attrs={'onclick':"add_section(this, '')"}),
+            twf.FormFieldRepeater('rep', widget=widget, extra=0, repetitions=1, max_repetitions=10),                        
+            widget('spare'),
+            twf.Button('add', default=cls.button_text, attrs={'onclick':"add_section(this, '')"}),
         ]
         return twf.FieldSet.__new__(cls, id, parent, children, **kw)
 
     fixed_fields = {}
 
     children = [
-        tw.api.Child(HidingSingleSelectField, 'select'),
-        tw.api.Child(twf.TextField, 'other'),
+        HidingSingleSelectField('select'),
+        twf.TextField('other'),
     ]
 
     # This is needed to avoid the value being coerced to a dict