Bauble / bauble.classic

this is how Bauble and Ghini both started
GNU General Public License v2.0
10 stars 34 forks source link

is there a callback for database changes? #230

Closed mfrasca closed 8 years ago

mfrasca commented 8 years ago

I am looking for something that gets activated any time there's a change to the database. I need that for, at least, updating the initial screen after a database change.

brettatoms commented 8 years ago

I've used SQLAlchemy events for this (http://docs.sqlalchemy.org/en/rel_1_0/orm/events.html) which will work in a single user environment but if multiple user's are using the same database then one client won't pick up the changes from another client. That would probably require a database trigger and some polling.

mfrasca commented 8 years ago

hi Brett, thanks for hint. I am aware of the multiuser and database trigger complication.

mario@rune:~$ cd Local/github/Bauble/bauble.classic
mario@rune:~/Local/github/Bauble/bauble.classic$ grep -rn event.listen bauble
mario@rune:~/Local/github/Bauble/bauble.classic$ 

my question was whether there was such a structure already in Bauble, if presenters are alerted by the framework. the above grep seems to tell me that if a presenter wants to be notified it should register its own listeners. I will probably do this for just the presenter I'm working at (the one for the initial home screen).

brettatoms commented 8 years ago

@mfrasca I think this must have been the old way to do it in SQLAlchemy before the @event.listen descriptors: https://github.com/Bauble/bauble.classic/blob/master/bauble/plugins/garden/accession.py#L370

mfrasca commented 8 years ago

@brettatoms thanks, I will look into it. it's very low priority: the user just hits again the home icon and things are back to fine.

mfrasca commented 8 years ago

mostly a note to myself : I think what I was looking for was a common update method in the views... what I found which served me: SearchView.reset_view. why was I looking for an update method ? »update« is the name of the InfoBox method. since the method does not really reset the view (the verb used in the docstring is to update) and it is invoked in just a very few places (twice internally and twice first making sure it is a view of the correct type), I think I will rename it to update.