当前位置: 首页>>代码示例>>Python>>正文


Python Website.delete方法代码示例

本文整理汇总了Python中mkt.websites.models.Website.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Website.delete方法的具体用法?Python Website.delete怎么用?Python Website.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mkt.websites.models.Website的用法示例。


在下文中一共展示了Website.delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_instances

# 需要导入模块: from mkt.websites.models import Website [as 别名]
# 或者: from mkt.websites.models.Website import delete [as 别名]
    def create_instances(self, data):
        created_count = 0
        for i, row in enumerate(data):
            name = self.clean_string(row["Name"])
            if not name:
                continue

            try:
                url = self.clean_string(row["URL"])
                website = Website.objects.get(url=url)
                print "Game with URL %s already exists. Continuing." % url
                continue
            except Website.DoesNotExist:
                pass

            with atomic():
                try:
                    website = Website(
                        categories=["games"],
                        devices=[DEVICE_DESKTOP.id],
                        description=self.clean_string(row["Description"]),
                        name=name,
                        status=STATUS_PUBLIC,
                    )
                    self.set_url(website, row)
                    website.save()

                    # Keywords use a M2M, so do that once the website is saved.
                    self.set_tags(website, row)

                    # Launch task to fetch imgs once we know everything is OK.
                    try:
                        self.set_icon(website, row)
                        self.set_promo_imgs(website, row)
                        WebsiteIndexer.index_ids([website.id], no_delay=True)
                    except Exception as e:
                        print e
                        WebsiteIndexer.refresh_index()
                        website.delete()
                        raise e

                    created_count += 1
                except ParsingError as e:
                    print e.message
        return created_count
开发者ID:jostw,项目名称:zamboni,代码行数:47,代码来源:import_games_from_csv.py


注:本文中的mkt.websites.models.Website.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。