Index: trunk/Monitoring/smon/local_repo.py
===================================================================
--- trunk/Monitoring/smon/local_repo.py	(revision 865)
+++ trunk/Monitoring/smon/local_repo.py	(revision 865)
@@ -0,0 +1,95 @@
+# -*- coding: ISO-8859-1 -*-
+
+##################################
+#  @program        smon
+#  @description    simulation monitor
+#  @copyright      Copyright â(c)2009 Centre National de la Recherche Scientifique CNRS. 
+#                             All Rights Reservedâ
+#  @svn_file       $Id: repo_io.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)
+##################################
+
+import sys
+import sqlite3
+
+_conn=None
+timeout=1
+
+def connect():
+	global _conn
+
+	if _conn is not None:
+		raise Exception()
+
+	_conn=sqlite3.connect(":memory:",timeout)
+
+	create_tables()
+
+def free():
+	global _conn
+
+	if _conn is None:
+		raise Exception()
+
+	_conn.close()
+
+	_conn=None
+
+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)")
+
+def retrieve_simulation(name):
+	c=_conn.cursor()
+
+	c.execute("select name,id from simulation where name = ?",(name,))
+
+	rs=c.fetchone()
+
+	if rs is None:
+		raise Exception()
+
+	return smon.types.Simulation(id=rs[1])
+    
+def delete_simulation(simulation):
+	_conn.execute("delete from simulation where name = ?",(simulation.name,))
+
+def create_simulation(simulation):
+	_conn.execute("insert into simulation (name) values (?)",(simulation.name,))
+    
+def update_simulation_status(simulation):
+	_conn.execute("update simulation set status=? where name = ?",(simulation.status,simulation.name))
+
+def retrieve_messages(simulation):
+	li=[]
+
+	c=_conn.cursor()
+
+	_conn.execute("select id from message where simulation_id = ?",(simulation.id,))
+
+	rs=c.fetchone()
+	while rs is not None:
+		li.append(smon.types.Message(id=rs[0]))
+		rs=c.fetchone()
+
+	return li
+
+def delete_messages(simulation):
+	_conn.execute("delete from message where simulation_id = ?",(simulation.id,))
+
+def create_message(message):
+	_conn.execute("insert into message (simulation_id) values (?)",(message.simulation_id,))
+
+def retrieve_last_message(simulation):
+	c=_conn.cursor()
+
+	_conn.execute("select id, content from message where simulation_id=? order by id desc limit 1",(simulation.id,))
+
+	rs=c.fetchone()
+
+	if rs is None:
+		raise Exception()
+
+	return smon.types.Message(id=rs[0])
Index: trunk/Monitoring/smon/repo_io.py
===================================================================
--- trunk/Monitoring/smon/repo_io.py	(revision 859)
+++ trunk/Monitoring/smon/repo_io.py	(revision 865)
@@ -25,14 +25,21 @@
 import prodiguer_shared
 
+
+
+
+CSTE_MODE_LOCAL_REPO="local_repo"
+CSTE_MODE_REMOTE_REPO="remote_repo"
+CSTE_MODE_REMOTE_REPO_STUB="remote_repo_stub"
+
 # set mode
-mode="local_repo" # local_repo, remote_repo, remote_repo__stub
+mode=CSTE_MODE_LOCAL_REPO # CSTE_MODE_LOCAL_REPO, CSTE_MODE_REMOTE_REPO, CSTE_MODE_REMOTE_REPO_STUB
 
 # set repository driver
-if mode=="remote_repo__stub":
-	import prodiguer_shared.repo.mq.hooks_stub as mq_hooks
-elif mode=="remote_repo":
-	import prodiguer_shared.repo.mq.hooks as mq_hooks
-elif mode=="local_repo":
-	import local_repo_hooks as mq_hooks
+if mode==CSTE_MODE_REMOTE_REPO_STUB:
+	import prodiguer_shared.repo.mq.hooks_stub as repo
+elif mode==CSTE_MODE_REMOTE_REPO:
+	import prodiguer_shared.repo.mq.hooks as repo
+elif mode==CSTE_MODE_LOCAL_REPO:
+	import local_repo as repo
 else:
 	raise Exception("ERR001 - incorrect mode")
@@ -41,33 +48,45 @@
 
 
-
-_CONNECTION = "postgresql://postgres:Silence107!@localhost:5432/prodiguer"
+# -- methods -- #
 
 def init():
-	if mode=="local_repo":
-		pass
-	elif mode=="remote_repo":
+	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=="remote_repo__stub":
+	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():
-	mq_hooks.create_message("test2", 2, "bla2")
+	repo.create_message("test2", 2, "bla2")
 	commit()
 
-	mq_hooks.update_simulation_status('1pctCO22', 'ERROR')
+	repo.update_simulation_status('1pctCO22', 'ERROR')
 	commit()
 
-	mq_hooks.create_message("test3", 3, "bla3")
+	repo.create_message("test3", 3, "bla3")
 	rollback()
 
 def commit():
-	if mode=="local_repo":
-		pass
-	elif mode=="remote_repo":
+	if mode==CSTE_MODE_LOCAL_REPO:
+		local_repo.commit()
+	elif mode==CSTE_MODE_REMOTE_REPO:
 		elixir.session.commit()
-	elif mode=="remote_repo__stub":
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
 		pass
 	else:
@@ -75,9 +94,9 @@
 
 def rollback():
-	if mode=="local_repo":
-		pass
-	elif mode=="remote_repo":
+	if mode==CSTE_MODE_LOCAL_REPO:
+		local_repo.rollback()
+	elif mode==CSTE_MODE_REMOTE_REPO:
 		elixir.session.rollback()
-	elif mode=="remote_repo__stub":
+	elif mode==CSTE_MODE_REMOTE_REPO_STUB:
 		pass
 	else:
@@ -85,37 +104,167 @@
 
 def retrieve_simulation(name):
-	mq_hooks.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):
-	mq_hooks.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):
-	mq_hooks.create_simulation(activity,
-
-def update_simulation_status(name):
-	mq_hooks.update_simulation_status(name,
-
-def retrieve_messages(name):
-	mq_hooks.retrieve_messages(name)
-
-def delete_messages(name):
-	mq_hooks.delete_messages(name)
-
-def create_message(name):
-	mq_hooks.create_message()
-
-def retrieve_last_messages(simulation):
-	mq_hooks.retrieve_last_messages(simulation)
-
-"""
-from prodiguer_shared.models import (
-	ExecutionState,
-	EXECUTION_STATE_RUNNING,
-	EXECUTION_STATE_SET,
-	Message,
-	Simulation,
-	SIMULATION_SPACE_TEST
-)
-"""
+	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 --- #
Index: trunk/Monitoring/smon/types.py
===================================================================
--- trunk/Monitoring/smon/types.py	(revision 859)
+++ trunk/Monitoring/smon/types.py	(revision 865)
@@ -36,4 +36,14 @@
         return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
 
+class Simulation():
+
+    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")
+
+    def __str__(self):
+        return ",".join(['%s=%s'%(k,str(v)) for (k,v) in self.__dict__.iteritems()])
+
 class SimulationTree(Tree):
 
