On 02/23/2013 01:15 AM, Erik Janssens wrote:
>
> if they are read-only, that's propably because they are not
> recognized as 'SQLAlchemy' properties and just treated as
> normal Python properties, which are read only by default
>
> You could maket them editable through the field attributes,
> but even then probably the type is not going to be reflected,
> etc.
>
> Are you sure you're using the EntityAdmin and not the ObjectAdmin
> to specify the Admin interface ?
>
> You might have to look in EntityAdmin.get_field_attributes to
> see exactly what happens why the properties are not
> recognized
Alright I used SQLAlchemy directly and got the following when I
reflected the table:
insp.get_columns("cell_per")
[{'autoincrement': False,
'default': None,
'name': u'line_id',
'nullable': False,
'type': INTEGER()},
{'autoincrement': False,
'default': None,
'name': u'category',
'nullable': False,
'type': VARCHAR(length=10)},
{'autoincrement': False,
'default': None,
'name': u'cell_per',
'nullable': False,
'type': INTEGER()},
{'autoincrement': False,
'default': None,
'name': u'type',
'nullable': True,
'type': VARCHAR(length=6)},
{'autoincrement': False,
'default': u'now()',
'name': u'ts_insert',
'nullable': True,
'type': TIMESTAMP(precision=0)},
.....]
The INTEGER fields where the only ones I could edit because they map to
a type understood by Camelot. The VARCHAR fields are not mapped
correctly. Seems by default SQLAlchemy will take a UNICODE() type and
map it to the appropriate database dialect type, but not the other way
around. Seems there might be a way to override this:
http://docs.sqlalchemy.org/en/rel_0_7/orm/examples.html#declarative-reflection
Seems I am going to learn more about SQLAlchemy:)
--
Adrian Klaver
adrian...@gmail.com