• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python serializers.json函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: insert_hq

def insert_hq():
    insert = request.vars.insert
    data = {'title' : request.vars.hq_title,
            'description' : request.vars.hq_description,
            'year' : request.vars.hq_year,
            'characters' : json2.loads(request.vars.hq_character)}
    if insert == 'true':
        if len(db.executesql("SELECT id FROM hq WHERE hq_title='{0}' AND deleted='F'".format(data['title']),as_dict=True)) == 0:
            query = """INSERT INTO hq (created, hq_title, hq_description, hq_year, deleted)
                        VALUES ('{0}', '{1}', '{2}', '{3}', 'F') RETURNING id""".format(request.now, data['title'], data['description'], data['year'])
        else:
            return XML(json('erro'))
    else:
        item_edit = request.vars.item_edit
        if len(db.executesql("SELECT id FROM hq WHERE hq_title='{0}' AND id != {1} AND deleted='F'".format(data['title'],item_edit),as_dict=True)) == 0:
            query = """UPDATE hq SET hq_title='{0}', hq_description='{1}', hq_year='{2}' WHERE id={3} RETURNING id""".format(data['title'],
                                                                                                                             data['description'],
                                                                                                                             data['year'],
                                                                                                                             item_edit)
        else:
            return XML(json('erro'))
    try:
        id_hq = db.executesql(query,as_dict=True)
        id_hq = id_hq[0]['id']
        if insert == 'true':
            for c in data['characters']:
                db.executesql("""INSERT INTO hq_character (created, marvel_character, hq, deleted)
                                    VALUES ('{0}', {1}, {2}, 'F')""".format(request.now, c, id_hq))
        else:
            aux = ''
            for c in data['characters']:
                aux += c + ','
                if len(db.executesql("""SELECT id FROM hq_character 
                                        WHERE hq={0} AND marvel_character={1} AND deleted='F'""".format(id_hq, c),as_dict=True)) == 0:
                    db.executesql("""INSERT INTO hq_character (created, marvel_character, hq, deleted)
                                    VALUES ('{0}', {1}, {2}, 'F')""".format(request.now, c, id_hq))
            aux = aux[0:-1]
            db.executesql("UPDATE hq_character SET deleted='T' WHERE hq={0} AND marvel_character NOT IN ({1})".format(id_hq, aux))
                
                    
        ret = {'hqs' : db.executesql("SELECT id, hq_title, hq_description, hq_year FROM hq WHERE deleted='F'",as_dict=True),
               'hqs_characters' : db.executesql("SELECT id, marvel_character, hq FROM hq_character WHERE deleted='F'",as_dict=True)}
        db.commit()
    except Exception as wE:
        db.rollback()
        ret = 'erro'
            
    return XML(json(ret))
开发者ID:PedroPH,项目名称:marvel_guide,代码行数:48,代码来源:backcall.py


示例2: autotags

def autotags():
    from serializers import json
    key = request.vars.term
    limit = int(request.vars.limit or 10)
    rows = db(db.tag.name.startswith(key)).select(
        db.tag.id,db.tag.name,distinct=True,limitby=(0,limit))
    items = [dict(id=r.id,value=r.name,label=r.name) for r in rows]
    return json(items)
开发者ID:adesst,项目名称:w2cms,代码行数:8,代码来源:default.py


示例3: autogroups

def autogroups():
    from serializers import json
    key = request.vars.term
    limit = int(request.vars.limit or 10)
    group = db.auth_group
    rows = db(group.role.startswith(key)).select(
        group.id,group.role,limitby=(0,limit))
    items = [dict(id=r.id,value=r.role,label=r.role) for r in rows]
    if 'everybody'.startswith(key):
        items.insert(0,dict(id=0, value='everybody',label='everybody'))
    return json(items)
开发者ID:adesst,项目名称:w2cms,代码行数:11,代码来源:default.py


示例4: verification_person

def verification_person():
    keypoint = request.vars.keypoints
    session.current_company_id = 1
    query = """
        SELECT id,created, last_update, full_name, birth_date,cpf,rg,email,keypoints1,keypoints2,sex,street_number,
        comp_person,neigh,street,zipcode,marital_status,deleted,cellphone,city_person
        FROM auth_user
        WHERE deleted='F'"""
    
    person_data = db.executesql(query,as_dict=True)
    if person_data != None or person_data != '':
        for i in range(0,len(person_data)):
            get_person = authentication(person_data[i]['keypoints1'],person_data[i]['keypoints2'],keypoint)
            if get_person == 1:
                session.full_name = person_data[0]['full_name']
                return XML(json({'info':'OK', 'person':person_data[0]}))
            else:
                return XML(json({'info':'Ocorreu um erro! Tente Novamente!', 'person':''}))
    else:
        return XML(json({'info':'Ocorreu um erro! Tente Novamente!', 'person':''}))
开发者ID:SamaraCardoso27,项目名称:TG-Web,代码行数:20,代码来源:default.py


示例5: delete_hq

def delete_hq():
    id_del = request.vars.delete
    try:
        db.executesql("UPDATE hq SET deleted='T' WHERE id={0}".format(id_del))
        ret = {'hqs' : db.executesql("SELECT id, hq_title, hq_description, hq_year FROM hq WHERE deleted='F'",as_dict=True),
               'hqs_characters' : db.executesql("SELECT id, marvel_character, hq FROM hq_character WHERE deleted='F'",as_dict=True)}
        db.commit()
    except Exception as wE:
        db.rollback()
        ret = 'erro'
    
    return XML(json(ret))
开发者ID:PedroPH,项目名称:marvel_guide,代码行数:12,代码来源:backcall.py


示例6: insert_news

def insert_news():
    news = {'title' : request.vars['data[news_title]'],
            'link'  : request.vars['data[news_url]'],
            'text'  : request.vars['data[news_text]']}
    insert = request.vars.insert
    try:
        if insert == 'true':
            query = """INSERT INTO news (created, news_title, news_url, news_text, deleted) 
                            VALUES (now(), '{0}', '{1}', '{2}', 'F')""".format(news['title'], news['link'], news['text'])
        else:
            query = """UPDATE news SET news_title='{0}', news_url='{1}', news_text='{2}'
                            WHERE id={3}""".format(news['title'], news['link'], news['text'], insert)
        db.executesql(query)
        db.commit()
        return ''
    except Exception as wE:
        db.rollback()
        ret = 'erro'
        return XML(json(ret))
开发者ID:PedroPH,项目名称:marvel_guide,代码行数:19,代码来源:backcall.py


示例7: json

 def json(self, data):
     return json(data)
开发者ID:ramanan12345,项目名称:fog-web2py,代码行数:2,代码来源:globals.py


示例8: getNews

def getNews():
    news = db.executesql("""SELECT id, news_title, created, news_text, news_url, deleted, news_image2, news_image3, news_image1
                                            FROM news WHERE deleted='F'""",as_dict=True)
    return XML(json(news))
开发者ID:PedroPH,项目名称:marvel_guide,代码行数:4,代码来源:backcall.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python serializers.UserSerializer类代码示例发布时间:2022-05-27
下一篇:
Python serializer.Serializer类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap