FileField overwrites Database Entries

7 views
Skip to first unread message

Moritz Schlarb

unread,
Mar 20, 2012, 8:38:22 AM3/20/12
to sp...@googlegroups.com
Hello at all!

I'm using the Turbogears 2.1 Admin extension (tgext.admin) that uses sprox heavily to provide a CRUD interface for the sqlalchemy model.

Since I have some PickleType columns in my model that should only be filled by uploading plain files, I created the following form:

class TestEditForm(EditableForm):
    __model__ = Test
    __require_fields__     = ['type']
    __omit_fields__        = ['id', 'assignment_id']
    __field_order__        = ['assignment', 'type', 'visible', 'timeout', 'argv', 'input', 'output']
    
    input = FileField(id='input', validator=FieldStorageUploadConverter(not_empty=False))
    output = FileField(id='output',validator=FieldStorageUploadConverter(not_empty=False))

which is included via

class TestCrudConfig(CrudRestControllerConfig):
    edit_form_type = TestEditForm

and

class MyAdminConfig(AdminConfig):
    test = TestCrudConfig

Now if there is already data in the input/output columns, it just gets overwritten with None if the file isn't uploaded again.

Am I missing a parameter to accomplish this non-overwriting behaviour?
Or could someone tell me some hackish way to achieve this!

Thanks a lot,
Moritz
Reply all
Reply to author
Forward
0 new messages