Пример #1
0
 def create_section(self, section_obj, experiment):
     print "   Building section %s" % section_obj.title.text
     sec = GwoSection(
         gwo_experiment=experiment,
         title=getattr(section_obj.title, 'text', ''),
         begin_script=getattr(section_obj.section_begin_script, 'text', ''),
         end_script=getattr(section_obj.section_end_script, 'text', ''),
         section_id=getattr(section_obj.section_id, 'text', ''),
     )
     sec.save(local_only=True)
     
     print "   Pulling Variations"
     var_feed = self.client.get_variations(client.VariationQuery(section_obj))
     
     for var_obj in var_feed.entry:
         self.create_variation(var_obj, sec)
Пример #2
0
 def sync_section(self, section_obj, exp_obj):
     try:
         section = GwoSection.objects.get(
             gwo_experiment=exp_obj,
             section_id=section_obj.section_id.text
         )
         created = False
     except GwoSection.DoesNotExist:
         section = GwoSection(
             gwo_experiment=exp_obj,
             section_id=section_obj.section_id.text
         )
         created = True
     if created:
         print "   Building section %s" % section_obj.title.text
     else:
         print "   Updating section %s" % section_obj.title.text
     
     section.title = section_obj.title.text
     section.begin_script = getattr(section_obj.section_begin_script, 'text', '')
     section.end_script = getattr(section_obj.section_end_script, 'text', '')
     section.save(local_only=True)
     
     print "   Pulling Variations"
     try:
         var_feed = self.client.get_variations(client.VariationQuery(section_obj))
     except Exception, e:
         print "   Error pulling variations"
         return