# HG changeset patch # User Matthew Turk # Date 1230611977 28800 # Branch yt-object-serialization # Node ID 212bf834fc7f2a96f407eaca2fc11107a28c7b95 # Parent a5267c2eb1d03a1d9c8a699462c7e67533f055e0 [svn r1061] Updates to the parameter file db for some only_on_root calls, auto-initialization of the shelf, etc. I'm trying to figure out how to handle syncing; this will do for now, but it kind of stinks. Also, I think the HOP halos will have to be un-pickleable. This kind of bums me out. diff -r a5267c2eb1d03a1d9c8a699462c7e67533f055e0 -r 212bf834fc7f2a96f407eaca2fc11107a28c7b95 .bzrignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.bzrignore Mon Dec 29 20:39:37 2008 -0800 @@ -0,0 +1,4 @@ +__config__.py +build +hdf5.cfg +setuptools-0.6c9-py2.5.egg diff -r a5267c2eb1d03a1d9c8a699462c7e67533f055e0 -r 212bf834fc7f2a96f407eaca2fc11107a28c7b95 yt/fido/ParameterFileStorage.py --- a/yt/fido/ParameterFileStorage.py Fri Dec 26 07:48:22 2008 -0800 +++ b/yt/fido/ParameterFileStorage.py Mon Dec 29 20:39:37 2008 -0800 @@ -23,29 +23,11 @@ along with this program. If not, see . """ -## This is going to be the means of interacting with an SQLite (no, I repeat, -## ORM will be used here!) db in the ~/.yt/ directory where parameter files -## will be stored. It will be queried for a hash, which then gets instantiated -## and returned to the user. - -## Non-functional right now. - -## Our table layout: -## ParameterFiles -## Filename fn text -## Last known path path text -## Sim time time real -## CurrentTimeID ctid real -## Hash hash text - from yt.fido import * from yt.funcs import * import shelve import os.path -#sqlite3.register_adapter(yt.lagos.OutputTypes.EnzoStaticOutput, _adapt_pf) -#sqlite3.register_converter("pfile", _convert_pf) - class ParameterFileStore(object): _shared_state = {} @@ -57,7 +39,7 @@ return self def __init__(self, in_memory = False): - pass + only_on_root(self.__init_shelf) def _get_db_name(self): return os.path.expanduser("~/.yt/parameter_files.db") @@ -109,14 +91,23 @@ my_shelf = shelve.open(self._get_db_name(), flag='r') return my_shelf[key] - def __setitem__(self, key, val): + def __store_item(self, key, val): my_shelf = shelve.open(self._get_db_name(), 'c') my_shelf[key] = val - def __delitem__(self, key): + def __delete_item(self, key): my_shelf = shelve.open(self._get_db_name(), 'c') del my_shelf[key] + def __init_shelf(self): + shelve.open(self._get_db_name(), 'c') + + def __setitem__(self, key, val): + only_on_root(self.__store_item, key, val) + + def __delitem__(self, key): + only_on_root(self.__delete_item, key) + def keys(self): my_shelf = shelve.open(self._get_db_name(), flag='r') return my_shelf.keys()