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


Python Movie.created_on方法代码示例

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


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

示例1: callback_post

# 需要导入模块: from models import Movie [as 别名]
# 或者: from models.Movie import created_on [as 别名]
def callback_post():
    LOGGER.info('Logging Request: METHOD: ' + request.method + ' => ROUTE: /api/movies')
    response.set_header('Date', DATETIMESTAMP)

    try:
        accept = request.headers.get('Accept')
        response.set_header('Content-Type', determine_response_content_type(accept))

        if 'application/json' not in request.headers.get(
                'Content-Type') and 'application/vnd.collection+json' not in request.headers.get('Content-Type'):
            LOGGER.error('Unsupported media type sent')
            response.status = 415
            response_body = ErrorCJ(ROOT, 'Invalid Content-Type', 415,
                                    'application/json and application/vnd.collection+json supported')
            return response_body.to_json()

        request_json = json_loads(request._get_body_string())
        if not request_json:
            raise Exception

        # debug
        # print request_json

        # connect to mongodb
        mongoengine.connect('api')

        movie_dict = dict()
        for item in request_json["template"]["data"]:
            movie_dict[item["name"]] = item["value"]

        # new movie
        movie = Movie()
        movie.sysid = str(uuid.uuid4()).replace("-", "")
        movie.created_on = datetime.datetime.now
        movie.updated_on = datetime.datetime.now
        movie.decode(movie_dict)
        movie.save()

        # send the response
        response.set_header('Location', ROOT + 'movies/' + movie.sysid)
        response.status = 201
        movie = None
        return

    except Exception as e:
        LOGGER.error('Unexpected exception ' + str(e))
        response.status = 500
        response_body = ErrorCJ(ROOT, 'Error Title', 500, str(e))
        return response_body.to_json()
开发者ID:bryanbarnard,项目名称:ISWQ2014,代码行数:51,代码来源:app.py


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