Add loading of user template functions to the new backend

This commit is contained in:
Kovid Goyal 2013-07-19 18:25:01 +05:30
parent 3a044f28e6
commit 97d0eed452
3 changed files with 5 additions and 3 deletions

View File

@ -168,8 +168,7 @@ How this will proceed:
work.
Various things that require other things before they can be migrated:
1. From initialize_dynamic(): set_saved_searches,
load_user_template_functions. Also add custom
1. From initialize_dynamic(): Also add custom
columns/categories/searches info into
self.field_metadata.
2. Catching DatabaseException and sqlite.Error when creating new

View File

@ -29,6 +29,7 @@ from calibre.utils.filenames import (is_case_sensitive, samefile, hardlink_file,
WindowsAtomicFolderMove)
from calibre.utils.magick.draw import save_cover_data_to
from calibre.utils.recycle_bin import delete_tree, delete_file
from calibre.utils.formatter_functions import load_user_template_functions
from calibre.db.tables import (OneToOneTable, ManyToOneTable, ManyToManyTable,
SizeTable, FormatsTable, AuthorsTable, IdentifiersTable, PathTable,
CompositeTable, UUIDTable)
@ -372,6 +373,8 @@ class DB(object):
self.initialize_prefs(default_prefs, restore_all_prefs, progress_callback)
self.initialize_custom_columns()
self.initialize_tables()
load_user_template_functions(self.library_id,
self.prefs.get('user_template_functions', []))
def initialize_prefs(self, default_prefs, restore_all_prefs, progress_callback): # {{{
self.prefs = DBPrefs(self)

View File

@ -55,7 +55,7 @@ class LibraryDatabase(object):
default_prefs=None, read_only=False, is_second_db=False,
progress_callback=lambda x, y:True, restore_all_prefs=False):
self.is_second_db = is_second_db # TODO: Use is_second_db
self.is_second_db = is_second_db
self.listeners = set()
backend = self.backend = DB(library_path, default_prefs=default_prefs,