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


Python ndb_json.toJSON函数代码示例

本文整理汇总了Python中util.ndb_json.toJSON函数的典型用法代码示例。如果您正苦于以下问题:Python toJSON函数的具体用法?Python toJSON怎么用?Python toJSON使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: get

    def get(self):

        newsInfomationId = int(self.request.get('id'))

        news = None
        publish = None
        book = None
        genko= None

        if newsInfomationId is not None:
            news = NewsInfomation.get_by_id(newsInfomationId)
            if news.publishStatus is not None:
                publish = news.publishStatus.get()
                genko = publish.genkoInfomation.get()

        res = {
                'response':{'status':200},
                'news':news,
                'publish':publish,
                'genko':genko,
              }

        logging.info(ndb_json.toJSON(res))
        self.response.content_type = 'application/json'
        self.response.write(ndb_json.toJSON(res))
开发者ID:codefreak2015,项目名称:comicnews,代码行数:25,代码来源:book.py

示例2: post

    def post(self):

        if self.invalidateSession():
            return self.returnSessionErrorResponse()
        logging.info(self.request)

        # デモアカウントは修正できない
        if self.isDemoAccount():
            res = {'response':{'status':200},'check':True}

            self.response.content_type = 'application/json'
            self.response.write(ndb_json.toJSON(res))
            return

        param = json.JSONDecoder().decode(self.request.body)

        title      = param['title']
        priceTier  = int(param['price']['value'])
        readerType = int(param['readerType']['value'])
        privateMode      = param['privateMode']
        presentOnly      = param['presentOnly']




        creatorKey = ndb.Key( urlsafe=self.session['creatorkey'] )
        genkoInfomationId = int(param['datastoreId'])


        genkoInfo = GenkoInfomation.get_by_id(genkoInfomationId)

        if genkoInfo.creatorInfomation != creatorKey:
            return self.returnSessionErrorResponse()

        genkoInfo.title = title
        genkoInfo.priceTier = priceTier
        genkoInfo.readerType = readerType
        genkoInfo.privateMode = privateMode
        genkoInfo.presentOnly = presentOnly



        genkoInfo.put()

        res = {'response':{'status':200},'check':True}

        self.response.content_type = 'application/json'
        self.response.write(ndb_json.toJSON(res))
开发者ID:codefreak2015,项目名称:comicnews,代码行数:48,代码来源:mypage.py

示例3: post

    def post(self):

        param = json.JSONDecoder().decode(self.request.body)

        id = param['id']
        hash = param['hash']

        entity = CreatorInviteMail.get_by_id(int(id))



        nowTime = datetime.now()


        res = {'response':{'status':200}}

        if  entity.hashKey==hash and nowTime < entity.expireDate:
            res['check'] = True
            res['mailaddress'] = entity.mailaddress
            res['inviteid'] = id
            res['hash'] = hash
        else:
            res['check'] = False

        self.response.content_type = 'application/json'
        self.response.write(ndb_json.toJSON(res))
开发者ID:codefreak2015,项目名称:comicnews,代码行数:26,代码来源:easyupload.py

示例4: post

    def post(self):

        param = json.JSONDecoder().decode(self.request.body)
        logging.info(param)

        mailaddress = param['mailaddress']
        password = Common.toPasswordHash(param['loginkey'])

        logging.info(mailaddress)
        logging.info(password)

        acc = AccountRoot.query(AccountRoot.mailaddress==mailaddress).get()


        res = {}
        res['check'] = acc.password == password
        res['response'] = {'status':200}

        if res['check']:
            self.startSession()
            self.session['creatorkey'] = acc.creatorInfomation.urlsafe()
            self.session['mailaddress'] = acc.mailaddress
            self.session['creatorname'] = acc.creatorInfomation.get().name

        self.response.content_type = 'application/json'
        self.response.write(ndb_json.toJSON(res))
开发者ID:codefreak2015,项目名称:comicnews,代码行数:26,代码来源:account.py

示例5: post

    def post(self):

        param = json.JSONDecoder().decode(self.request.body)
        logging.info(param)

        entity = None
        if  param.has_key('datastoreId') and param['datastoreId'] != "":
            entity =  NewsInfomation.get_by_id(int(param['datastoreId']))
        else:
            entityId =  NewsInfomation.allocate_ids(size=1)[0]
            entity = NewsInfomation(id=entityId)

        # 時刻は日本時間で入力されたものを標準時間に変更するので9時間減らす
        entity.releaseDate= datetime.strptime(param['releaseDate'],'%Y-%m-%d %H:%M:%S') - timedelta(hours=9)
        entity.headline= param['headline']
        entity.type    = param['type']

        if 'typeParam' in param:
            entity.typeParam   = param['typeParam']

        if 'image' in param:
            entity.image   = param['image']

        if 'publishid' in param:
            entity.publishStatus = ndb.Key("PublishStatus",int(param['publishid']))

        entity.put()

        res = {
                'response':{'status':200},
                'entity':entity,
              }

        self.response.content_type = 'application/json'
        self.response.write(ndb_json.toJSON(res))
开发者ID:codefreak2015,项目名称:comicnews,代码行数:35,代码来源:book.py

示例6: get

    def get(self):
        logging.info(self.request)

        if self.invalidateSession():
            return self.returnSessionErrorResponse()

        creatorKey = ndb.Key( urlsafe=self.session['creatorkey'] )

        creatorinfomation = creatorKey.get()
        creatorinfomationdetail = CreatorInfomationDetail.get_by_id(CreatorInfomationDetail.createIdFromInteger(creatorKey.id()))

        #qe = ndb.AND(CreatorPointTransaction.creatorInfomation==creatorKey)
        #transList, next_curs, more     = CreatorPointTransaction.query(qe).order(-GenkoInfomation.insertDate).fetch_page(10)


        conn = Common.getSqlConnection()
        cursor = conn.cursor()

        pointReflashCommand = "SELECT SUM(rebate)-SUM(withdraw)-SUM(fee) FROM pointtransaction where creatorinfomationid=%d" % (creatorinfomation.key.id())
        logging.info(pointReflashCommand)
        cursor.execute(pointReflashCommand)
        pointTotal = cursor.fetchall()

        requestCommand = "select action,withdraw,insertdate from pointtransaction where withdraw > 0 and creatorinfomationid=%d order by insertdate desc" % (creatorinfomation.key.id())
        logging.info(requestCommand)
        cursor.execute(requestCommand)
        requestRows = cursor.fetchall()

        conn.commit()
        conn.close()
        logging.info(requestRows)

        transList = []
        for row in requestRows:
            element = {
                'action':row[0],
                'withdraw':int(row[1]),
                'insertDate':calendar.timegm(row[2].utctimetuple())
            }
            transList.append(element)
        logging.info(transList)

        creatorpoint = 0
        if pointTotal[0][0] is not None:
            creatorpoint = int(pointTotal[0][0])

        res =   {
                'response':{'status':200},
                'creator': creatorinfomation,
                'transactions':transList,
                'emptyDetail':creatorinfomationdetail is None,
                'point': creatorpoint
                }
        logging.info(res)

        self.response.content_type = 'application/json'
        self.response.write(ndb_json.toJSON(res))
开发者ID:codefreak2015,项目名称:comicnews,代码行数:57,代码来源:mypage.py

示例7: get

    def get(self):
        self.createUserData()

        res =   {
                'result':True,
                }

        self.response.content_type = 'application/json'
        self.response.write(ndb_json.toJSON(res))
开发者ID:codefreak2015,项目名称:comicnews,代码行数:9,代码来源:entitygenerate.py

示例8: post

    def post(self):

        res = {
                'contentName':'デモファイル',
                'contentKey':'demodemo'
            }
        logging.info(res)

        self.response.content_type = 'application/json'
        self.response.write(ndb_json.toJSON(res))
开发者ID:codefreak2015,项目名称:comicnews,代码行数:10,代码来源:upload.py

示例9: get

    def get(self):

        upload_url = blobstore.create_upload_url('/creator/api/easyupload/contributesubmit')

        res = {
                'uploadurl':upload_url
            }
        logging.info(upload_url)

        self.response.content_type = 'application/json'
        self.response.write(ndb_json.toJSON(res))
开发者ID:codefreak2015,项目名称:comicnews,代码行数:11,代码来源:easyupload.py


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