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


Python Message.all方法代码示例

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


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

示例1: messages

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import all [as 别名]
def messages():
    messages = list(Message.all().filter('seen', False))
    for m in messages:
        m.seen = True
        m.save()
    return flask.Response('\n\n'.join([m.content for m in messages]),
        mimetype='text/plain')
开发者ID:sneeu,项目名称:MicroprinterMQ,代码行数:9,代码来源:views.py

示例2: get

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import all [as 别名]
 def get(self):
     "Displays the home page, which lists the latest messages"
     # lets have some basic cachine just in case
     output = memcache.get("index")
     if output is None:
         # we're only showing messages from within the last five days
         # this is for demonstration purposes only and stops 
         # the demo getting swamped with messages
         yesterday = datetime.today() - timedelta(5)
         
         # get all messages posted in the last day and order them
         # by the date posted
         messages = Message.all()
         messages.order('-date')
         messages.filter('date >', yesterday)
         # prepare the context for the template
         context = {
             'messages': messages,
             'debug': settings.DEBUG,
         }
         # calculate the template path
         path = os.path.join(os.path.dirname(__file__), 'templates',
             'index.html')
         # render the template with the provided context
         output = template.render(path, context)
         memcache.add("index", output, settings.CACHE_TIME)
     self.response.out.write(output)
开发者ID:frankk00,项目名称:appengine-imified,代码行数:29,代码来源:main.py

示例3: get

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import all [as 别名]
    def get(self):
        
        # Get the id that indicate where is the start point of new messages:
        current_id = int(self.request.get('id'))
        messages = Message.all().order('-postID').filter("postID > ", current_id)
        msg_set  = messages.fetch(10)
 
        self.response.headers['Content-Type'] = 'text/xml'
        self.response.headers['Cache-Control'] = 'no-cache'
        
        # Start writing the xml content:
        self.response.out.write('<?xml version="1.0"?>\n')
        self.response.out.write('    <response>\n')
        self.response.out.write('        <id>%d</id>\n' % Message.max_id() )
        for msg in msg_set:
            if not msg.isRemoved:
                self.response.out.write('        <message>\n')
                self.response.out.write('            <author>%s</author>\n' % msg.author.nickname() )
                self.response.out.write('            <postID>%d</postID>\n' % msg.postID )
                self.response.out.write('            <content>%s</content>\n' % msg.content )
                self.response.out.write('            <rcount>%d</rcount>\n' % msg.rCount )
                self.response.out.write('            <time>%s</time>\n' % msg.postDate )
                self.response.out.write('        </message>\n')            

        self.response.out.write('    </response>\n')
开发者ID:benjamin99,项目名称:3dAR,代码行数:27,代码来源:main.py

示例4: get

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import all [as 别名]
    def get(self):
        """
            Fetch All Messages using memcache
        """

        messages = memcache.get("all_messages")

        if not messages:
            messages = Message.all().order("-date").fetch(20)
            memcache.add("all_messages", messages, 30)
            cache_hit = False
        else:
            cache_hit = True

        """
            Make Messages available to the template
        """
        context = {
            'messages': messages,
            'cache_hit': cache_hit
        }

        """
            Render Template
        """
        path = os.path.join(os.path.dirname(__file__), 'base.html')
        self.response.out.write(template.render(path, context))
开发者ID:thurloat,项目名称:Appengine-Demo-App,代码行数:29,代码来源:messages.py

示例5: get

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import all [as 别名]
  def get(self, channelid):
    channel = self._getentity(Channel, channelid)
    if channel is None: return

    template_values = {
      'channel': channel,
      'messages': Message.all().filter('channel =', channel),
    }
    path = os.path.join(os.path.dirname(__file__), 'messagelist.html')
    self.response.out.write(template.render(path, template_values))
开发者ID:qmacro,项目名称:coffeeshop,代码行数:12,代码来源:coffeeshop.py

示例6: poll

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import all [as 别名]
def poll():
    messages = []
    topic_key = request.args.get('topic_key')
    if topic_key:
        topic = Topic.get(topic_key)
        if topic:
            offset = int(request.args.get('offset'))
            l = Message.all().filter('topic', topic).order('created_at').fetch(limit=100, offset=offset)
            messages = [{'content': m.content, 'email': m.author.email, 'created_at': pretty_date(m.created_at), 'topic_key': str(m.topic.key())} for m in l]
    return jsonify(messages=messages)
