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


Python Message.query方法代码示例

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


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

示例1: get

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import query [as 别名]
 def get(self):
   arg = cgi.escape(self.request.get('q'))
   user = self.user_model
   user.message_count = 0
   user.put()
   if arg == "sent":
     messages = Message.query(Message.sender == user.username).order(-Message.time)
   else:
     messages = Message.query(Message.recipient == user.username).order(-Message.time)
   self.response.out.write(template.render('views/messages.html', {'viewer': user, 'messages': messages}))
开发者ID:tungply7,项目名称:Tutoring-Service,代码行数:12,代码来源:Messages.py

示例2: get

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import query [as 别名]
    def get(self, *args, **kwargs):

        params = dict()
        params['group'] = self.group

        if self.group_membership.isPending == True:
            self.display_message('Dein Aufnahmeantrag fuer diese Gruppe wurde noch nicht bearbeitet')
            return

        messagesQuery = Message.query(ancestor=self.group.key).order(Message.created)
        messages = messagesQuery.fetch()
        userKeys = []

        for message in messages:
            userKeys.append(message.userKey)

        users = ndb.get_multi(userKeys)
        params['messages'] = zip(messages, users)
        params['groupmembership'] = self.group_membership

        if self.group_membership.isModerator:
            requestsQuery = GroupMembership.query(GroupMembership.groupKey == self.group.key,
                                                  GroupMembership.isPending == True)

            requests = requestsQuery.fetch()
            requestingUserKeys = []
            for request in requests:
                requestingUserKeys.append(request.userKey)

            requestingUsers = ndb.get_multi(requestingUserKeys)
            print(requestingUsers)
            params['member_requests'] = requestingUsers


        self.render_template('showgroup.html', params=params)
开发者ID:fi4sk0,项目名称:supertinygroupware,代码行数:37,代码来源:main.py

示例3: testSendMessageDetails

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import query [as 别名]
 def testSendMessageDetails(self):
     self._sendMessage()
     (message,) = Message.query().fetch(1)
     self.assertEqual(message.from_user.email(), self.user1.email())
     self.assertEqual(message.to_user.email(), self.user2.email())
     self.assertEqual(message.subject, 'subject')
     self.assertEqual(message.content, 'content')
开发者ID:viorels,项目名称:udacity-messages,代码行数:9,代码来源:tests.py

示例4: get

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import query [as 别名]
    def get(self, conversation_id):
        conversation = ndb.Key(Conversation, int(conversation_id)).get()

        if self.user.key not in conversation.user_keys:
            return self.render_json_error('You are not allowed to view this conversation', 403)

        messages = Message.query(Message.conversation_key == conversation.key,
            Message.visibleto_user_keys == self.user.key).order(Message.created).fetch()

        self.render_json_response(messages)
开发者ID:alexmedanchuk,项目名称:Code-Samples,代码行数:12,代码来源:inbox.py

示例5: cache

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import query [as 别名]
def cache(key, update = False):
    msgs = memcache.get(key)
    if msgs is None or update:
        print "DB CACHE QUERY %s" % key
        if key is 'top_msgs':
            msgs = Message.query().order(-Message.createDate).fetch(20)
        elif key is 'get_chars':
            msgs = Character.all()
        msgs = list(msgs)
        memcache.set(key, msgs)
    return msgs
开发者ID:qwertyshan,项目名称:Jedi,代码行数:13,代码来源:main.py

示例6: get

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import query [as 别名]
 def get(self):
     userid = get_account().key.id()
     # inbox messages
     inboxMessages = Message.query(Message.touserid == userid).fetch()
     inboxMessages = sorted(
         inboxMessages,
         key=lambda inboxMessage: inboxMessage.datetime
     )
     inbox_messages_out = []
     for im in inboxMessages:
         fromuseremail = Account.get_by_id(im.fromuserid).guser.email()
         im_out = {
             'fromuseremail': fromuseremail,
             'subject': im.subject,
             'message': im.message,
             'datetime': im.datetime.strftime("%Y-%m-%d %H:%M:%S")
         }
         inbox_messages_out.append(im_out)
     # sent messages
     sentMessages = Message.query(Message.fromuserid == userid).fetch()
     sentMessages = sorted(
         sentMessages,
         key=lambda sentMessage: sentMessage.datetime
     )
     sent_messages_out = []
     for sm in sentMessages:
         touseremail = Account.get_by_id(sm.touserid).guser.email()
         sm_out = {
             'touseremail': touseremail,
             'subject': sm.subject,
             'message': sm.message,
             'datetime': sm.datetime.strftime("%Y-%m-%d %H:%M:%S")
         }
         sent_messages_out.append(sm_out)
     messages = {
         'inbox_messages': inbox_messages_out,
         'sent_messages': sent_messages_out
     }
     self.response.headers['Content-Type'] = 'application/json'
     self.response.write(json.dumps(messages))
开发者ID:N0tinuse,项目名称:senior_project,代码行数:42,代码来源:info.py

