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


Python User.select方法代码示例

本文整理汇总了Python中database.User.select方法的典型用法代码示例。如果您正苦于以下问题:Python User.select方法的具体用法?Python User.select怎么用?Python User.select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在database.User的用法示例。


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

示例1: prepare

# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import select [as 别名]
 def prepare(self):
     domain_query = DomainLogs.select().where(DomainLogs.domain == self.request.host).first()
     if not domain_query:
         user = User.select().where(User.domain == self.request.host.split(".")[-3]).first()
         if not user:
             return
         domain_query = DomainLogs()
         domain_query.user_id = user.id
         domain_query.domain = self.request.host
         domain_query.save()
         log = DNSLogs()
         log.ip = self.request.headers.get('X-Forwarded-For')
         log.user_id = user.id
         log.domain_id = domain_query.id
         log.save()
     if not self.request.uri == "/favicon.ico":
         log = UrlLogs()
         packet = "%s %s %s\n" % (self.request.method, self.request.uri, self.request.version)
         for header in self.request.headers:
             packet += "%s: %s\n" % (header, self.request.headers.get(header))
         packet += "\n%s" % self.request.body
         log.url = self.request.uri
         log.ip = self.request.headers.get("X-Forwarded-For")
         log.domain_id = domain_query.id
         log.user_id = domain_query.user_id
         log.packet = packet
         log.save()
开发者ID:Nightsuki,项目名称:QvQDNS,代码行数:29,代码来源:qvqweb.py

示例2: handleUserJoin

# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import select [as 别名]
def handleUserJoin(obj):
    if not obj['joined']: return
    u = RUser(obj['u'], 0, r)
    if u.isOnline() and not u.getCurrentServer()['sid'] == obj['sid']: #If the user is online, kick them from the first server
        push(obj['sid'], {"a": "kick", "u": obj['u'], "msg": "User joined another server..."})
    u.joinServer(obj['sid'])
    u.addServerHistory(obj['sid'])

    # Join Message
    q = User.select().where(User.username == obj['u'])
    if not q.count():
        packs = [{"a": "sendto", "user": obj['u'], "msg": i} for i in need_reg_msgs]
        push(obj['sid'], packs)
        return

    resp = [
        {"a": "sendto", "user": obj['u'], "msg": "{C_RED}{C_ITALIC}Your user level has been synced."},
        {"a": "user_level", "user": obj['u'], "level": q[0].level}]
    push(obj['sid'], resp)

    msg = [{"a": "sendto", "user": None, "msg": "{C_AQUA}%s {C_GOLD}{C_ITALIC}has joined %s" % (q[0].username, u.getCurrentServer()['name'])}]
    for fr in q[0].getFriends():
        tmp = RUser(fr.username, fr.id, r)
        if tmp.perma['CFG_NOTI_FRIEND_JOIN'] is False: continue
        if tmp.isOnline():
            msg[0]['user'] = tmp.name
            push(tmp.getCurrentServer()['sid'], msg)
开发者ID:b1naryth1ef,项目名称:Metaweb,代码行数:29,代码来源:worker.py

示例3: loginRoute

# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import select [as 别名]
def loginRoute():
    if not 'user' in request.form.keys() or not 'pw' in request.form.keys():
        return flashy('/', 'All fields must be filled in!', 'error')
    q = [i for i in User.select().where(User.username == request.form.get('user'))]
    if not len(q):
        return flashy('/', 'No such user with that name!', 'error')
    if bcrypt.hashpw(request.form.get('pw'), q[0].password) == q[0].password:
        session['logged'] = True
        session['uid'] = q[0].id
        return flashy('/', 'You have been logged in!', 'success')
    return flashy('/', 'Invalid password!', 'error')
开发者ID:b1naryth1ef,项目名称:buildy,代码行数:13,代码来源:main.py

示例4: handleUserQuit

# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import select [as 别名]
def handleUserQuit(obj):
    u = RUser(obj['u'], 0, r)
    u.quitServer(obj['sid'])

    q = User.select().where(User.username == obj['u'])
    if not q.count(): return

    msg = [{"a": "sendto", "user": None, "msg": "{C_AQUA}%s {C_GOLD}{C_ITALIC}has left %s" % (q[0].username, u.getServerInfo(u.getLastServer()['sid'])['name'])}]
    for fr in q[0].getFriends():
        tmp = RUser(fr.username, fr.id, r)
        if tmp.perma['CFG_NOTI_FRIEND_QUIT'] is False: continue
        if tmp.isOnline():
            msg[0]['user'] = tmp.name
            push(tmp.getCurrentServer()['sid'], msg)
开发者ID:b1naryth1ef,项目名称:Metaweb,代码行数:16,代码来源:worker.py

示例5: beforeRequest

# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import select [as 别名]
def beforeRequest():
    g.user = None
    g.uid = -1
    g.state = STATE

    if request.path.startswith("/static"):
        return

    # Normal session
    if request.cookies.get("sid"):
        s = Session.find(request.cookies.get("sid"))
        if s:
            # Eventually we should be lazily loading this in, or cacheing it at redis
            try:
                g.user = User.select().where(User.id == s['user']).get()
                g.uid = g.user.id
            except User.DoesNotExist:
                resp = flashy("Wow! Something really went wrong. Contact support!")
                resp.set_cookie('sid', '', expires=0)
                return resp
开发者ID:b1naryth1ef,项目名称:GoPlayNao,代码行数:22,代码来源:app.py

示例6: start_qvq

# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import select [as 别名]
def start_qvq(domain, ip):
    domain = "%s." % domain
    qvqdns = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    qvqdns.bind(('', 53))
    try:
        print ("QvQDNS is listening on 0.0.0.0:53\n")
        while 1:
            data, addr = qvqdns.recvfrom(1024)
            try:
                p = DNSQuery(data)
            except:
                p = None
                pass
            if p and p.dominio.endswith(domain):
                qvqdns.sendto(p.respuesta(ip), addr)
                print("%s------%s" % (p.dominio[:-1], addr[0]))
                user = User.select().where(User.domain == p.dominio.split(domain)[0].split(".")[-1]).first()
                if user:
                    domain_query = DomainLogs.select().where(DomainLogs.domain == p.dominio[:-1]).first()
                    if not domain_query:
                        domain_query = DomainLogs()
                        domain_query.user_id = user.id
                        domain_query.domain = p.dominio[:-1]
                        domain_query.save()
                    log = DNSLogs()
                    log.ip = addr[0]
                    log.user_id = user.id
                    log.domain_id = domain_query.id
                    log.save()
            else:
                print("%s------%s" % (p.dominio[:-1], addr[0]))
                try:
                    result = domain_to_ip(p.dominio[:-1])
                    qvqdns.sendto(p.respuesta(result[0]), addr)
                except:
                    pass
            del p
    except KeyboardInterrupt:
        qvqdns.close()
        print ("QvQDNS is closed!")
开发者ID:Nightsuki,项目名称:QvQDNS,代码行数:42,代码来源:qvqdns.py

示例7: test

# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import select [as 别名]
def test(id):
    g.user = User.select().where(User.id == id).get()
    g.uid = g.user.id
    resp = flashy("Welcome back %s!" % g.user.username, "success")
    resp.set_cookie("sid", g.user.login(), expires=time.time() + Session.LIFETIME)
    return resp
开发者ID:b1naryth1ef,项目名称:GoPlayNao,代码行数:8,代码来源:app.py

示例8: get_have_count

# 需要导入模块: from database import User [as 别名]
# 或者: from database.User import select [as 别名]
 def get_have_count(self):
     # TODO: move this to stats/cache
     from database import User
     return User.select().where(User.badges.contains(self.id)).count()
开发者ID:b1naryth1ef,项目名称:GoPlayNao,代码行数:6,代码来源:badges.py


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