开发者ID:ouxuedong,项目名称:dod-app,代码行数:12,代码来源:main.py

示例7: get

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import all [as 别名]
	def get(self):
		messages = Message.all().order('-datetime')

		results = []
		for message in messages:
			results.append(message.to_dict())

		
		response = {"list" : results, "total" : len(results)}
		json = simplejson.dumps(response)
		self.response.out.write(json)
开发者ID:ghinch,项目名称:Mail-Engine,代码行数:13,代码来源:views.py

示例8: discussion

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import all [as 别名]
def discussion(topic_key):
    messages = None
    if topic_key:
        topic = Topic.get(topic_key)
        if not topic:
            flash('No topic found', 'error')
            return redirect(url_for('index'))
        child_topics = []
        for child_topic_key in topic.child_topics:
            child_topics.append(Topic.get(child_topic_key))
        messages = Message.all().filter('topic', topic).order('-created_at').fetch(limit=50)
    return render_template('discussion.html', messages=messages, topic=topic, child_topics=child_topics)
开发者ID:ouxuedong,项目名称:dod-app,代码行数:14,代码来源:main.py

示例9: post

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import all [as 别名]
    def post(self):
        print "this is post in LoginHandler"
        data = json.loads(self.request.body)
        print data

        print type(data)
        
        fullname = data.get('fullname')       
        password = data.get('password')
        print fullname  
        print password
        try:
            u = self.auth.get_user_by_password(fullname, password, remember=True,
                                           save_session=True)
            all_users = User.query().fetch()
            logging.info(all_users) 
            user_list = []
            print u.get('name')
            curren_user = u.get('name')
            for user in all_users:
                user_list.append(user.name)
                #print user.name
            
            print user_list
            
            print type(user_list)
           
            message_list = []
            message = Message.all()
            current_message = message.filter("receiver =", "%s"%curren_user )
            print current_message

            for msg in message:
                message_list.append(msg.message) 
            print message_list    
            userlist = user_list
            messagelist = message_list
            
            result = {'userlist': userlist, 'messagelist': messagelist, 'curren_user':curren_user }
            self.response.headers['content-type'] = 'application/json'
            
            self.response.write(json.dumps(result))


        except (InvalidAuthIdError, InvalidPasswordError) as e:
            logging.info(
                'Login failed for user %s because of %s', fullname, type(e))
            # self._serve_page(True)
            stat = "invalid user"
            result = {'stat': stat}
            self.response.headers['content-type'] = 'application/json'
            self.response.write(json.dumps(result))
开发者ID:swamy-nyros,项目名称:python-test-assignment,代码行数:54,代码来源:main.py

示例10: distribute_message

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import all [as 别名]
 def distribute_message(self, message):
     message_json = json.dumps({
         'author': message.author.display_name(),
         'message': message.text       
     })
     related_messages = Message.all().filter('conver =', message.conver).fetch(1000)
     participating_permausers = [message.author for message in related_messages]
     participating_permausers.extend(message.conver.get_watchers())
     pp_ids = [pp.user_id() for pp in participating_permausers]
     pp_ids = list(set(pp_ids))
     for pp_id in pp_ids:
         # ugly, but for now everyone can just get the messages
         channel.send_message(pp_id + str(message.conver.key().id_or_name()), message_json)
开发者ID:lehrblogger,项目名称:Teatime_PageChat,代码行数:15,代码来源:handlers.py

示例11: get

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

        users = User.query().fetch()
        user_list = []
        for user in users:
            user_list.append(user) 

        message = Message.all() 
        message_list = []
        for msg in message:
            message_list.append(msg)               
    
        self.render_template('user_list.html', {'user_list': user_list, 'message_list': message_list})
开发者ID:swamy-nyros,项目名称:python-test-assignment,代码行数:15,代码来源:main.py

