From 6cf487df5a57178496c57d0251ec4ecbf8d26e80 Mon Sep 17 00:00:00 2001 From: alex_nanou Date: Mon, 27 Feb 2006 16:56:19 +0000 Subject: [PATCH] *** empty log message *** --- CHANGES | 2 +- PKG-INFO | 2 +- pli/net/rpcsession.py | 9 +++++-- pli/persistance/sql/core.py | 5 ++-- pli/persistance/sql/pgsql/create_db_tables.sql | 5 ++++ pli/persistance/sql/shelve.py | 36 +++++++++++++++++++------- 6 files changed, 44 insertions(+), 15 deletions(-) diff --git a/CHANGES b/CHANGES index dd175c0..3a1dbc5 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -# this file was generated on [200601311710] +# this file was generated on [200602271954] pli changes: version 0.0.166 (200512090249): diff --git a/PKG-INFO b/PKG-INFO index 6276b2e..07cd424 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.0 Name: pli -Version: 0.0.168 +Version: 0.0.169 Summary: PLI: a utility library for the Python language. Home-page: http://pli.sourceforge.net/ Author: Alex A. Naanou diff --git a/pli/net/rpcsession.py b/pli/net/rpcsession.py index 0c38085..0bd8545 100644 --- a/pli/net/rpcsession.py +++ b/pli/net/rpcsession.py @@ -1,7 +1,7 @@ #======================================================================= __version__ = '''0.1.77''' -__sub_version__ = '''20051121203534''' +__sub_version__ = '''20060227195221''' __copyright__ = '''(c) Alex A. Naanou 2003''' @@ -319,7 +319,12 @@ class RPCSessionManager(object): ##!!! TEST !!!## if sid in self.__active_sessions__: obj = self.__active_sessions__[sid][1] - if self.__timeout__ != None \ + if self.__session_timeout__ == True \ + and None != getattr(obj, '__timeout__', -1) > 0 \ + and hasattr(obj, '_last_accessed') \ + and (time.time() - obj._last_accessed) > obj.__timeout__: + self.close_session(sid) + elif self.__timeout__ != None \ and hasattr(obj, '_last_accessed') \ and (time.time() - obj._last_accessed) > self.__timeout__: self.close_session(sid) diff --git a/pli/persistance/sql/core.py b/pli/persistance/sql/core.py index 2f6ca5e..ef210a8 100755 --- a/pli/persistance/sql/core.py +++ b/pli/persistance/sql/core.py @@ -1,7 +1,7 @@ #======================================================================= __version__ = '''0.0.01''' -__sub_version__ = '''20051012075723''' +__sub_version__ = '''20060204020843''' __copyright__ = '''(c) Alex A. Naanou 2003''' @@ -285,6 +285,7 @@ def registertablehandler(table_name): # TODO add lazy reconstruction option for mutable and deep objects... # TODO make an atomic type handler constructor... (should this be # decoratable??) +# TODO make the table names configurable.... class SQLReader(object): ''' ''' @@ -526,7 +527,7 @@ class AbstractSQLInterface(object): def write(self, a, b=None): ''' - this can one of: + this can be one of: write(obj) -> OID write(name, obj) -> OID diff --git a/pli/persistance/sql/pgsql/create_db_tables.sql b/pli/persistance/sql/pgsql/create_db_tables.sql index 7ad913d..d35a740 100755 --- a/pli/persistance/sql/pgsql/create_db_tables.sql +++ b/pli/persistance/sql/pgsql/create_db_tables.sql @@ -1,6 +1,11 @@ SET client_encoding = 'UNICODE'; -- CREATE DATABASE "poker" WITH TEMPLATE = template0 ENCODING = 'UNICODE'; +-- TODO add transaction id's to all objects (and make an object's primery key a combination of the two oid and tid...) + + + + BEGIN; -- this will provide a way to access objects in the database using simple string names. diff --git a/pli/persistance/sql/shelve.py b/pli/persistance/sql/shelve.py index 387a883..81866d4 100755 --- a/pli/persistance/sql/shelve.py +++ b/pli/persistance/sql/shelve.py @@ -1,7 +1,7 @@ #======================================================================= __version__ = '''0.0.01''' -__sub_version__ = '''20051012080046''' +__sub_version__ = '''20060204024020''' __copyright__ = '''(c) Alex A. Naanou 2003''' @@ -45,24 +45,42 @@ class SQLShelve(mapping.Mapping): def __setitem__(self, name, value): ''' ''' + interface = self._interface data = self._data - # insert the object... - oid = self._interface.write(value) - # update the keys dict... - data[name] = oid - self._interface.write(data) + try: + # insert the object... + oid = interface.write(value) + # update the keys dict... + data[name] = oid + interface.write(data) + except: +## ##!!! rollback... +## interface.__sql_reader__.sql.connection.rollback() + raise 'oops!' + # commit... + # XXX make this prittier! + interface.__sql_reader__.sql.connection.commit() ##!!! REWRITE: might be a tad cleaner... def __delitem__(self, name): ''' ''' ## return self._interface.delete(self._data.pop(name)) + interface = self._interface data = self._data - data.pop(name) - self._interface.write(data) + try: + data.pop(name) + interface.write(data) + except: +## ##!!! rollback... +## interface.__sql_reader__.sql.connection.rollback() + raise 'oops!' + # commit... + # XXX make this prittier! + interface.__sql_reader__.sql.connection.commit() def __iter__(self): ''' ''' - for name in self._data: + for name in self._data.keys(): yield name -- 2.11.4.GIT