From f46c8b06233566c66df81848d4fa9ee785432cbe Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Mon, 13 Jan 2014 15:04:48 -0800 Subject: [PATCH] move database_change events back to library.py dbcore is abstractable. Should not depend on any beets internals. --- beets/dbcore.py | 1 - beets/library.py | 12 ++++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/beets/dbcore.py b/beets/dbcore.py index 2189c0c88..d40c0a80a 100644 --- a/beets/dbcore.py +++ b/beets/dbcore.py @@ -511,7 +511,6 @@ class Transaction(object): the row ID of the last affected row. """ cursor = self.lib._connection().execute(statement, subvals) - plugins.send('database_change', lib=self.lib) return cursor.lastrowid def script(self, statements): diff --git a/beets/library.py b/beets/library.py index ab2c8d383..ecc3218ee 100644 --- a/beets/library.py +++ b/beets/library.py @@ -204,6 +204,18 @@ class LibModel(dbcore.Model): funcs.update(plugins.template_funcs()) return funcs + def store(self): + super(LibModel, self).store() + plugins.send('database_change', lib=self.lib) + + def remove(self): + super(LibModel, self).remove() + plugins.send('database_change', lib=self.lib) + + def add(self, lib=None): + super(LibModel, self).add(lib) + plugins.send('database_change', lib=self.lib) + class Item(LibModel): _fields = ITEM_KEYS