示例#1
0
 def store(self, instance):
     written = {}
     persistent = IPersistentObject(instance)
     oid = persistent.get_oid()
     instance = persistent.get_object()
     print 'Store %s with OID %s' % (instance, oid)
     transformation_writer = self.writer_factory(instance)
     transformation_writer.set_manager(self)
     for instance in transformation_writer:
         persistent = IPersistentObject(instance)
         oid = persistent.get_oid()
         if written.has_key(oid):
             continue
         if persistent.is_persistent() and not persistent.is_saved():
             instance = persistent.get_object()
             transformation = transformation_writer.write(instance)
             print '\t-> storing %s with OID %s' % (instance, oid)
             self.storage.store_record(oid, transformation)
             written[oid] = None
             persistent.set_saved()
             self.cache.add_instance(oid, instance)
         else: print '\t-> not storing %s with OID %s' % (instance, oid)
示例#2
0
 def store(self, instance):
     written = {}
     persistent = IPersistentObject(instance)
     oid = persistent.get_oid()
     instance = persistent.get_object()
     print 'Store %s with OID %s' % (instance, oid)
     transformation_writer = self.writer_factory(instance)
     transformation_writer.set_manager(self)
     for instance in transformation_writer:
         persistent = IPersistentObject(instance)
         oid = persistent.get_oid()
         if written.has_key(oid):
             continue
         if persistent.is_persistent() and not persistent.is_saved():
             instance = persistent.get_object()
             transformation = transformation_writer.write(instance)
             print '\t-> storing %s with OID %s' % (instance, oid)
             self.storage.store_record(oid, transformation)
             written[oid] = None
             persistent.set_saved()
             self.cache.add_instance(oid, instance)
         else:
             print '\t-> not storing %s with OID %s' % (instance, oid)
示例#3
0
 def load(self, oid):
     print 'Loading %s' % oid
     instance = self.cache.get_instance(oid, None)
     if instance is None or isinstance(instance, DeferredObject):
         transformation = self.storage.load_record(oid)
         instance = self._transformation_reader.read(transformation)
         persistent = IPersistentObject(instance)
         self._configure_persistence(persistent, oid)
         persistent.set_loaded()
         persistent.set_saved()
         instance = persistent.get_object()
     else: 
         print '\tloaded from cache!'
     print '\tload(%s) -> %s' % (oid, instance)
     return instance
示例#4
0
 def load(self, oid):
     print 'Loading %s' % oid
     instance = self.cache.get_instance(oid, None)
     if instance is None or isinstance(instance, DeferredObject):
         transformation = self.storage.load_record(oid)
         instance = self._transformation_reader.read(transformation)
         persistent = IPersistentObject(instance)
         self._configure_persistence(persistent, oid)
         persistent.set_loaded()
         persistent.set_saved()
         instance = persistent.get_object()
     else:
         print '\tloaded from cache!'
     print '\tload(%s) -> %s' % (oid, instance)
     return instance