From 84380cdd2fa19c5f9aad96b48d5d2fe0b4edbac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Sun, 9 Apr 2006 17:26:10 +0000 Subject: [PATCH] * add a small code piece to check key syntax --- pisi/dbshelve.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pisi/dbshelve.py b/pisi/dbshelve.py index 2927e421..0adfe8e7 100644 --- a/pisi/dbshelve.py +++ b/pisi/dbshelve.py @@ -38,6 +38,7 @@ Now added support for overriding the marshalling method import cPickle import bsddb3.db as db import bsddb3.dbobj as dbobj +import string import pisi @@ -60,6 +61,10 @@ class DBShelf: #def __del__(self): # self.close() + allowed_chars = string.letters + string.digits + '-' + def check_key(key): + return pisi.util.all(lambda x: x in allowed_chars, key) + def has_key(self, key, txn = None): if txn: return self.db.has_key(key, txn)