コード例 #1
0
ファイル: config.py プロジェクト: yudai09/niftycloud
 def dump_to_sdb(self, domain_name, item_name):
     from niftycloud.compat import json
     sdb = niftycloud.connect_sdb()
     domain = sdb.lookup(domain_name)
     if not domain:
         domain = sdb.create_domain(domain_name)
     item = domain.new_item(item_name)
     item.active = False
     for section in self.sections():
         d = {}
         for option in self.options(section):
             d[option] = self.get(section, option)
         item[section] = json.dumps(d)
     item.save()
コード例 #2
0
ファイル: config.py プロジェクト: yudai09/niftycloud
 def load_from_sdb(self, domain_name, item_name):
     from niftycloud.compat import json
     sdb = niftycloud.connect_sdb()
     domain = sdb.lookup(domain_name)
     item = domain.get_item(item_name)
     for section in item.keys():
         if not self.has_section(section):
             self.add_section(section)
         d = json.loads(item[section])
         for attr_name in d.keys():
             attr_value = d[attr_name]
             if attr_value is None:
                 attr_value = 'None'
             if isinstance(attr_value, bool):
                 self.setbool(section, attr_name, attr_value)
             else:
                 self.set(section, attr_name, attr_value)