[pkg-fso-commits] [SCM] FSO frameworkd Debian packaging branch, debian, updated. upstream/0.9.5.5-717-g0f98819
Sebastian Krzyszkowiak
seba.dos1 at gmail.com
Sat Aug 6 08:17:57 UTC 2011
The following commit has been merged in the debian branch:
commit 2233cd9474238be941b0d50c2b6b5ec7756f6a90
Author: Sebastian Krzyszkowiak <seba.dos1 at gmail.com>
Date: Thu Aug 20 14:44:16 2009 +0200
opimd: SQLite-Notes: add new backend
diff --git a/framework/subsystems/opimd/opimd.py b/framework/subsystems/opimd/opimd.py
index 3e66b03..e661391 100644
--- a/framework/subsystems/opimd/opimd.py
+++ b/framework/subsystems/opimd/opimd.py
@@ -56,6 +56,7 @@ import pimb_sqlite_contacts
import pimb_sqlite_messages
import pimb_sqlite_calls
import pimb_sqlite_dates
+import pimb_sqlite_notes
import pimb_ogsmd_calls
from backend_manager import BackendManager
diff --git a/framework/subsystems/opimd/pimb_sqlite_dates.py b/framework/subsystems/opimd/pimb_sqlite_notes.py
similarity index 58%
copy from framework/subsystems/opimd/pimb_sqlite_dates.py
copy to framework/subsystems/opimd/pimb_sqlite_notes.py
index 72c60dd..e1fd55c 100644
--- a/framework/subsystems/opimd/pimb_sqlite_dates.py
+++ b/framework/subsystems/opimd/pimb_sqlite_notes.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# Openmoko PIM Daemon
-# SQLite-Dates Backend Plugin
+# SQLite-Notes Backend Plugin
#
# http://openmoko.org/
#
@@ -23,7 +23,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
-"""opimd SQLite-Dates Backend Plugin"""
+"""opimd SQLite-Notes Backend Plugin"""
import os
import sqlite3
@@ -40,15 +40,15 @@ import framework.patterns.tasklet as tasklet
from framework.config import config, rootdir
rootdir = os.path.join( rootdir, 'opim' )
-_DOMAINS = ('Dates', )
-_SQLITE_FILE_NAME = os.path.join(rootdir,'sqlite-dates.db')
+_DOMAINS = ('Notes', )
+_SQLITE_FILE_NAME = os.path.join(rootdir,'sqlite-notes.db')
#----------------------------------------------------------------------------#
-class SQLiteDatesBackend(Backend):
+class SQLiteNotesBackend(Backend):
#----------------------------------------------------------------------------#
- name = 'SQLite-Dates'
+ name = 'SQLite-Notes'
properties = [PIMB_CAN_ADD_ENTRY, PIMB_CAN_DEL_ENTRY, PIMB_CAN_UPD_ENTRY, PIMB_CAN_UPD_ENTRY_WITH_NEW_FIELD]
_domain_handlers = None # Map of the domain handler objects we support
@@ -56,27 +56,26 @@ class SQLiteDatesBackend(Backend):
#----------------------------------------------------------------------------#
def __init__(self):
- super(SQLiteDatesBackend, self).__init__()
+ super(SQLiteNotesBackend, self).__init__()
self._domain_handlers = {}
self._entry_ids = []
try:
self.con = sqlite3.connect(_SQLITE_FILE_NAME)
cur = self.con.cursor()
- cur.execute("""CREATE TABLE IF NOT EXISTS dates (
+ cur.execute("""CREATE TABLE IF NOT EXISTS notes (
id INTEGER PRIMARY KEY,
- Begin INTEGER,
- End INTEGER,
- Message TEXT,
- deleted INTEGER DEFAULT 0);""")
+ Timestamp TEXT,
+ Timezone TEXT,
+ Title TEXT,
+ Content TEXT);""")
- cur.execute("CREATE TABLE IF NOT EXISTS date_values (id INTEGER PRIMARY KEY, dateId INTEGER, Field TEXT, Value TEXT)")
+ cur.execute("CREATE TABLE IF NOT EXISTS note_values (id INTEGER PRIMARY KEY, noteId INTEGER, Field TEXT, Value TEXT)")
- cur.execute("CREATE INDEX IF NOT EXISTS dates_id_idx ON dates (id)")
- cur.execute("CREATE INDEX IF NOT EXISTS dates_Begin_idx ON dates (Begin)")
- cur.execute("CREATE INDEX IF NOT EXISTS dates_End_idx ON dates (End)")
- cur.execute("CREATE INDEX IF NOT EXISTS dates_Message_idx ON dates (Message)")
+ cur.execute("CREATE INDEX IF NOT EXISTS notes_id_idx ON notes (id)")
+ cur.execute("CREATE INDEX IF NOT EXISTS notes_Title_idx ON notes (Title)")
+ cur.execute("CREATE INDEX IF NOT EXISTS notes_Content_idx ON notes (Content)")
- cur.execute("CREATE INDEX IF NOT EXISTS date_values_datesId_idx ON date_values (dateId)")
+ cur.execute("CREATE INDEX IF NOT EXISTS note_values_notesId_idx ON note_values (noteId)")
self.con.text_factory = sqlite3.OptimizedUnicode
self.con.commit()
@@ -109,13 +108,13 @@ class SQLiteDatesBackend(Backend):
def load_entries_from_db(self):
"""Loads all entries from db"""
- keys = {0:'_backend_entry_id', 1:'Begin', 2:'End', 3:'Message'}
+ keys = {0:'_backend_entry_id', 1:'Timestamp', 2:'Timezone', 3:'Title', 4:'Content'}
cur = self.con.cursor()
try:
- cur.execute('SELECT id, Begin, End, Message FROM dates WHERE deleted=0')
+ cur.execute('SELECT * FROM notes')
lines = cur.fetchall()
except:
- logger.error("%s: Could not read from database (table dates)! Possible reason is old, uncompatible table structure. If you don't have important data, please remove %s file.", self.name, _SQLITE_FILE_NAME)
+ logger.error("%s: Could not read from database (table notes)! Possible reason is old, uncompatible table structure. If you don't have important data, please remove %s file.", self.name, _SQLITE_FILE_NAME)
raise OperationalError
for line in lines:
@@ -123,7 +122,7 @@ class SQLiteDatesBackend(Backend):
for key in keys:
entry[keys[key]] = line[key]
try:
- cur.execute('SELECT Field, Value FROM date_values WHERE dateId=?',(line[0],))
+ cur.execute('SELECT Field, Value FROM note_values WHERE noteId=?',(line[0],))
for pair in cur:
if entry.has_key(pair[0]):
if type(entry[pair[0]]) == list:
@@ -133,72 +132,70 @@ class SQLiteDatesBackend(Backend):
else:
entry[pair[0]]=pair[1]
except:
- logger.error("%s: Could not read from database (table date_values)! Possible reason is old, uncompatible table structure. If you don't have important data, please remove %s file.", self.name, _SQLITE_FILE_NAME)
+ logger.error("%s: Could not read from database (table note_values)! Possible reason is old, uncompatible table structure. If you don't have important data, please remove %s file.", self.name, _SQLITE_FILE_NAME)
raise OperationalError
- entry_id = self._domain_handlers['Dates'].register_entry(self, entry)
+ entry_id = self._domain_handlers['Notes'].register_entry(self, entry)
self._entry_ids.append(entry_id)
cur.close()
- def del_entry(self, date_data):
+ def del_entry(self, entry_data):
cur = self.con.cursor()
- for (field_name, field_value) in date_data:
+ for (field_name, field_value) in entry_data:
if field_name=='_backend_entry_id':
- dateId=field_value
- # cur.execute('UPDATE dates SET deleted=1 WHERE id=?',(dateId,))
- cur.execute('DELETE FROM dates WHERE id=?',(dateId,))
- cur.execute('DELETE FROM date_values WHERE dateId=?',(dateId,))
+ entryId=field_value
+ # cur.execute('UPDATE notes SET deleted=1 WHERE id=?',(entryId,))
+ cur.execute('DELETE FROM notes WHERE id=?',(entryId,))
+ cur.execute('DELETE FROM note_values WHERE noteId=?',(entryId,))
self.con.commit()
cur.close()
- def upd_entry(self, date_data):
- reqfields = ['Begin', 'End', 'Message']
+ def upd_entry(self, entry_data):
+ reqfields = ['Timestamp', 'Timezone', 'Title', 'Content']
cur = self.con.cursor()
- for (field, value) in date_data:
+ for (field, value) in entry_data:
if field=='_backend_entry_id':
- dateId=value
- for (field, value) in date_data:
+ entryId=value
+ for (field, value) in entry_data:
if field in reqfields:
- cur.execute('UPDATE dates SET '+field+'=? WHERE id=?',(value,dateId))
+ cur.execute('UPDATE notes SET '+field+'=? WHERE id=?',(value,entryId))
elif not field.startswith('_'):
- cur.execute('SELECT id FROM date_values WHERE dateId=? AND field=?',(dateId,field))
+ cur.execute('SELECT id FROM note_values WHERE noteId=? AND field=?',(entryId,field))
if cur.fetchone() == None:
- cur.execute('INSERT INTO date_values (field,value,dateId) VALUES (?,?,?)',(field,value,dateId))
+ cur.execute('INSERT INTO note_values (field,value,noteId) VALUES (?,?,?)',(field,value,entryId))
else:
- cur.execute('UPDATE date_values SET value=? WHERE field=? AND dateId=?',(value,field,dateId))
- # cur.execute('UPDATE dates SET updated=1 WHERE id=?',(dateId,))
+ cur.execute('UPDATE note_values SET value=? WHERE field=? AND noteId=?',(value,field,entryId))
+ # cur.execute('UPDATE notes SET updated=1 WHERE id=?',(entryId,))
self.con.commit()
cur.close()
- def add_entry(self, date_data):
- date_id = self.add_date_to_db(date_data)
- return date_id
+ def add_entry(self, entry_data):
+ note_id = self.add_note_to_db(entry_data)
+ return note_id
- def add_date_to_db(self, date_data):
- reqfields = ['Begin', 'End', 'Message']
+ def add_note_to_db(self, entry_data):
+ reqfields = ['Timestamp', 'Timezone', 'Title', 'Content']
for field in reqfields:
- try:
- date_data[field]
- except KeyError:
- date_data[field]=''
+ if not entry_data.get(field):
+ entry_data[field]=''
cur = self.con.cursor()
- cur.execute('INSERT INTO dates (Begin, End, Message) VALUES (?,?,?)',(date_data['Begin'], date_data['End'], date_data['End']))
+ cur.execute('INSERT INTO notes (Timestamp, Timezone, Title, Content) VALUES (?,?,?, ?)',(entry_data['Timestamp'], entry_data['Timezone'], entry_data['Title'], entry_data['Content']))
cid = cur.lastrowid
- for field in date_data:
+ for field in entry_data:
if not field in reqfields:
- if type(date_data[field]) == Array or type(date_data[field]) == list:
- for value in date_data[field]:
- cur.execute('INSERT INTO date_values (dateId, Field, Value) VALUES (?,?,?)',(cid, field, value))
+ if type(entry_data[field]) == Array or type(entry_data[field]) == list:
+ for value in entry_data[field]:
+ cur.execute('INSERT INTO note_values (noteId, Field, Value) VALUES (?,?,?)',(cid, field, value))
else:
- cur.execute('INSERT INTO date_values (dateId, Field, Value) VALUES (?,?,?)',(cid, field, date_data[field]))
+ cur.execute('INSERT INTO note_values (noteId, Field, Value) VALUES (?,?,?)',(cid, field, entry_data[field]))
self.con.commit()
cur.close()
- date_data['_backend_entry_id']=cid
+ entry_data['_backend_entry_id']=cid
- date_id = self._domain_handlers['Dates'].register_entry(self, date_data)
- return date_id
+ note_id = self._domain_handlers['Notes'].register_entry(self, entry_data)
+ return note_id
--
FSO frameworkd Debian packaging
More information about the pkg-fso-commits
mailing list