コード例 #1
0
ファイル: push.py プロジェクト: yimiqisan/huwai
def run(argv):
    channel = argv[0]
    try:
        fn = 'cmd/push_'+channel+'.txt'
        f = open(fn, 'r')
    except Exception:
        print 'open file %s error'%fn
        return False
    print 'start'
    if channel == 'user':
        u = User()
        while(True):
            line=f.readline()
            if not line:
                break
            n, e, p= line.split('\t')
            r = u.register(n.decode('utf-8'), password=unicode(p.strip()), email=unicode(e))
            print r
    elif channel[:3] == 'tag':
        t = Tag()
        while(True):
            line=f.readline()
            if not line:
                break
            h, d, c = line.split(',')
            c = c.replace('\r\n', '').replace('\n', '').replace('\r', '').decode('utf-8')
            r = t._api.add(SITE_ID, c, relation_l=['place'])
            print r
    else:
        pass
    f.close()
    print 'finish!!!'
    return True
コード例 #2
0
ファイル: authHandler.py プロジェクト: yimiqisan/huwai
 def post(self):
     a = self.get_argument('act', None)
     extra = self.get_argument('extra', None)
     n = self.get_argument('nick', None)
     if n is None:return self.render('profile/thirdpart.html', **{'warning': '请先报上名号', 'nick': n, 'extra': extra})
     p = self.get_argument('password', None)
     if p is None:return self.render('profile/thirdpart.html', **{'warning': '您接头暗号是?', 'nick': n, 'extra': extra})
     if extra: extra=eval(extra)
     u = User()
     if a == 'reg':
         e= self.get_argument('email', None)
         if e is None:return self.render('profile/thirdpart.html', **{'warning': '设置邮箱,可能帮您找回失散多年的密码', 'nick': n, 'extra': extra})
         r = u.register(n, e, p)
         if r[0]:
             self.set_secure_cookie("user", n, 1)
             uid = r[1]
             self.SESSION['uid']=uid
             if extra.has_key('photo'):self.save_avatar(extra['photo'])
             if extra.has_key('qqid'):u._api.edit(uid, qqid=extra['qqid'])
             if extra.has_key('sinaid'):u._api.edit(uid, sinaid=extra['sinaid'])
             if extra.has_key('sina_access_token'):u._api.edit(uid, sina_access_token=extra['sina_access_token'])
             self.redirect('/account/profile')
         else:
             return self.render('profile/thirdpart.html', **{'warning': r[1], 'nick': n, 'extra': extra})
     elif a == 'bind':
         pass
     else:
         return self.render('profile/thirdpart.html', **{'warning': '系统晕了,不知道您是绑定还是注册!', 'nick': n, 'extra': extra})
コード例 #3
0
ファイル: authHandler.py プロジェクト: yimiqisan/huwai
 def add_user(self, **extra):
     u = User()
     n = extra.pop('nick')
     if u._api.is_nick_exist(n):return self.render('profile/auth.html', **{'warning': '名称已存在', 'nick': n, 'extra': extra})
     r = u.register(n, **extra)
     if r[0]:
         self.SESSION['uid']=u._id
         self.SESSION['nick']=n
         if extra.has_key('photo'):self.save_avatar(extra['photo'])
         u._api.edit(u._id, **extra)
         return self.render('ajax/runjs.html', uid=u._id)
     else:
         return self.render('profile/auth.html', **{'warning': r[1], 'nick': n, 'extra': extra})
コード例 #4
0
ファイル: profileHandler.py プロジェクト: yimiqisan/huwai
    def post(self):
        e= self.get_argument('email', None)
        if e is None:return self.render('profile/register.html', **{'warning': '设置邮箱,可能帮您找回失散多年的密码', 'email':e})
        n = self.get_argument('nick', None)
        if n is None:return self.render('profile/register.html', **{'warning': '请先报上名号', 'email':e})
        p = self.get_argument('password', None)
        if p is None:return self.render('profile/register.html', **{'warning': '您接头暗号是?', 'email':e})
        u = User()
        r = u.register(n, p, email=e)
        if r[0]:
#            self.set_secure_cookie("user", n, 1)
            self.SESSION['uid']=r[1]
            self.SESSION['nick']=n
            self.redirect('/account/profile')
        else:
            return self.render('profile/register.html', **{'warning': r[1], 'email':e})
コード例 #5
0
ファイル: profileHandler.py プロジェクト: yimiqisan/huwai
    def post(self):
        e= self.get_argument('email', None)
        if e is None:return self.write({'error':'设置邮箱,可能帮您找回失散多年的密码'})
        n = self.get_argument('nick', None)
        if n is None:return self.write({'error':'请报上名号'})
        p = self.get_argument('password', None)
        if p is None:return self.write({'error':'您接头暗号是'})
        u = User()
        r = u.register(n, p, email=e)
        if r[0]:
#            self.set_secure_cookie("user", n, 1)
            self.SESSION['uid']=r[1]
            self.SESSION['nick']=n
            self.write({'uid':u._id})
        else:
            self.write({'error':r[1]})