diff --git a/src/memory/memory.py b/src/memory/memory.py index 09ac000e..a55a3ea3 100644 --- a/src/memory/memory.py +++ b/src/memory/memory.py @@ -141,7 +141,7 @@ class Params(): @param profile: profile of the profile""" #FIXME: must be asynchronous and call the callback once the profile actually exists if self.storage.hasProfile(profile): - info (_('The profile profile already exists')) + info (_('The profile [%s] already exists') % (profile,)) return True if not self.host.trigger.point("ProfileCreation", profile): return False @@ -679,7 +679,7 @@ class Memory: """Add an identity discovered from server @param feature: string of the feature @param profile: which profile is using this server ?""" - if not self.server_identities.has_key(profile): + if not profile in self.server_identities: self.server_identities[profile] = {} if not self.server_identities[profile].has_key((category, _type)): self.server_identities[profile][(category, _type)]=set() @@ -687,7 +687,7 @@ class Memory: def getServerServiceEntities(self, category, _type, profile): """Return all available entities for a service""" - if self.server_identities.has_key(profile): + if profile in self.server_identities: return self.server_identities[profile].get((category, _type), set()) else: return None diff --git a/src/memory/sqlite.py b/src/memory/sqlite.py index f1c9f74a..085d2348 100644 --- a/src/memory/sqlite.py +++ b/src/memory/sqlite.py @@ -52,13 +52,13 @@ class SqliteStorage(): "INSERT INTO message_types VALUES ('groupchat')", "INSERT INTO message_types VALUES ('headline')", "INSERT INTO message_types VALUES ('normal')", - "CREATE TABLE history (id INTEGER PRIMARY KEY ASC, profile_id INTEGER, source TEXT, dest TEXT, source_res TEXT, dest_res TEXT, timestamp DATETIME, message TEXT, type TEXT, FOREIGN KEY(profile_id) REFERENCES profiles(id), FOREIGN KEY(type) REFERENCES message_types(type))", + "CREATE TABLE history (id INTEGER PRIMARY KEY ASC, profile_id INTEGER, source TEXT, dest TEXT, source_res TEXT, dest_res TEXT, timestamp DATETIME, message TEXT, type TEXT, FOREIGN KEY(profile_id) REFERENCES profiles(id) ON DELETE CASCADE, FOREIGN KEY(type) REFERENCES message_types(type))", "CREATE TABLE param_gen (category TEXT, name TEXT, value TEXT, PRIMARY KEY (category,name))", - "CREATE TABLE param_ind (category TEXT, name TEXT, profile_id INTEGER, value TEXT, PRIMARY KEY (category,name,profile_id), FOREIGN KEY(profile_id) REFERENCES profiles(id))", + "CREATE TABLE param_ind (category TEXT, name TEXT, profile_id INTEGER, value TEXT, PRIMARY KEY (category,name,profile_id), FOREIGN KEY(profile_id) REFERENCES profiles(id) ON DELETE CASCADE)", "CREATE TABLE private_gen (namespace TEXT, key TEXT, value TEXT, PRIMARY KEY (namespace, key))", - "CREATE TABLE private_ind (namespace TEXT, key TEXT, profile_id INTEGER, value TEXT, PRIMARY KEY (namespace, key, profile_id), FOREIGN KEY(profile_id) REFERENCES profiles(id))", + "CREATE TABLE private_ind (namespace TEXT, key TEXT, profile_id INTEGER, value TEXT, PRIMARY KEY (namespace, key, profile_id), FOREIGN KEY(profile_id) REFERENCES profiles(id) ON DELETE CASCADE)", "CREATE TABLE private_gen_bin (namespace TEXT, key TEXT, value BLOB, PRIMARY KEY (namespace, key))", - "CREATE TABLE private_ind_bin (namespace TEXT, key TEXT, profile_id INTEGER, value BLOB, PRIMARY KEY (namespace, key, profile_id), FOREIGN KEY(profile_id) REFERENCES profiles(id))", + "CREATE TABLE private_ind_bin (namespace TEXT, key TEXT, profile_id INTEGER, value BLOB, PRIMARY KEY (namespace, key, profile_id), FOREIGN KEY(profile_id) REFERENCES profiles(id) ON DELETE CASCADE)", ] for op in database_creation: d = self.dbpool.runOperation(op)