def post(self): #判断是否存在# newUser = self.request.get('username').strip('\n') try: int(newUser) int(self.request.get('password')) except : self.response.out.write("<script>alert('用户名和密码为数字!');</script>") url = self.request.url template_values = {'url':url,} self.render('template/user/userAdd.html',template_values) return if int(newUser)>999: self.response.out.write("<script>alert('用户名必须小于1000!');</script>") url = self.request.url template_values = {'url':url,} self.render('template/user/userAdd.html',template_values) return users=User.get_by_keyname('u'+newUser) if users: self.response.out.write("<script>alert('用户名已存在!');</script>") url = self.request.url template_values = {'url':url,} self.render('template/user/userAdd.html',template_values) else: user = User(key_name='u'+str(len(newUser))+'u'+newUser) user.userName = newUser user.passWord = self.request.get('password').strip('\n') repassWord = self.request.get('repassword').strip('\n') user.trueName = self.request.get('truename').strip('\n') user.tele = self.request.get('telephone').strip('\n') user.mobile = self.request.get('mobile').strip('\n') user.put() addInit(user.userName,user.trueName,user.tele,user.mobile)#默认初始化订阅 self.redirect('/userInfo')
def get(self,page): searchType = self.request.get('searchType')#'searchType‘不存在是返回的不是None,而是''空字符 father=self.request.get('father') subscribes=Subscribe.all() if father: subscribes=subscribes.filter('father =',father) if searchType=='': searchType=self.request.get('userName') subscribes=subscribes.filter('userName ='******'__key__') elif searchType=='userName': subscribes=subscribes.filter('father =','').order(searchType).order('__key__') searchType='' else: if not User.get_by_keyname('u'+searchType): searchType='' if father: subscribes=subscribes.filter('userName ='******'__key__') else: subscribes=subscribes.filter('level =','1').filter('userName ='******'__key__') # index=0 if page=="" else int(page) # if subscribes and type(subscribes) is not list: # subscribes = subscribes.fetch(16,index*16) # prevpage,nextpage=getPageing(len(subscribes), index) template_values = {'subscribes':subscribes,'searchType':searchType,'father':father} self.render('template/subscribe/subscribeInfo.html',template_values)#本地上运行用这个
def get(self): UserName = self.request.get('UserName') UserPwd = self.request.get('UserPwd') ulist=User.all().filter('userName ='******'用户名或密码不正确。')) pass
def get(self): UserName = self.request.get('UserName') UserPwd = self.request.get('UserPwd') ulist=User.all().filter('userName ='******'1') else: self.response.out.write('3') pass
def post(self): userName = self.request.get('username') index = self.request.get('index') user = User.get_by_keyname('u'+userName) if user: user.trueName = self.request.get('truename') user.tele = self.request.get('telephone') user.mobile = self.request.get('mobile') user.put() self.redirect('/userList/%s' %index)
def get(self,page): searchType = self.request.get('searchType')#'searchType‘不存在是返回的不是None,而是''空字符 if searchType in ['userName','date']: greetings=User.all().order('-'+searchType) elif searchType=='': greetings=User.all() else: greetings=User.get_by_keyname('u'+searchType) if greetings: greetings=[greetings] else: greetings=[] index=0 if page=="" else int(page) if greetings and type(greetings) is not list: greetings = greetings.fetch(16,index*16) prev,next=getPageing(len(greetings), index) template_values = {'greetings':greetings,"prev":prev,"next":next,"index":index,} self.render('template/user/userinfo2.html',template_values)
def get(self): UserName = self.request.get('UserName') UserPwd = self.request.get('UserPwd') ulist = User.all().filter('userName ='******'用户名或密码不正确。')) pass
def getUname(): # memname=memcache.get('username') unn = UserNameNumber.get_by_key_name('userNameNumber') # if not memname: if not unn: unn = UserNameNumber(key_name='userNameNumber') ul = User.all().order('-__key__').fetch(1) if ul: u = ul[0] uname = u.key().name() unames = uname.split('u') if len(unames) >= 3: uname = unames[2] else: uname = '1000' if len(uname) <= 3: uname = '1000' else: uname = str(int(uname) + 1) else: uname = '1000' else: uname = str(unn.userName + 1) # else: # uname=str(int(memname)+1) # memcache.set('username',uname,3600) unn.userName = int(uname) unn.put() if User.get_by_keyname('u' + str(len(uname)) + 'u' + uname): return getUname() else: # u=User(key_name='u'+str(len(uname))+'u'+uname) # u.userName=uname # u.passWord=uname # u.trueName='' # u.tele='' # u.mobile='' # u.put() return uname
def checkUser(self): # 验证是否具有这个用户 if not IsPassword: return True username = self.request.get("UserName") password = self.request.get("UserPwd") if not username or not password: return False # greetings = db.GqlQuery("SELECT * FROM User where userName=:1 and passWord=:2",UserName,UserPwd) if 1 == User.all().filter("userName ="******"passWord =", password).count(): return True else: return False
def getUname(): # memname=memcache.get('username') unn=UserNameNumber.get_by_key_name('userNameNumber') # if not memname: if not unn: unn=UserNameNumber(key_name='userNameNumber') ul=User.all().order('-__key__').fetch(1) if ul: u=ul[0] uname=u.key().name() unames=uname.split('u') if len(unames)>=3: uname=unames[2] else: uname='1000' if len(uname)<=3: uname='1000' else: uname=str(int(uname)+1) else: uname='1000' else: uname=str(unn.userName+1) # else: # uname=str(int(memname)+1) # memcache.set('username',uname,3600) unn.userName=int(uname) unn.put() if User.get_by_keyname('u'+str(len(uname))+'u'+uname): return getUname() else: # u=User(key_name='u'+str(len(uname))+'u'+uname) # u.userName=uname # u.passWord=uname # u.trueName='' # u.tele='' # u.mobile='' # u.put() return uname
def userAppData(userName, datas): str = "&" user = User.get_by_keyname("u" + userName) appmap = user.getParms() ###### # 把用户跟应用相关的参数,比如微博的token和socket都按照urlparms的格式组装好 # # # # 另外还缺少一个写应用参数的接口 ###### for k in appmap.keys(): for p in appmap[k].keys(): str += "%s=%s&" % (p, appmap[k][p]) if datas: datas.setAttribute("appdata", str[:-1])
def get(self): try: UserName = self.request.get('UserName') UserPwd = self.request.get('UserPwd') if not UserName: self.response.out.write(getUname()) return try: int(UserName) int(UserPwd) except : self.response.out.write('2') return #没有进行参数正确验证 if UserName=='' or UserPwd=='': self.response.out.write('2') return user = User.get_by_keyname('u'+UserName) if not user: user = User(key_name='u'+str(len(UserName))+'u'+UserName) user.userName = self.request.get('UserName').strip('\n') user.passWord = self.request.get('UserPwd').strip('\n') user.trueName = self.request.get('trueName').strip('\n') user.tele = self.request.get('tele').strip('\n') user.mobile = self.request.get('mobile').strip('\n') user.put() addInit(user.userName,user.trueName,user.tele,user.mobile)#默认初始化订阅 self.response.out.write('1') else: self.response.out.write('2') except Exception,e: logging.error('user:'******'2')
def post(self): """ 根据应用的请求把相关用户的应用参数记录下来 """ app = self.request.get("appid") userName = self.request.get("UserName") user = User.get_by_keyname("u" + userName) if user: appmap = user.getParms() if not appmap.has_key(app): appmap[app] = {} for i in range(10): key = self.request.get("key" + str(i)) value = self.request.get("value" + str(i)) if key and value: appmap[app][key] = value user.put() pass
def doRePassWord(self): username = self.request.get("UserName") pas = [] for p in self.request.get("Content").split("**"): if p: pas.append(p) if len(pas) >= 2: u = User.get_by_keyname("u" + username) # u=db.GqlQuery("SELECT * FROM User where userName=:1 AND passWord=:2 ",self.request.get('UserName'),pas[0]).fetch(1) if u: u.passWord = pas[1] u.put() self.response.out.write("0") return else: self.response.out.write("1") return # if len(pas)>=3 and pas[1]!=pas[2]: # self.response.out.write('2') # return self.response.out.write("1") return
def get(self): userName = self.request.get('userName') if userName=='000': return index = self.request.get('index') user=User.get_by_keyname('u'+userName) if user: user.delete() sq=Subscribe.all().filter('userName ='******'u'+userName) if u: u.delete() contentq=ContentClass.all().filter('userName ='******'/userList/%s' %index)
def get(self): try: UserName = self.request.get('UserName') UserPwd = self.request.get('UserPwd') if not UserName: self.response.out.write(getUname()) return try: int(UserName) int(UserPwd) except: self.flush(getResult(None, False, u'用户名或密码不是数字')) return #没有进行参数正确验证 if UserName == '' or UserPwd == '': self.flush(getResult(None, False, u'用户名和密码不能为空')) return user = User.get_by_keyname('u' + UserName) if not user: user = User(key_name='u' + str(len(UserName)) + 'u' + UserName) user.userName = self.request.get('UserName').strip('\n') user.passWord = self.request.get('UserPwd').strip('\n') # user.trueName = self.request.get('trueName').strip('\n') # user.tele = self.request.get('tele').strip('\n') # user.mobile = self.request.get('mobile').strip('\n') user.put() # addInit(user.userName,user.trueName,user.tele,user.mobile)#默认初始化订阅 self.flush(getResult(None)) else: self.flush(getResult(None, False, u'保存用户信息时出错,请稍后再试。')) except Exception, e: logging.error('user register:' + str(e)) self.response.out.write(getResult(None, False, u'系统错误,请稍后再试。'))
def get(self): try: UserName = self.request.get('UserName') UserPwd = self.request.get('UserPwd') if not UserName: self.response.out.write(getUname()) return try: int(UserName) int(UserPwd) except : self.flush(getResult(None,False,u'用户名或密码不是数字')) return #没有进行参数正确验证 if UserName=='' or UserPwd=='': self.flush(getResult(None,False,u'用户名和密码不能为空')) return user = User.get_by_keyname('u'+UserName) if not user: user = User(key_name='u'+str(len(UserName))+'u'+UserName) user.userName = self.request.get('UserName').strip('\n') user.passWord = self.request.get('UserPwd').strip('\n') # user.trueName = self.request.get('trueName').strip('\n') # user.tele = self.request.get('tele').strip('\n') # user.mobile = self.request.get('mobile').strip('\n') user.put() # addInit(user.userName,user.trueName,user.tele,user.mobile)#默认初始化订阅 self.flush(getResult(None)) else: self.flush(getResult(None,False,u'保存用户信息时出错,请稍后再试。')) except Exception,e: logging.error('user register:'+str(e)) self.response.out.write(getResult(None,False,u'系统错误,请稍后再试。'))
def get(self, *args): fromurl = "/top" if not ContentClass.get_by_key_name("a3"): content = ContentClass(key_name="a3") content.maincode = "a3" content.level = "1" content.title = u"微博" content.content = u"[*sys/001/a777_1*]微博" content.status = "1" content.updateSpanTime = "100" content.put() if not ContentClass.get_by_key_name("a4"): content = ContentClass(key_name="a4") content.maincode = "a4" content.level = "1" content.title = u"即时通讯" content.content = u"[*sys/002/a777_1*]即时通讯" content.status = "1" content.updateSpanTime = "100" content.put() if not ContentClass.get_by_key_name("a777"): content = ContentClass(key_name="a777") content.maincode = "a777" content.level = "1" content.title = u"系统图库" content.content = u"[*sys/003/a777_1*]系统图库" content.status = "1" content.updateSpanTime = "100" content.put() if not ContentClass.get_by_key_name("a888"): content = ContentClass(key_name="a888") content.maincode = "a888" content.level = "1" content.title = u"应用列表" content.content = u"[*sys/004/a777_1*]应用列表" content.status = "1" content.updateSpanTime = "100" content.put() if not ContentClass.get_by_key_name("a888-s1"): content = ContentClass(key_name="a888-s1") content.maincode = "a888" content.father = "a888" content.level = "100" content.content = u"应用列表" content.status = "1" content.replyType = "16" content.put() if not ContentClass.get_by_key_name("a888-s1-3"): content = ContentClass(key_name="a888-s1-3") content.maincode = "a888" content.father = "a888-s1" content.level = "101" content.title = "a3;a3_1:weibo.zxxsbook.com,a3_2:weibo.zxxsbook.com" content.content = u"微博应用这是微博应用的简介" content.status = "1" content.replyType = "16" content.put() if not ContentClass.get_by_key_name("a888-s1-4"): content = ContentClass(key_name="a888-s1-4") content.maincode = "a888" content.father = "a888-s1" content.level = "101" content.title = "a4;a4_1:im.zxxsbook.com" content.content = u"即时通讯应用,这是即时通讯应用的简介" content.status = "1" content.replyType = "16" content.put() if not ContentClass.get_by_key_name("a888-s1-777"): content = ContentClass(key_name="a888-s1-777") content.maincode = "a888" content.father = "a888-s1" content.level = "101" content.title = "a777;a777_1:imglib.zxxsbook.com" content.content = u"系统图库的简介" content.status = "1" content.replyType = "16" content.put() if not ContentClass.get_by_key_name("a999"): contentclass = ContentClass(key_name="a999") contentclass.title = u"系统设置" contentclass.content = u"[*sys/005/a777_1*]系统设置" contentclass.maincode = "a999" contentclass.level = "1" contentclass.status = "1" contentclass.updateSpanTime = "100" contentclass.put() if not ContentClass.get_by_key_name("a999-2"): contentclass = ContentClass(key_name="a999-2") contentclass.title = u"微博授权" contentclass.content = u"微博授权" contentclass.maincode = "a999" contentclass.father = "a999" contentclass.level = "2" contentclass.status = "1" contentclass.updateSpanTime = "100" contentclass.put() if not ContentClass.get_by_key_name("a999-2-s1"): contentclass = ContentClass(key_name="a999-2-s1") contentclass.content = u"微博授权" contentclass.maincode = "a999" contentclass.father = "a999-2" contentclass.level = "100" contentclass.status = "1" contentclass.replyType = "15" contentclass.put() # if not ContentClass.get_by_key_name("a9999"): # contentclass=ContentClass(key_name='a9999') # contentclass.code='a9999' # contentclass.title=u'系统消息' # contentclass.content=u'系统消息' # contentclass.maincode='a9999' ## contentclass.father='a999' # contentclass.level='1' # contentclass.status='1' # contentclass.updateSpanTime='100' # contentclass.put() if not ContentClass.get_by_key_name("a999-9"): contentclass = ContentClass(key_name="a999-9") contentclass.title = u"修改密码" contentclass.content = u"修改密码" contentclass.maincode = "a999" contentclass.father = "a999" contentclass.level = "2" contentclass.status = "1" contentclass.updateSpanTime = "100" contentclass.put() if not ContentClass.get_by_key_name("a999-9-s1"): contentclass = ContentClass(key_name="a999-9-s1") # contentclass.title=u'修改密码' contentclass.content = u"修改密码" contentclass.maincode = "a999" contentclass.father = "a999-9" contentclass.level = "100" contentclass.replyType = "5" contentclass.status = "1" # contentclass.updateSpanTime='100' contentclass.put() if not ContentClass.get_by_key_name("a999-9-s1-1"): contentclass = ContentClass(key_name="a999-9-s1-1") contentclass.content = u"**原始密码#10#**新密码#10#**" contentclass.maincode = "a999" contentclass.father = "a999-9-s1" contentclass.level = "101" contentclass.replyType = "5" contentclass.status = "1" contentclass.put() if not User.get_by_keyname(key_names="u000"): u = User(key_name="u3u000") u.userName = "******" u.passWord = "******" u.put() if not Subscribe.get_by_key_name(key_names="a999u000"): s = Subscribe(key_name="a999u000") s.userName = "******" s.code = "a999" s.level = "1" s.father = "" s.maincode = "a999" s.subscribeType = "1" s.status = "1" s.put() # if not Subscribe.get_by_key_name(key_names='a9999u000'): # s=Subscribe(key_name='a9999u000') # s.userName='******' # s.code='a9999' # s.level='1' # s.father='' # s.maincode='a9999' # s.subscribeType='0' # s.status='1' # s.put() if not Subscribe.get_by_key_name(key_names="a888u000"): s = Subscribe(key_name="a888u000") s.userName = "******" s.code = "a888" s.level = "1" s.father = "" s.maincode = "a888" s.subscribeType = "0" s.status = "1" s.put() if not Subscribe.get_by_key_name(key_names="a999-9u000"): s = Subscribe(key_name="a999-9u000") s.status = "1" s.subscribeType = "0" s.userName = "******" s.maincode = "a999" s.code = "a999-9" s.father = "a999" s.level = "2" s.put() self.redirect(fromurl)
def doDingYue(self): username = self.request.get("UserName") docontent = self.request.get("Content") # m=self.request.get('MainCode') code = self.request.get("Code") c = code.split("-") if "3" == c[-1]: if "1" == docontent: content = ContentClass.get_by_key_name(key_names="a999-2-s1-" + username) if not content: content = ContentClass(key_name="a999-2-s1-" + username) content.maincode = "a999" # 主编号 content.father = "a999-2-s1" # 父级 content.content = "*;*1*2*3*4*" # 内容 content.replyType = "15" content.status = "1" content.level = "101" content.userName = username content.put() content = ContentClass.get_by_key_name(key_names=code + "-" + username) if not content: content = ContentClass(key_name=code + "-" + username) content.maincode = "a888" # 主编号 content.father = code # 父级 content.content = "1" # 内容 content.replyType = "16" content.status = "1" content.level = "102" content.userName = username content.put() s = Subscribe.get_by_key_name(key_names="a999-2u" + username) if not s: s = Subscribe(key_name="a999-2u" + username) s.userName = username s.code = "a999-2" s.level = "2" s.father = "a999" s.maincode = "a999" s.subscribeType = "0" s.status = "1" s.put() s = Subscribe.get_by_key_name(key_names="a3u" + username) if not s: s = Subscribe(key_name="a3u" + username) s.userName = username s.code = "a3" s.level = "1" s.maincode = "a3" s.subscribeType = "1" s.status = "1" s.put() self.response.out.write(WEBURL[7:] + "/InfoUpdate;") content = ContentClass.get_by_key_name(key_names=code) if content: try: self.response.out.write(content.title.split(";")[1].split(",")[0].split(":")[1] + "/InfoAll;") self.response.out.write(content.title.split(";")[1].split(",")[0].split(":")[1] + "/InfoUpdate") except Exception, e: logging.info("error:" + content.title) return else: content = ContentClass.get_by_key_name(key_names="a999-2-s1-" + username) if content: content.status = "0" content.put() user = User.get_by_keyname("u" + username) if user: appmap = user.getParms() if appmap.has_key("a3"): del appmap["a3"] user.put() content = ContentClass.get_by_key_name(key_names=code + "-" + username) if content: content.content = "0" content.put() s = Subscribe.get_by_key_name(key_names="a999-2u" + username) if s: s.status = "0" s.put() s = Subscribe.get_by_key_name(key_names="a3u" + username) if s: s.status = "0" s.put() self.response.out.write(WEBURL[7:] + "/InfoUpdate") return
def get(self): userName = self.request.get('userName') index = self.request.get('index') users = User.get_by_keyname('u'+userName) template_values = {'user':users,"index":index,} self.render('template/user/userUpdate.html',template_values)