ivoflipse / Pawlabeling

Tool for processing and analyzing pressure measurements
Other
18 stars 1 forks source link

Load contents from child tables after putting #64

Closed ivoflipse closed 11 years ago

ivoflipse commented 11 years ago

For example, when you select a session, I can make a dictionary self.measurements that keeps track of all the measurement objects. Then I can always trust on this being present, without having to ask PyTables for anything.

The reason I bring it up is when I checked model.put_measurement, I noticed I was creating a self.measurement using information I got from the processing widget. But preferably I'd keep the View as agnostic about what its dealing with as possible, because that way its easier to ensure its actually displaying what I want it to display.

def put_measurement(self, measurement):
    self.measurement = measurement
    self.measurement_id = measurement["measurement_id"]
    self.measurement_name = measurement["measurement_name"]
    self.logger.info("Measurement ID set to {}".format(self.measurement_id))
    self.contacts_table = table.ContactsTable(database_file=self.database_file,
                                              subject_id=self.subject_id,
                                              session_id=self.session_id,
                                              measurement_id=self.measurement_id)
    pub.sendMessage("update_statusbar", status="Measurement: {}".format(self.measurement_name))

If instead it only returned the measurement_name (guaranteed to be unique within a session), I could look it up in self.measurements and then set self.measurement to be the right one.

ivoflipse commented 11 years ago

I just noticed measurementwidget is subscribed to put_session, so it will trigger get_measurements. This seems very inefficient, since I already know every widget will be interested in the result, I might as well trigger it myself.

Perhaps I should create a controller.py whoms task it is to trigger these events. The model was actually meant as a glue layer between the view and the pytables's tables, not to control the flow of the program.

ivoflipse commented 11 years ago

This is working for just about everything, sadly it made some functions rather messy, so I'll probably have to refactor things.