示例12: get

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import all [as 别名]
	def get(self):
		# We fetch all the accounts
		authors = Account.all()
		
		# We fetch the last ten messages
		message_query = Message.all().order('-date')
		messages = message_query.fetch(10)
		
		# Check if user is logged in
		unknown_user = False
		if users.get_current_user():
			# Generate the logout url
			url = users.create_logout_url(self.request.uri)
			url_linktext = 'Logout'
			anon = False

			# We check that the user is registered
			accounts = Account.all()
			accounts.filter('user = ', users.get_current_user())
			account = accounts.get()
			if account == None:
				unknown_user = True
		else:
			# Generate the login url
			url = users.create_login_url(self.request.uri)
			url_linktext = 'Login'
			anon = True
	  
		# Check if user is admin
		is_admin = users.is_current_user_admin()
	    
		# Choose a random title
   		titles = ('<a>PINT</a>Spot', '<a>PINT</a>ed', '<a>PINT</a>Me', '<a>PINT</a>Soft', '<a>PINT</a>Hard', '<a>PINT</a>SM', '<a>PINT</a>ware', '<a>PINT</a>BDSM', '<a>PINT</a>BSD', '<a>PINT</a>LSD', '<a>PINT</a>ou (or ubuntu)', '<a>PINT</a>ubuntu', 'i<a>PINT</a>', 'you<a>PINT</a>', 'Google <a>PINT</a>', '<a>PINT</a>Please', '<a>PINT</a>Sorry', '<a>PINT</a>Welcomed', '<a>PINT</a>Again', '<a>PINT</a>guin', 'JustOne<a>PINT</a>', 'JustAnother<a>PINT</a>', 'OneMore<a>PINT</a>', 'Bier&<a>PINT</a>', '<a>PINT</a>OfVodka', '<a>PINT</a>ade', '<a>PINT</a>aid', '<a>PINT</a>ADD', '<a>PINT</a>INC', '<a>PINT</a>agramme', '<a>PINT</a>-A-Gramme', '<a>PINT</a>-A-Kilo', 'Pound-A-<a>PINT</a>', 'Fish<a>PINT</a>', '<a>PINT</a>Sized', 'Mystic<a>PINT</a>', 'Super<a>PINT</a>', 'Hyper<a>PINT</a>', 'Quantic<a>PINT</a>', 'QuantumOf<a>PINT</a>', 'Electro<a>PINT</a>', 'Royal<a>PINT</a>', 'Republican<a>PINT</a>', 'YesWeCan...<a>PINT</a>', 'WhatTheFucking...<a>PINT</a>', 'IVotedFor<a>PINT</a>', 'WhatSThe<a>PINT</a>', '<a>PINT</a>Aday', '<a>PINT</a>IsMine', 'my<a>PINT</a>!', '<a>PINT</a>Book', '<a>PINT</a>Book-Air', 'less Air, more <a>PINT</a>', 'Apple<a>PINT</a>', 'Web<a>PINT</a>', 'Command+<a>PINT</a>', 'Ctrl+Meta+Alt+<a>PINT</a>', ':<a>PINT</a>', '3Click<a>PINT</a>', 'Black<a>PINT</a>', '<a>PINT</a>sh', '<a>PINT</a> (<a>PINT</a> Is Not Twilight)', 'tinP', 'tniP', 'Tonight<a>PINT</a>', 'Coffee<a>PINT</a>', 'Breakfast<a>PINT</a>', 'Bacon<a>PINT</a>', '<a>PINT</a>Pause', '<a>PINT</a>-nic', '<a>PINT</a>Address', '<a>PINT</a>Phone', 'Multi<a>PINT</a>', 'Simple<a>PINT</a>...', 'FourFingers<a>PINT</a>', 'Start<a>PINT</a>', 'Stop<a>PINT</a>', '<a>PINT</a>', '<a>PINT</a>EGER', 'FloatOr<a>PINT</a>', '<a>PINT</a>Pointer', 'Master<a>PINT</a>er', 'License<a>PINT</a>er', 'GNU<a>PINT</a>', '<a>PINT</a>ix', '<a>PINT</a>ux', '<a>PINT</a>ium', '<a>PINT</a>OS', 'ThanksForThe<a>PINT</a>', 'LordOfThe<a>PINT</a>', 'Piss<a>PINT</a>', '<a>PINT</a>8', '666 Number Of The <a>PINT</a>', 'Bug<a>PINT</a>', 'BlueScreenOf<a>PINT</a>', '<a>PINT</a>Panic', '<a>PINT</a>OSleep', '<a>PINT</a>craft', 'War<a>PINT</a>', '<a>PINT</a>OfDead', '<a>PINT</a>sOfTheCaribeans', 'TheLast<a>PINT</a>', '<a>PINT</a>:Revolution', '<a>PINT</a>:Resurrection', 'Evil<a>PINT</a>', 'TheIncredible<a>PINT</a> ', 'X<a>PINT</a> ', 'Y<a>PINT</a>', 'Why<a>PINT</a>', 'Inexhaustible<a>PINT</a>', 'SauronS<a>PINT</a>', 'Sleepy<a>PINT</a>', 'NeverSleep<a>PINT</a>', '<a>PINT</a>Wars', 'P1N7')
		random_title = random.choice(titles)
		
		# These values are to be sent to the template
		template_values = {
			'random_title': random_title,
			'unknown_user': unknown_user,
			'messages': messages,
			'authors': authors,
			'url': url,
			'url_linktext': url_linktext,
			'anon': anon,
			'is_admin': is_admin
		}
	
		# We get the template path then show it
		path = os.path.join(os.path.dirname(__file__), 'index.html')
		self.response.out.write(template.render(path, template_values))
