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


Python Event.save方法代码示例

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


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

示例1: post

# 需要导入模块: from model.event import Event [as 别名]
# 或者: from model.event.Event import save [as 别名]
 def post(self):
     args = event_parser.parse_args()
     newEvent = Event(
         tag = args.tag,
         name = args.name,
         description = args.description,
         venue = Venue.query.get_by_name(args.venue["name"]),
         time = args.time,
         date = args.date,
         image = args.image,
         gests = map(lambda gest: gest["username"], args.gests),
         requirement = map(lambda req: Requirement(name=req["name"],quantity=req["quantity"]), args.requirement),
         capacity = args.capacity,
         visibility = Visibility.query.get(args.visibility),
         owner = currentUser()
     )
     newEvent.save()
     log.info("Crea un Evento con: {'tag':'%s'}" % newEvent.tag)
     return newEvent, 201
开发者ID:arq1nnySu,项目名称:enjoy-events-back,代码行数:21,代码来源:eventService.py

示例2: get_topnews

# 需要导入模块: from model.event import Event [as 别名]
# 或者: from model.event.Event import save [as 别名]
    def get_topnews(results=8):
        URL = "https://ajax.googleapis.com/ajax/services/search/news?v=1.0&ned=%s&topic=%s&rsz=%d"
        editions = ("es_cl", "en_us")
        topics = {"w": "Internacional", "h": "Titulares"}
        i = 0

        for edition in editions:
            for topic in topics:
                url = URL % (edition, topic, results)
                print F, url
                response = urllib2.urlopen(url)
                data = response.read()

                news = json.loads(data)
                if news["responseStatus"] == 200:
                    for result in news["responseData"]["results"]:
                        data = {}

                        data["title"] = result["titleNoFormatting"]
                        data["locale"] = edition
                        data["date"] = result["publishedDate"]
                        data["url"] = result["url"]
                        data["type"] = "news"
                        data["id"] = md5(data["url"]).hexdigest()
                        data["content"] = ""

                        event = {}
                        event["title"] = data["title"]
                        event["locale"] = data["locale"]
                        event["description"] = result["content"]
                        event["date"] = data["date"]
                        e_id = event["id"] = md5("%s %s" % (repr(data["title"]), data["url"])).hexdigest()

                        print F, repr("Crawled news: %s" % data["title"])
                        e = Event(event)
                        e.save()

                        n = Page(data)
                        n.parent_id = e_id
                        n.save()

                        if result.has_key("relatedStories"):
                            for related in result["relatedStories"]:
                                data = {}
                                data["title"] = related["titleNoFormatting"]
                                data["locale"] = edition
                                data["date"] = related["publishedDate"]
                                data["url"] = related["url"]
                                data["id"] = md5(data["url"]).hexdigest()
                                data["type"] = "news"
                                data["content"] = ""

                                print F, repr("Related news: %s" % data["title"])
                                n = Page(data)
                                n.parent_id = e_id
                                n.save()
                                i += 1
                else:
                    print F, news["responseDetails"]

        print F, "total news collected: %d" % i
开发者ID:mquezada,项目名称:cc6909,代码行数:63,代码来源:google_news.py


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