X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=monitor%2Fdatabase%2Fdbpickle.py;h=f7db4803a677b53eda084ae61fc1415f0f474c33;hb=0a896f10303078562b737c83fd08dc25f0973c58;hp=074ff68e2db943c222db0f5463e7e0d5ed0210a7;hpb=7b3d462aa05fcc1892fd914db163143f36a05945;p=monitor.git diff --git a/monitor/database/dbpickle.py b/monitor/database/dbpickle.py index 074ff68..f7db480 100644 --- a/monitor/database/dbpickle.py +++ b/monitor/database/dbpickle.py @@ -22,11 +22,19 @@ def lastModified(name, type=None): t = SPickle().mtime("production.%s" % name, type) return t +def escapeName(name): + """ + automatically escape names passed to the db to make sensible-filenames without + exposing this to users. + """ + return name.replace("/", "_") + def cachedRecently(name, length=int(config.cachetime), type=None): """ return true or false based on whether the modified time of the cached file is within 'length' minutes. """ + name = name.replace("/", "_") if hasattr(config, 'cachecalls') and not config.cachecalls: # don't use cached calls if cachecalls is false return False @@ -44,14 +52,15 @@ def cachedRecently(name, length=int(config.cachetime), type=None): return True def dbLoad(name, type=None): + name = escapeName(name) return SPickle().load(name, type) def dbExists(name, type=None): - #if self.config.debug: - # name = "debug.%s" % name + name = escapeName(name) return SPickle().exists(name, type) def dbDump(name, obj=None, type=None): + name = escapeName(name) # depth of the dump is 2 now, since we're redirecting to '.dump' return SPickle().dump(name, obj, type, 2) @@ -119,7 +128,7 @@ class SPickle: Otherwise, it's normal mode, if the file doesn't exist, raise error Load the file """ - print "loading %s" % name + #print "loading %s" % name if config.debug: if self.exists("debug.%s" % name, type):