commit 7056140d381988062bf59df5f89a28b4eb7504af
Author: dsorber <david.sorber@gmail.com>
Date:   Sun Jul 13 10:50:06 2014 -0400

    Started working on the Tag class.

diff --git a/software/bookmark_library/lib/bookmark.py b/software/bookmark_library/lib/bookmark.py
index 9dfb26f..135e53e 100644
--- a/software/bookmark_library/lib/bookmark.py
+++ b/software/bookmark_library/lib/bookmark.py
@@ -34,8 +34,7 @@ class Bookmark(object):
     
     def __init__(self, db_conn, id=None, url=None):
         
-        # Make sure the DB connection is valid before doing anything 
-        # else
+        # Make sure the DB connection is valid before doing anything else
         if not db_conn:
             raise DBConnectionError('Invalid database connection object!')
         
@@ -52,8 +51,10 @@ class Bookmark(object):
         self.last_visited = 0
         self.last_reachable = 0
         self.deleted = False
+        self.category_tags = set()
+        self.description_tags = set()
         
-        # Retrieve an existing bookmark
+        # Retrieve an existing bookmark if an ID is passed in
         if self.id:
             db = self._db_conn.cursor()
             db.execute(SQL_SELECT_BOOKMARK, (self.id,))
diff --git a/software/bookmark_library/lib/tag.py b/software/bookmark_library/lib/tag.py
index e69de29..655214c 100644
--- a/software/bookmark_library/lib/tag.py
+++ b/software/bookmark_library/lib/tag.py
@@ -0,0 +1,41 @@
+import sqlite3
+
+SQL_SELECT_TAG_BY_ID = "SELECT * FROM tags WHERE id=?"
+SQL_SELECT_TAG_BY_VALUE = "SELECT * FROM tags WHERE value=?"
+
+
+class Tag(object):
+    
+    def __init__(self, db_conn, id=None, value=None):
+        
+        # Make sure the DB connection is valid before doing anything else
+        if not db_conn:
+            raise Exception
+            #~ raise DBConnectionError('Invalid database connection object!')
+            
+        self._db_conn = db_conn
+        
+        # Data attributes
+        self.id = id
+        self.value = value
+
+        if self.id:
+            # If an ID was passed in then the tag's value must match the ID
+            db = self._db_conn.cursor()
+            db.execute(SQL_SELECT_TAG_BY_ID, (self.id,))
+            row = db.fetchone()
+            if not row:
+                raise Exception
+            self.value = row[1]   
+                 
+        elif self.value:
+            # If a value was passed in, check to see if it already exists in 
+            # the DB; if so set the ID accordingly
+            db = self._db_conn.cursor()
+            db.execute(SQL_SELECT_TAG_BY_VALUE, (self.value,))
+            row = db.fetchone()
+            if row:
+               self.id = int(row[0]) 
+
+    def __str__(self, value):
+        return repr(self.value)
