[Twisted-Python] web.static & woven.widgets patches

Bruce Mitchener bruce at cubik.org
Wed Oct 9 17:14:57 MDT 2002


Hey Paul,

Paul Boehm wrote:
> i too found no unittests for woven, and my patch allows to
> check checkboxes via the model. this shouldn't break anything
> either.
> 
> can anyone give me a statement regarding those patches?

Sure, on this one I can. :)

> diff -u -r1.20 widgets.py
> --- widgets.py  3 Oct 2002 15:46:26 -0000       1.20
> +++ widgets.py  4 Oct 2002 16:52:50 -0000
> @@ -388,13 +388,17 @@
> 
>      def generateDOM(self, request, node):
>          mVal = self.getData()
> -        if mVal:
> -            self['value'] = str(mVal)
> +        self['value'] = str(mVal)
>          return Widget.generateDOM(self, request, node)

That part is good and fixes a fairly ugly bug that I'd been seeing.

>  class CheckBox(Input):
>      def initialize(self):
>          self['type'] = 'checkbox'
> +    def generateDOM(self, request, node):
> +        node = Input.generateDOM(self, request, node)
> +        if self.getData():
> +            node.setAttribute('checked', "checked")
> +        return node

This part isn't good though ... any time the value="" is set with this, 
it'd be checked, when that isn't really the desired behavior.

For instance, in this random bit of a woven template (ignoring other 
random things that might be wrong with it):

     <table width="50%" model="products" view="List" class="summary"
        border="1" cellpadding="3" cellspacing="0">
         <tr class="listHeader">
             <th width="100%">Products</th>
             <th>Delete</th>
         </tr>
         <tr class="emptyList">
             <td align="center">*** None ***</td>
         </tr>
         <tr class="listItem">
             <td>      <span view="ProductLink" /></td>
             <td align="center">
               <input view="CheckBox" controller="ProductDeleter"
                      model="productID" />
             </td>
         </tr>
         <tr class="listFooter">
             <td colspan="2" align="right"><input type='submit'
                 name='delproducts' value='Process deletions' /></td>
         </tr>
     </table>

that would produce a table with the right column being checkboxes .. but 
with all of them but the first one checked if the productID ranged from 
0-10.

  - Bruce





More information about the Twisted-Python mailing list