Index: trunk/Monitoring/smon/local_repo.py
===================================================================
--- trunk/Monitoring/smon/local_repo.py	(revision 865)
+++ trunk/Monitoring/smon/local_repo.py	(revision 866)
@@ -40,5 +40,5 @@
 def create_tables():
 	_conn.execute("create table simulation (id INTEGER PRIMARY KEY, name TEXT)")
-	_conn.execute("create table message (id INTEGER PRIMARY KEY, simulation_id INT)")
+	_conn.execute("create table message (id INTEGER PRIMARY KEY, simulation_id TEXT)") # TODO: check how to use INT datatype for simulation_id column
 
 def retrieve_simulation(name):
@@ -81,5 +81,5 @@
 
 def create_message(message):
-	_conn.execute("insert into message (simulation_id) values (?)",(message.simulation_id,))
+	_conn.execute("insert into message (simulation_id) values (?)",(message.simuid,))
 
 def retrieve_last_message(simulation):
Index: trunk/Monitoring/smon/repo_io.py
===================================================================
--- trunk/Monitoring/smon/repo_io.py	(revision 865)
+++ trunk/Monitoring/smon/repo_io.py	(revision 866)
@@ -28,4 +28,241 @@
 
 
+
+
+
+# -- methods -- #
+
+def init():
+	if mode==CSTE_MODE_LOCAL_REPO:
+		repo.connect()
+	elif mode==CSTE_MODE_REMOTE_REPO:
+		_CONNECTION = "postgresql://postgres:Silence107!@localhost:5432/prodiguer"
+		prodiguer_shared.connect(_CONNECTION)
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR004 - incorrect mode")
+
+def free():
+	if mode==CSTE_MODE_LOCAL_REPO:
+		repo.close()
+	elif mode==CSTE_MODE_REMOTE_REPO:
+
+		#prodiguer_shared.close()
+		pass
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR009 - incorrect mode")
+
+def test():
+	repo.create_message("test2", 2, "bla2")
+	commit()
+
+	repo.update_simulation_status('1pctCO22', 'ERROR')
+	commit()
+
+	repo.create_message("test3", 3, "bla3")
+	rollback()
+
+def commit():
+	if mode==CSTE_MODE_LOCAL_REPO:
+		repo.commit()
+	elif mode==CSTE_MODE_REMOTE_REPO:
+		elixir.session.commit()
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR002 - incorrect mode")
+
+def rollback():
+	if mode==CSTE_MODE_LOCAL_REPO:
+		repo.rollback()
+	elif mode==CSTE_MODE_REMOTE_REPO:
+		elixir.session.rollback()
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR003 - incorrect mode")
+
+def retrieve_simulation(name):
+	simulation=None
+
+	if mode==CSTE_MODE_LOCAL_REPO:
+		simulation=repo.retrieve_simulation(name)
+	elif mode==CSTE_MODE_REMOTE_REPO:
+
+		# prepare args
+		# ..
+
+		# execute
+		s=repo.retrieve_simulation(name)
+
+		# process return values
+		simulation=smon.types.Simulation(exec_start_date=s.ExecutionStartDate,exec_end_date=s.ExecutionEndDate,status=s.ExecutionState) # ExecutionState example: EXECUTION_STATE_RUNNING, EXECUTION_STATE_SET..
+
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR014 - incorrect mode")
+
+	return simulation
+
+def delete_simulation(name):
+	if mode==CSTE_MODE_LOCAL_REPO:
+		repo.delete_simulation(name)
+	elif mode==CSTE_MODE_REMOTE_REPO:
+
+		# prepare args
+		# ..
+
+		# execute
+		repo.delete_simulation(name)
+
+		# process return values
+		# ..
+
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR015 - incorrect mode")
+
+def create_simulation(simulation):
+	if mode==CSTE_MODE_LOCAL_REPO:
+		repo.create_simulation(simulation)
+	elif mode==CSTE_MODE_REMOTE_REPO:
+
+		# prepare args
+		# ..
+
+		# execute
+		repo.create_simulation(activity)
+
+		# process return values
+		# ..
+
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR016 - incorrect mode")
+
+def update_simulation_status(simulation):
+	if mode==CSTE_MODE_LOCAL_REPO:
+		repo.update_simulation_status(simulation)
+	elif mode==CSTE_MODE_REMOTE_REPO:
+
+		# prepare args
+		# ..
+
+		# execute
+		repo.update_simulation_status(name)
+
+		# process return values
+		# ..
+
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR017 - incorrect mode")
+
+def retrieve_messages(simulation):
+	message=None
+
+	if mode==CSTE_MODE_LOCAL_REPO:
+		message=repo.retrieve_messages(simulation)
+	elif mode==CSTE_MODE_REMOTE_REPO:
+
+		# prepare args
+		# ..
+
+		# execute
+		repo.retrieve_messages(name)
+
+		# process return values
+		# ..
+
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR018 - incorrect mode")
+
+	return message
+
+def delete_messages(simulation):
+	if mode==CSTE_MODE_LOCAL_REPO:
+		repo.delete_messages(name)
+	elif mode==CSTE_MODE_REMOTE_REPO:
+
+		# prepare args
+		# ..
+
+		# execute
+		repo.delete_messages(name)
+
+		# process return values
+		# ..
+
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR019 - incorrect mode")
+
+def create_message(message):
+	if mode==CSTE_MODE_LOCAL_REPO:
+		repo.create_message(message)
+	elif mode==CSTE_MODE_REMOTE_REPO:
+
+		# prepare args
+		# ..
+
+		# execute
+		repo.create_message()
+
+		# process return values
+		# ..
+
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR020 - incorrect mode")
+
+def retrieve_last_message(simulation):
+	message=None
+
+	if mode==CSTE_MODE_LOCAL_REPO:
+		message=repo.retrieve_last_message(simulation)
+	elif mode==CSTE_MODE_REMOTE_REPO:
+
+		# prepare args
+		# ..
+
+		# execute
+		repo.retrieve_last_message(simulation)
+
+		# process return values
+		# ..
+
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
+		pass
+	else:
+		raise Exception("ERR021 - incorrect mode")
+
+	return message
+
+
+# --- higher level methods --- #
+
+def get_running_simulations():
+	running_simulation=[]
+
+	for s in retrieve_simulation():
+		if s.status=="running":
+			running_simulation.append(s)
+			
+	return running_simulation
+
+
+# --- module init --- #
+
 CSTE_MODE_LOCAL_REPO="local_repo"
 CSTE_MODE_REMOTE_REPO="remote_repo"
