X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=m_librarian%2Fdb.py;h=e7eea99560eadf289c8beab669c0043fa3cfdaa7;hb=d9a85ec552d93e4a009f729d09f4452e6b34dac5;hp=f65569cb6e37183922b4dc6ae4e88a51e5bfec00;hpb=cf773e9ae70a7a1cbdd27e234db3834c3c07d649;p=m_librarian.git diff --git a/m_librarian/db.py b/m_librarian/db.py index f65569c..e7eea99 100755 --- a/m_librarian/db.py +++ b/m_librarian/db.py @@ -20,6 +20,12 @@ class Author(SQLObject): books = RelatedJoin('Book', otherColumn='book_id', intermediateTable='author_book', createRelatedTable=False) + + @property + def fullname(self): + fullnames = filter(None, (self.surname, self.name, self.misc_name)) + return ' '.join(fullnames) + full_name_idx = DatabaseIndex(surname, name, misc_name, unique=True) count_idx = DatabaseIndex(count) @@ -142,6 +148,9 @@ def open_db(db_uri=None): except: db_uri = find_sqlite_dburi() + if '://' not in db_uri: + db_uri = 'sqlite://' + os.path.abspath(db_uri).replace(os.sep, '/') + sqlhub.processConnection = connection = connectionForURI(db_uri) if connection.dbName == 'sqlite':