hasgeek / baseframe

Baseframe for Hasgeek projects
BSD 3-Clause "New" or "Revised" License
11 stars 17 forks source link

Don't assume `id` for primary key column #153

Open jace opened 7 years ago

jace commented 7 years ago

Baseframe forms provide an edit_id that is set to obj.id. As discussed in hasgeek/coaster#111, this is incorrect usage. edit_id should be deprecated in favour of an edit_identity value using the correct method. (We use a different name here since the value will change from a scalar to a tuple.) All references within Baseframe to edit_id must be replaced with edit_identity (for example in something like AvailableName).

jace commented 7 years ago

Baseframe has two uses of edit_id.

  1. In forms/form.py, where the form constructor is notionally unaware of SQLAlchemy but checks if the object has an attribute named id. Introducing SQLAlchemy awareness seems like a bad idea here.

  2. In forms/sqlalchemy.py, in the AvailableAttr (previously AvailableName) validator, where edit_id could be replaced with the inspect approach, but where we also need to know the columns to test against in a query.