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


Python Message.select方法代码示例

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


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

示例1: get_message_json

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import select [as 别名]
def get_message_json(conversation_id=None, message=None):
	messages = None
	if conversation_id:
		messages = Message.select().where(Message.conversation==conversation_id).order_by(Message.ts.asc())
	elif message:
		messages = message
	return __jsonify_messages(messages)
开发者ID:FelipePiacsek,项目名称:chat_angular,代码行数:9,代码来源:messages.py

示例2: poll_message

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import select [as 别名]
def poll_message(room_code):
    """
    Route used to poll messages waiting for the user.
    It adds a queue to the set of player's message queues.
    Fetches new messages from the database and, if no messages, it waits until
    a new message appears in the queue.
    """
    sessid = request.cookies.get("sessid")
    try:
        player = Player.select(Player, Room).join(Room).where(Player.sessid == sessid, Room.code == room_code).get()
    except Player.DoesNotExist:
        return HTTPError(404)
    last_update_ts = float(request.query.get("lastUpdate", time.time()))
    last_update = datetime.fromtimestamp(last_update_ts)

    queue = gevent.queue.Queue()
    message_queue[player.id].add(queue)
    messages = Message.select().where(Message.player == player, Message.timestamp > last_update).execute()
    if messages.count == 0:

        def get_messages(queue):
            while True:
                try:
                    message = queue.get(timeout=90)
                except gevent.queue.Empty:
                    return
                if message is StopIteration:
                    return
                yield message

        messages = list(get_messages(queue))
    message_queue[player.id].remove(queue)
    return {"messages": [message.dict() for message in messages], "timestamp": time.time()}
开发者ID:warownia1,项目名称:TheResistance,代码行数:35,代码来源:views.py

示例3: get_context

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import select [as 别名]
 def get_context(self):
     last_week = datetime.datetime.now() - datetime.timedelta(days=7)
     signups_this_week = User.select().where(User.join_date > last_week).count()
     messages_this_week = Message.select().where(Message.pub_date > last_week).count()
     return {
         'signups': signups_this_week,
         'messages': messages_this_week,
     }
开发者ID:sekenned,项目名称:totb,代码行数:10,代码来源:admin.py

示例4: private_timeline

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import select [as 别名]
def private_timeline():
    user = auth.get_logged_in_user()

    messages = Message.select().where(
        Message.user << user.following()
    ).order_by(Message.pub_date.desc())

    return object_list('private_messages.html', messages, 'message_list')
开发者ID:DommertTech,项目名称:flask-turboduck,代码行数:10,代码来源:views.py

示例5: private_timeline

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import select [as 别名]
def private_timeline():
    user = auth.get_logged_in_user()

    messages = Message.select().where(Message.user << user.following()).order_by(Message.pub_date.desc())
    return object_list('profile.html',
			messages,
			'message_list',
			course_1_name='jhdsjhdjs',
			progress='50',
			course_1_description='opis opis opis',
			)
开发者ID:coderluka,项目名称:naucilus,代码行数:13,代码来源:views.py

示例6: mark_message_as_read

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import select [as 别名]
def mark_message_as_read(user_id, conversation_id=None, message=None):
	m = None
	cp = None
	if conversation_id:
		cp = ConversationParty.select().where((ConversationParty.conversation==conversation_id) & (ConversationParty.user==user_id)).first()
		if not message:
			m = Message.select().where(Message.conversation==conversation_id).order_by(Message.ts.desc()).first()
	if message:
		m = message
	with database.transaction():
		ConversationParty.update(last_read_message=m).where(ConversationParty.id==cp).execute()
开发者ID:FelipePiacsek,项目名称:chat_angular,代码行数:13,代码来源:messages.py

示例7: private_timeline

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import select [as 别名]
def private_timeline():
    user = auth.get_logged_in_user()
    messages = Message.select().where(Message.user << user.following()).order_by(Message.pub_date.desc())
    return object_list('profile.html',
			messages,
			'message_list',
			ps_nr_points=' 57',
			ps_nr_badges=' 5',
			html_nr_points=' 77',
			html_nr_badges=' 3',
			py_nr_points=' 77',
			py_nr_badges=' 3',
			usersname=user,
			)
开发者ID:Jovan3211,项目名称:naucilus,代码行数:16,代码来源:views.py

示例8: log

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import select [as 别名]
    def log(self, conv_id=0):
        if conv_id is 0:
            self.redirect('/conversations')
        else:
            try:
                conversation = Conversation.get(Conversation.conv_id == conv_id)
            except:
                # cherrypy.request.session.alerts.warn("Conversation ID not found")
                self.redirect('/conversations')

            # Now we know there is a conversation with that ID, check for messages
            try:
                messages = Message.select().where(Message.conversation == conversation and Message.message_type == 1)
                print (messages)
                return {'conversation': conversation, 'messages': messages}
            except:
                return {'conversation': conversation, 'no_messages': 1}
开发者ID:elamperti,项目名称:bastardbot,代码行数:19,代码来源:bastardcontroller.py

示例9: public_timeline

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import select [as 别名]
def public_timeline():
    messages = Message.select().order_by(Message.pub_date.desc())
    return object_list('forum.html', messages, 'message_list')
开发者ID:coderluka,项目名称:naucilus,代码行数:5,代码来源:views.py

示例10: links

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import select [as 别名]
 def links(self, page=1):
     messages = Message.select().where(Message.message_type == 2)
     return {'messages': messages}
开发者ID:elamperti,项目名称:bastardbot,代码行数:5,代码来源:bastardcontroller.py

示例11: public_timeline

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import select [as 别名]
def public_timeline():
    messages = Message.select().order_by(('pub_date', 'desc'))
    return object_list('public_messages.html', messages, 'message_list')
开发者ID:Nassty,项目名称:flask-peewee,代码行数:5,代码来源:views.py

示例12: get_number_of_unread_messages

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import select [as 别名]
def get_number_of_unread_messages(user_id, conversation_id):
	cp = ConversationParty.select().where((ConversationParty.user==user_id) & (ConversationParty.conversation==conversation_id)).first()
	m = cp.last_read_message
	if m:
		return Message.select().where((Message.conversation==conversation_id) & (Message.ts > m.ts)).count()
	return Message.select().where(Message.conversation==conversation_id).count()
开发者ID:FelipePiacsek,项目名称:chat_angular,代码行数:8,代码来源:messages.py

示例13: public_timeline

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import select [as 别名]
def public_timeline():
    userf = auth.get_logged_in_user()
    messages = Message.select().order_by(Message.pub_date.desc())
    return object_list('forum.html', messages, 'message_list', forumusername=userf, forumname='The Forum Wall',)
开发者ID:Jovan3211,项目名称:naucilus,代码行数:6,代码来源:views.py


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