示例7: testSendGroupMessage

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import query [as 别名]
    def testSendGroupMessage(self):
        # user logs in for the first time
        UserProfile.for_user(self.user2)

        # send group message and check if it's recorded
        self._sendGroupMessage()
        self.assertEqual(1, GroupMessage.query().count())

        # no 1 to 1 messages are stored until the user checks inbox
        self.assertEqual(0, Message.query().count())

        # after checking messages a copy of the group message is stored in inbox
        (messages, _, _) = Message.list_for_user(self.user2)
        self.assertEqual(1, len(messages))
开发者ID:viorels,项目名称:udacity-messages,代码行数:16,代码来源:tests.py

示例8: home

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import query [as 别名]
def home(request):
    #return http.HttpResponse('Hello World! A')
	#return render(request, 'index.html')
	now = datetime.datetime.now()
	html = "<html><body>It is now %s.</body></html>" % now
	instance=myurl(myurl="%s"%now,status='OK')
	instance.put()
	form = CommentForm(auto_id=False)
	accout= Account.query(Account.aid>0).fetch()
	message=Message.query().fetch()
	nodeall=Nodeall.query(Nodeall.ntemp=='T').fetch()
	total=dict(j=0,d=0)
	for node in nodeall:
		total['j']=total['j']+node.nd		
		total['d']=total['d']+node.nd
	return render(request, 'index.html',{'form':form,'acc':accout,'message':message,'nodeall':nodeall,'total':total})
开发者ID:g1z2yong,项目名称:accone,代码行数:18,代码来源:views.py

示例9: get

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import query [as 别名]
 def get(self):
     api_key = self.request.get('api-key')
     if api_key != API_KEY:
         self.response.write('Invalid key')
         return
     to = self.request.get('to')
     body = self.request.get('body')
     
     ancestor_key = ndb.Key('Messages', 'messages')
     query = Message.query(ancestor=ancestor_key).order(-Message.date)
     if to:
        query = query.filter(Message.to == to)
     print type(query)
     messages = [dict(to=msg.to,
                  body=msg.body,
                  date=msg.date.isoformat()) for msg in query if body in msg.body]
     self.response.headers['Content-Type'] = 'application/json'
     self.response.write(json.dumps(messages))
开发者ID:Radcliffe,项目名称:web-to-sms,代码行数:20,代码来源:retrieve.py

示例10: get

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import query [as 别名]
    def get(self):
        user, logout = check_user(users.get_current_user())
        if user:
            message_list = list()
            more = True
            curs = None
            while more:
                m, curs, more = Message.query(
                ).order(
                    -Message.when).fetch_page(
                        10, start_cursor=curs)
                for mitem in m:
                    message_list.append(mitem)


            template = JINJA_ENVIRONMENT.get_template('admin.html')
            self.response.write(template.render(
                {'logout_url':users.create_logout_url('/'),
                 'messages': message_list}))

        else:
            self.redirect(users.create_login_url('/admin'))
开发者ID:guillemborrell,项目名称:vscontentmanager,代码行数:24,代码来源:main.py

示例11: get

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import query [as 别名]
    def get(self):
        list_of_m = Message.query().fetch()
        params = {"list_of_m": list_of_m}

        user = users.get_current_user()

        params["user"] = user

        if user:
            prijavljen = True
            logout_url = users.create_logout_url('/')

            params["prijavljen"] = prijavljen
            params["logout_url"] = logout_url
        else:
            prijavljen = False
            login_url = users.create_login_url('/')

            params["prijavljen"] = prijavljen
            params["login_url"] = login_url

        return self.render_template("main.html", params=params)
开发者ID:KleEnder,项目名称:chap-app,代码行数:24,代码来源:main.py

示例12: get

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import query [as 别名]
 def get(self):
     uporabnik = users.get_current_user()
     seznam = Message.query(Message.izbrisan == False).fetch()         # da prikazes samo tiste, ki niso izbrisani (v queriju)
     params = {"seznam":seznam,"uporabnik":uporabnik}
     return self.render_template("seznam_sporocil.html",params=params)
开发者ID:matejagustin,项目名称:base_jinja,代码行数:7,代码来源:main.py

示例13: testSendMessage

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import query [as 别名]
 def testSendMessage(self):
     self._sendMessage()
     self.assertEqual(1, Message.query().count())
开发者ID:viorels,项目名称:udacity-messages,代码行数:5,代码来源:tests.py

示例14: message_list

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import query [as 别名]
def message_list():
    page_size = app.config.get('OBJECTS_ON_PAGE', 20)
    messages = Message.query().fetch(page_size)
    return render_template('messages.html', messages=messages)
开发者ID:tarvitz,项目名称:test-work,代码行数:6,代码来源:views.py

示例15: get

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import query [as 别名]
    def get(self):
        m = Message.query().fetch()
        # message = m.query.query()

        self.response.write(m)
开发者ID:s2krish,项目名称:opchallenge,代码行数:7,代码来源:handlers.py


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