pombreda / formalchemy

Automatically exported from code.google.com/p/formalchemy
MIT License
0 stars 0 forks source link

Grid.configure() not passing parameters properly to FieldSet.configure() #163

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi

Very nice refactoring of FieldSet and Grid! Found one bug though:

Grid.configure() passes the arguments to the super class as positional 
arguments instead of keyword arguments.

The problem can be reproduced like so:
from formalchemy import Grid
from formalchemy.tests import Three
inst = Three(id=123)
grid = Grid(Three, [inst])
grid.configure(include=[grid.foo])
grid.render()
u'<thead>\n  <tr>\n      <th>Foo</th>\n      <th>Bar</th>\n  
</tr>\n</thead>\n\n<tbody>\n  \n  \n  <tr class="even">\n    <td>\n      <input 
id="Three-123-foo" name="Three-123-foo" type="text" />\n    </td>\n    <td>\n   
   <input id="Three-123-bar" name="Three-123-bar" type="text" />\n    </td>\n  
</tr>\n</tbody>\n'

-> Field Foo is still rendered

Solution:
in formalchemy.tables.py, change line 67:
FieldSet.configure(self, pk, exclude, include, options)
to
FieldSet.configure(self, pk=pk, exclude=exclude, include=include, 
options=options)

by the way: consider setting the default values in Fieldset.configure() for 
exclude/include/options to None instead of [] like so:
def configure(self, pk=False, focus=True, readonly=False, 
global_validator=None, exclude=None, include=None, options=None):
AFAIK it is considered bad practice to instantiate objects in method 
signatures. 

Cheers,
Stefani

Original issue reported on code.google.com by stefani....@gmail.com on 25 Mar 2011 at 3:09

GoogleCodeExporter commented 9 years ago
Sorry, it should say "Field Bar is still rendered".
Stefani

Original comment by stefani....@gmail.com on 25 Mar 2011 at 3:20

GoogleCodeExporter commented 9 years ago
I've released a 1.3.7 to fix that (signature is not changed though)

Original comment by gael.pas...@gmail.com on 25 Mar 2011 at 3:35