Revision 7218b9c1
Added by dsorber almost 12 years ago
| software/bookmark_library/lib/bookmark.py | ||
|---|---|---|
|
|
||
|
import sqlite3
|
||
|
|
||
|
from tag import Tag
|
||
|
|
||
|
|
||
|
DB_PATH = 'bookmarks.db'
|
||
|
|
||
|
SQL_SELECT_BOOKMARK = "SELECT * FROM bookmarks WHERE id=?"
|
||
|
SQL_INSERT_BOOKMARK = "INSERT INTO bookmarks VALUES (?,?,?,?,?,?,?,?)"
|
||
|
SQL_UPDATE_BOOKMARK = "UPDATE bookmarks SET {:s} WHERE id=?"
|
||
|
SQL_SELECT_CAT_TAGS = "SELECT tag_id FROM category_tags where bookmark_id=?"
|
||
|
SQL_SELECT_DESC_TAGS = "SELECT tag_id FROM description_tags where bookmark_id=?"
|
||
|
|
||
|
HTTP_OKAY = 200
|
||
|
|
||
| ... | ... | |
|
self.deleted = False
|
||
|
else:
|
||
|
self.deleted = True
|
||
|
|
||
|
# Grab category tags
|
||
|
for row in db.execute(SQL_SELECT_CAT_TAGS, (self.id,)):
|
||
|
self.category_tags.add(Tag(int(row[0])))
|
||
|
|
||
|
# Grab description tags
|
||
|
for row in db.execute(SQL_SELECT_DESC_TAGS, (self.id,)):
|
||
|
self.description_tags.add(Tag(int(row[0])))
|
||
|
|
||
|
# This dict MUST appear *after* the data attributes, it is used to
|
||
|
# record which data attributes are dirty
|
||
| ... | ... | |
|
'times_visited': False,
|
||
|
'last_visited': False,
|
||
|
'last_reachable': False,
|
||
|
'deleted': False}
|
||
|
'deleted': False}
|
||
|
|
||
|
def __del__(self):
|
||
|
""" Automatically save any changes to a record before the object is
|
||
Added a tiny bit of code tonight. Need to keep track of dirty value of tags lists using hash (convert from set to frozenset before hashing).