开发者ID:engleek,项目名称:pintme,代码行数:52,代码来源:main.py

示例13: get

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import all [as 别名]
 def get(self):
     permauser = PermaUser.get_current_permauser()
     conver_url = utils.unescape(self.request.get('url'))
     conver = Conver.get_for_url(conver_url)
     messages = Message.all().filter('conver =', conver).order('created').fetch(1000)
     self.response.out.write(template.render(
         os.path.join(os.path.dirname(__file__),
         'templates/conver.html'), 
         {
             'token': channel.create_channel(permauser.user_id() + str(conver.key().id_or_name())),
             'conver_url': conver_url,
             'messages': [ {'author': message.author.display_name(), 'text': message.text} for message in messages],
             'loginorout_text': 'Log out',
             'loginorout_url': users.create_logout_url(self.request.uri)
         }
     ))
开发者ID:lehrblogger,项目名称:Teatime_PageChat,代码行数:18,代码来源:handlers.py

示例14: testPostMessage

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import all [as 别名]
    def testPostMessage(self):
        status, result = views.postMessage(self.n2, simulateUrl(self.n1), '2==>1')
        self.assertEqual(200, status)
        ms = Message.all().order('-timestamp')
        # Race condition: assume nobody else is posting messages!
        self.assertEqual('2==>1', ms[0].text)
        self.assertEqual(self.n2, ms[0].sender.name)
        self.assertEqual(self.n1, ms[0].recipient.name)
        ms[0].delete()

        # Message too long
        status, result = views.postMessage(self.n2, self.n1,
                                           '?' * (LIMITS['TEXT']+1))
        self.assertEqual(400, status)

        # User doesn't exist
        status, result = views.postMessage(self.n1, uuid.uuid4().hex, '??')
        self.assertEqual(404, status)
开发者ID:league,项目名称:cryptodemo,代码行数:20,代码来源:tests.py

示例15: get

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import all [as 别名]
 def get(self, server, channel):
     key = db.Key.from_path(Channel.kind(), '%s/%s' % (unquote(channel), server))
     channel = Channel.get(key)
     date = self.request.GET.get('date')
     if date:
         start_date = datetime.strptime(date, '%Y-%m-%d').date()
     else:
         start_date = datetime.utcnow().date()
     end_date = start_date + timedelta(days=1)
     messages = Message.all().filter('channel =', channel) \
                 .filter('timestamp >= ', start_date) \
                 .filter('timestamp < ', end_date) \
                 .order('timestamp')
     # date based pagination
     next_day = start_date + timedelta(days=1)
     if next_day > datetime.utcnow().date():
         next_day = None
     previous_day = end_date - timedelta(days=2)
     self.response.out.write(render('templates/channel.html', locals()))
     
开发者ID:sanyaade,项目名称:ircarchive,代码行数:21,代码来源:archive.py


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