X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=m_librarian%2Fdb.py;h=e7eea99560eadf289c8beab669c0043fa3cfdaa7;hb=76fad1db9bf3d812333ca9f65b1ed87c8549cab7;hp=b3ddd5211961196f282c411cfffe79acf9edada7;hpb=d6ef04787834ffeded257d96af4c965ca7055a51;p=m_librarian.git diff --git a/m_librarian/db.py b/m_librarian/db.py index b3ddd52..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,11 +148,16 @@ 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': def lower(s): - return s.lower() + if isinstance(s, basestring): + return s.lower() + return s sqlite = connection.module