There's more...

You might have noted that update and delete operations work thanks to the rowid field, for instance, in the update_contact method from the ContactsController class:

    def update_contact(self):
if not self.selection:
return
rowid = self.contacts[self.selection].rowid
update_contact = self.view.get_details()
update_contact.rowid = rowid

Since this is an implementation detail for our SQLite database, this should be hidden from the rest of our components.

A solution would be to add another field to the Contact class with a name such as id or contact_id—note that id is also a Python built-in function and some editors might incorrectly highlight it.

Then, we can assume this field is part of our domain data as a unique identifier and leave the implementation details of how it is generated to the model.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset