python keys模块_Python flask.session 模块,keys() 实例源码 - 编程字典

def display_data(url):

page_init()

deletable = None

db = get_db()

cur = db.cursor()

cur.execute('SELECT '+database_fields+' FROM playerinfo WHERE url='+app.sqlesc+'',(url,))

data = cur.fetchall()

if len(data) != 1:

g.error = _('There is nothing here... is this URL correct?')

if str(url) != 'favicon.ico':

cur.execute('INSERT INTO errors (ip, time, notes) VALUES ('+app.sqlesc+','+app.sqlesc+','+app.sqlesc+')',(request.environ['REMOTE_ADDR'],time.time(),str(len(data))+' cur.fetchall() for url:'+str(url)))

db.commit()

return render_template("error.html", **page_args())

else:

cur.execute('UPDATE playerinfo SET views=views+1 WHERE url='+app.sqlesc+'',(url,))

db.commit()

datadict = {}

for k, key in enumerate(sorted(database_structure_dict.keys())):

if key != 'farm_info':

datadict[key] = data[0][k]

claimable = False

deletable = False

if datadict['owner_id'] == None:

if url in session and url+'del_token' in session and session[url] == datadict['md5'] and session[url+'del_token'] == datadict['del_token']:

if logged_in():

claimable = True

else:

deletable = True

elif logged_in() and str(datadict['owner_id']) == str(get_logged_in_user()):

deletable = True

# other_saves, gallery_set = get_others(datadict['url'],datadict['date'],datadict['map_url'])

other_saves, gallery_set = get_others(datadict['url'],get_date(datadict),datadict['map_url'])

for item in ['money','totalMoneyEarned','statsStepsTaken','millisecondsPlayed']:

if item == 'millisecondsPlayed':

datadict[item] = "{:,}".format(round(float((int(datadict[item])/1000)/3600.0),1))

else:

datadict[item] = "{:,}".format(datadict[item])

datadict['animals'] = None if datadict['animals']=='{}' else json.loads(datadict['animals'])

datadict['portrait_info'] = json.loads(datadict['portrait_info'])

friendships = sorted([[friendship[11:],datadict[friendship]] for friendship in sorted(database_structure_dict.keys()) if friendship.startswith('friendships') and datadict[friendship]!=None],key=lambda x: x[1])[::-1]

kills = sorted([[kill[27:].replace('_',' '),datadict[kill]] for kill in sorted(database_structure_dict.keys()) if kill.startswith('statsSpecificMonstersKilled') and datadict[kill]!=None],key=lambda x: x[1])[::-1]

if datadict['imgur_json']!=None:

datadict['imgur_json'] = json.loads(datadict['imgur_json'])

# passworded = True if datadict['del_password'] != None else False

# passworded=passworded, removed from next line

claimables = find_claimables()

vote = json.dumps({url:get_votes(url)})

if logged_in() == False and len(claimables) > 1 and request.cookies.get('no_signup')!='true':

flash({'message':'

'+_("It looks like you have uploaded multiple files, but are not logged in: if you sign up or sign in you can link these uploads, enable savegame sharing, and one-click-post farm renders to imgur!")+'

'.format(url_for('signup'),url_for('login')),'cookie_controlled':'no_signup'})

return render_template("profile.html", deletable=deletable, claimable=claimable, claimables=claimables, vote=vote,data=datadict, kills=kills, friendships=friendships, others=other_saves, gallery_set=gallery_set, **page_args())

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值