@@ -46,234 +283,5 @@
 
 
-
-
-# -- methods -- #
-
-def init():
-	if mode==CSTE_MODE_LOCAL_REPO:
-		local_repo.connect()
-	elif mode==CSTE_MODE_REMOTE_REPO:
-		_CONNECTION = "postgresql://postgres:Silence107!@localhost:5432/prodiguer"
-		prodiguer_shared.connect(_CONNECTION)
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR004 - incorrect mode")
-
-def free():
-	if mode==CSTE_MODE_LOCAL_REPO:
-		local_repo.close()
-	elif mode==CSTE_MODE_REMOTE_REPO:
-
-		#prodiguer_shared.close()
-		pass
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR009 - incorrect mode")
-
-def test():
-	repo.create_message("test2", 2, "bla2")
-	commit()
-
-	repo.update_simulation_status('1pctCO22', 'ERROR')
-	commit()
-
-	repo.create_message("test3", 3, "bla3")
-	rollback()
-
-def commit():
-	if mode==CSTE_MODE_LOCAL_REPO:
-		local_repo.commit()
-	elif mode==CSTE_MODE_REMOTE_REPO:
-		elixir.session.commit()
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR002 - incorrect mode")
-
-def rollback():
-	if mode==CSTE_MODE_LOCAL_REPO:
-		local_repo.rollback()
-	elif mode==CSTE_MODE_REMOTE_REPO:
-		elixir.session.rollback()
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR003 - incorrect mode")
-
-def retrieve_simulation(name):
-	simulation=None
-
-	if mode==CSTE_MODE_LOCAL_REPO:
-		simulation=repo.retrieve_simulation(name)
-	elif mode==CSTE_MODE_REMOTE_REPO:
-
-		# prepare args
-		# ..
-
-		# execute
-		s=repo.retrieve_simulation(name)
-
-		# process return values
-		simulation=smon.types.Simulation(exec_start_date=s.ExecutionStartDate,exec_end_date=s.ExecutionEndDate,status=s.ExecutionState) # ExecutionState example: EXECUTION_STATE_RUNNING, EXECUTION_STATE_SET..
-
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR014 - incorrect mode")
-
-    return simulation
-
-def delete_simulation(name):
-	if mode==CSTE_MODE_LOCAL_REPO:
-		repo.delete_simulation(name)
-	elif mode==CSTE_MODE_REMOTE_REPO:
-
-		# prepare args
-		# ..
-
-		# execute
-		repo.delete_simulation(name)
-
-		# process return values
-		# ..
-
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR015 - incorrect mode")
-
-def create_simulation(simulation):
-	if mode==CSTE_MODE_LOCAL_REPO:
-		repo.create_simulation(simulation)
-	elif mode==CSTE_MODE_REMOTE_REPO:
-
-		# prepare args
-		# ..
-
-		# execute
-		repo.create_simulation(activity)
-
-		# process return values
-		# ..
-
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR016 - incorrect mode")
-
-def update_simulation_status(simulation):
-	if mode==CSTE_MODE_LOCAL_REPO:
-		repo.update_simulation_status(simulation)
-	elif mode==CSTE_MODE_REMOTE_REPO:
-
-		# prepare args
-		# ..
-
-		# execute
-		repo.update_simulation_status(name)
-
-		# process return values
-		# ..
-
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR017 - incorrect mode")
-
-def retrieve_messages(simulation):
-	message=None
-
-	if mode==CSTE_MODE_LOCAL_REPO:
-		message=repo.retrieve_messages(simulation)
-	elif mode==CSTE_MODE_REMOTE_REPO:
-
-		# prepare args
-		# ..
-
-		# execute
-		repo.retrieve_messages(name)
-
-		# process return values
-		# ..
-
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR018 - incorrect mode")
-
-	return message
-
-def delete_messages(simulation):
-	if mode==CSTE_MODE_LOCAL_REPO:
-		repo.delete_messages(name)
-	elif mode==CSTE_MODE_REMOTE_REPO:
-
-		# prepare args
-		# ..
-
-		# execute
-		repo.delete_messages(name)
-
-		# process return values
-		# ..
-
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR019 - incorrect mode")
-
-def create_message(message):
-	if mode==CSTE_MODE_LOCAL_REPO:
-		repo.create_message(message)
-	elif mode==CSTE_MODE_REMOTE_REPO:
-
-		# prepare args
-		# ..
-
-		# execute
-		repo.create_message()
-
-		# process return values
-		# ..
-
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR020 - incorrect mode")
-
-def retrieve_last_message(simulation):
-	message=None
-
-	if mode==CSTE_MODE_LOCAL_REPO:
-		message=repo.retrieve_last_message(simulation)
-	elif mode==CSTE_MODE_REMOTE_REPO:
-
-		# prepare args
-		# ..
-
-		# execute
-		repo.retrieve_last_message(simulation)
-
-		# process return values
-		# ..
-
-	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
-		pass
-	else:
-		raise Exception("ERR021 - incorrect mode")
-
-	return message
-
-
-# --- higher level methods --- #
-
-def get_running_simulations():
-	running_simulation=[]
-
-	for s in retrieve_simulation():
-		if s.status=="running":
-			running_simulation.append(s)
-			
-	return running_simulation
+# note that by putting init() call here, it will only be called when first imported by the first import statement
+init()
+
Index: trunk/Monitoring/smon/types.py
===================================================================
--- trunk/Monitoring/smon/types.py	(revision 865)
+++ trunk/Monitoring/smon/types.py	(revision 866)
@@ -2,12 +2,12 @@
 
 ##################################
-#  @program        smon
+#  @program		   smon
 #  @description    simulation monitor
-#  @copyright      Copyright â(c)2009 Centre National de la Recherche Scientifique CNRS. 
-#                             All Rights Reservedâ
-#  @svn_file       $Id: types.py 2599 2013-03-24 19:01:23Z jripsl $
-#  @version        $Rev: 2599 $
+#  @copyright	   Copyright â(c)2009 Centre National de la Recherche Scientifique CNRS. 
+#							  All Rights Reservedâ
+#  @svn_file	   $Id: types.py 2599 2013-03-24 19:01:23Z jripsl $
+#  @version		   $Rev: 2599 $
 #  @lastrevision   $Date: 2013-03-24 20:01:23 +0100 (Sun, 24 Mar 2013) $
-#  @license        CeCILL (http://dods.ipsl.jussieu.fr/jripsl/smon/LICENSE)
+#  @license		   CeCILL (http://dods.ipsl.jussieu.fr/jripsl/smon/LICENSE)
 ##################################
 
@@ -25,35 +25,45 @@
 		self.msg=msg
 
-    def __str__(self):
-        return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
+	def __str__(self):
+		return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
 
 class Tree():
 
-    def __init__(self,**kw):
+	def __init__(self,**kw):
 		pass
 
-    def __str__(self):
-        return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
+	def __str__(self):
+		return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
 
 class Simulation():
 
-    def __init__(self,**kw):
+	def __init__(self,**kw):
 		self.exec_start_date=kw.get("exec_start_date")
 		self.exec_end_date=kw.get("exec_end_date")
 		self.status=kw.get("status")
+		self.name=kw.get("name")
 
-    def __str__(self):
-        return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
+	def __str__(self):
+		return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
+
+class Message():
+
+	def __init__(self,JSON_KW):
+		for key in JSON_KW:
+			setattr(self, key, JSON_KW[key])
+
+	def __str__(self):
+		return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
 
 class SimulationTree(Tree):
 
-    def __init__(self,**kw):
+	def __init__(self,**kw):
 		dg = nx.DiGraph()
 
 	def update(cls):
 		dg.add_edge('a','b')
-
-	def print(cls):
-		print dg.edges()
+	
+	def print__TODO(cls):
+		print dg.edges() 
 
 	def write(cls):
@@ -63,12 +73,12 @@
 		dg = pickle.load(open('/tmp/graph.txt'))
 
-    def __str__(self):
-        return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
+	def __str__(self):
+		return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
 
 class SimulationTrees():
 
-    def __init__(self,**kw):
-        self.sample=kw.get("sample",[])
+	def __init__(self,**kw):
+		self.sample=kw.get("sample",[])
 
-    def __str__(self):
-        return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
+	def __str__(self):
+		return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
