示例#1
0
 def set_key(self, classifier, key, value):
     """
     Set the value held by the classifier, key composite key.
     """
     session = self.sessionFactory()
     store = Store()
     value = json.dumps(value)
     store.value = value
     store.key = key
     store.classifier = classifier
     session.merge(store)
     session.commit()
示例#2
0
 def set_key_list(self, classifier, key_value_tuples):
     """
     Given a list of tuples of classifier, key, value set them all.
     It is more efficient to use one session and merge all of the objects
     at once than to merge them individually.
     """
     session = self.sessionFactory()
     for key, value in key_value_tuples:
         store = Store()
         value = json.dumps(value)
         store.value = value
         store.key = key
         store.classifier = classifier
         session.merge(store)
     session.commit()