]> git.phdru.name Git - m_librarian.git/blobdiff - m_librarian/db.py
Version 0.0.12: download many books
[m_librarian.git] / m_librarian / db.py
index f65569cb6e37183922b4dc6ae4e88a51e5bfec00..e7eea99560eadf289c8beab669c0043fa3cfdaa7 100755 (executable)
@@ -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':