pombreda / formalchemy

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

FieldSet.append() should accept AttributeFields for use with SQLAlchemy models #147

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In FA 1.3.4, for FieldSet.append() to be useful when appending fields which 
sync to SQLAlchemy models, one must append AttributeFields(), not Fields(). The 
problem is that appending an AttributeField() to a FieldSet is forbidden by an 
assertion in line 216 of base.py. Also all the examples of FieldSet.append() 
use Fields() not AttributeFields() which may cause confusion to users of 
SQLAlchemy.

>> fs = FieldSet(model=user, session=session)
>> fs.configure(pk=True, include=[fs.name, fs.address])
The following raises an assertion error due to the assert statement in base.py, 
line 216
>> fs.append(AttributeField(instrumented_attribute=User.telephone, parent=fs))

Unless there is something I am missing, I would recommend:
Changing the assert statement on line 216 of base.py to allow for 
AttributeFields to be used. Also, I'd change the documentation of the 
FieldSet.append() method to indicate that AttributeFields() must be used when 
using SQLAlchemy. 

Attached is the diff to base.py I am using.

Sam

Original issue reported on code.google.com by smagis...@gmail.com on 1 Oct 2010 at 3:06

Attachments:

GoogleCodeExporter commented 9 years ago
applied. thanks

Original comment by gael.pas...@gmail.com on 5 Oct 2010 at 12:30