コード例 #1
0
    def export_from_mysql(self):
        exporter = Exporter("examplestore.xml")

        for product in self.session.query(Product):
            item = Item(exporter.database, "product%s" % product.id)
            item.add_tag("product")
            exporter.export(item)

        for customer in self.session.query(Customer):
            item = Item(exporter.database, "customer%s" % customer.id)
            item.add_tag("customer")
            for purchase in self.session.query(Purchase).filter_by(
                    customer=customer.id):
                item.link_to("product%s" % purchase.product)
            exporter.export(item)

        exporter.finish()
コード例 #2
0
    def export_from_mysql(self):
        exporter = Exporter("examplestore.xml")

        for product in self.session.query(Product):
            item = Item(exporter.database, "product%s" % product.id)
            item.add_tag("product")
            exporter.export(item)
            
        for customer in self.session.query(Customer):
            item = Item(exporter.database, "customer%s" % customer.id)
            item.add_tag("customer")
            for purchase in self.session.query(Purchase).filter_by(customer=customer.id):
                item.link_to("product%s" % purchase.product)
            exporter.export(item)

        exporter.finish()
コード例 #3
0
    def export_to_xml(self, users):
        exporter = Exporter('recommendstore.xml')
        # loop thru users and words
        k_exist = []
        for u in users:
            #pitem = Item(exporter.database,u.twitter)
            #pitem.add_tag('person')
            #exporter.export(pitem)
            for k in u.bio_kws:
                if k not in k_exist:
                    item = Item(exporter.database, "k_%s" % k)
                    item.add_tag('keyword')
                    k_exist.append(k)
                    exporter.export(item)

        #re-loop!!
        for u in users:
            pitem = Item(exporter.database, u.twitter)
            pitem.add_tag('person')
            for k in u.bio_kws:
                pitem.link_to("k_%s" % k)
            exporter.export(pitem)

        exporter.finish()
コード例 #4
0
    def export(self):
        exporter = Exporter("graphstore.xml")
        for story in Story.objects.all():
            item = Item(exporter.database, "story%s" % story.id)
            item.add_tag("story")
            exporter.export(item)

        from django.contrib.auth.models import User
        for user in User.objects.all():
            item = Item(exporter.database, "user%s" % user.id)
            item.add_tag("user")
            for story in user.liked.all():
                item.link_to("story%s" % story.id)
            exporter.export(item)
        
        from tagging.models import Tag
        for tag in Tag.objects.all():
            item = Item(exporter.database, "tag%s" % tag.id)
            item.add_tag("tag")
            for tagged_item in tag.items.all():
                item.link_to("story%s" % tagged_item.object.id)
        
        exporter.finish()
コード例 #5
0
  def export_to_xml(self,users):
    exporter = Exporter('recommendstore.xml')
    # loop thru users and words
    k_exist = []
    for u in users:
      #pitem = Item(exporter.database,u.twitter)
      #pitem.add_tag('person')
      #exporter.export(pitem)
      for k in u.bio_kws:
        if k not in k_exist:
          item = Item(exporter.database,"k_%s" % k)
          item.add_tag('keyword')
          k_exist.append(k)
          exporter.export(item)

    #re-loop!!
    for u in users:
      pitem = Item(exporter.database,u.twitter)
      pitem.add_tag('person')
      for k in u.bio_kws:
        pitem.link_to("k_%s" % k)
      exporter.export(pitem)

    exporter.finish()