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


Python Message.get方法代码示例

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


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

示例1: get

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import get [as 别名]
    def get(self):
        try:
            if self.request.get('key'):
                item = Message.get( self.request.get('key') )

                vals = {
                    'item' : item,
                    }
                self.template( 'message-del.html', vals, 'admin' );
            else:
                self.redirect('.')
        except:
            self.redirect('.')
开发者ID:ranginui,项目名称:kohacon,代码行数:15,代码来源:message.py

示例2: ajax_message

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import get [as 别名]
def ajax_message():
    Message.create(
        user_id=session['user_id'],
        content=request.form["message_text"]
    )
    message = Message.get(Message.content == request.form["message_text"])
    message_info = session['first_name'] + " " + session['last_name'] + " - "
    message_info += message.created_at.strftime("%B %d %Y")
    message_dict = {
        "message": message.content,
        "message_info": message_info,
        "message_id": message.id,
    }
    return jsonify(message_dict)
开发者ID:LawerenceLee,项目名称:coding_dojo_projects,代码行数:16,代码来源:app.py

示例3: post

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import get [as 别名]
 def post(self):
     try:
         item = Message.get( self.request.get('key') ) if self.request.get('key') else None
         if item is not None:
             try:
                 item.delete()
                 self.redirect('.')
             except:
                 vals = {
                     'item' : item,
                     'err' : 'There was an error when deleting this message, please try again'
                     }
                 self.template( 'message-del.html', vals, 'admin' );
     except:
         self.redirect('.')
开发者ID:ranginui,项目名称:kohacon,代码行数:17,代码来源:message.py

示例4: create_topic

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import get [as 别名]
def create_topic():
    title = start = end = parent_topic_key = ''
    message = None
    
    if request.method == 'POST':
        title = request.form.get('title')
        if not title:
            flash('Title required.', 'error')
        else:
            topic = Topic(title=title, author=g.user)
            parent_topic_key = request.form.get('parent_topic_key')
            parent_topic = None
            if parent_topic_key:
                parent_topic = Topic.get(parent_topic_key)
                topic.parent_topic = parent_topic
            start = request.form.get('start')
            if start:
                try:
                    start = datetime.strptime(start, '%Y-%m-%d %H:%M')
                except ValueError:
                    start = datetime.now()
                topic.start = start
            end = request.form.get('end')
            if end:
                try:
                    end = datetime.strptime(end, '%Y-%m-%d %H:%M')
                    topic.end = end
                except ValueError:
                    pass
            new_topic_key = topic.put()
            if parent_topic:
                parent_topic.child_topics.append(new_topic_key)
                parent_topic.put()
            flash('Topic "%s" created.!' % title)
            return redirect(url_for('discussion', topic_key=new_topic_key))
    elif request.method == 'GET':
        message_key = request.args.get('message_key')
        if message_key:
            message = Message.get(message_key)
            parent_topic_key = str(message.topic.key())
            start = datetime.now().strftime('%Y-%m-%d %H:%M')
            title = 'On - %s' % message.content

    return render_template('index.html', title=title, start=start, end=end, 
                           parent_topic_key=parent_topic_key, message=message)
开发者ID:ouxuedong,项目名称:dod-app,代码行数:47,代码来源:main.py

示例5: _process_rmq_message

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import get [as 别名]
 def _process_rmq_message(self, rmq_message):
   try:
     rmq_message = json.loads(rmq_message)
     channel = Channel.get(
         Channel.id == rmq_message['channel_id']
     )
     user = User.get(
         User.id == rmq_message['user_id']
     )
     message = Message.get(
         Message.id == rmq_message['message_id']
     )
     plugin_name = rmq_message['plugin_name']
     plugin_response = rmq_message['plugin_response']
     return channel, user, message, plugin_name, plugin_response
   except Exception as e:
     self.error(e)
     return None, None, None, None, None
开发者ID:gabeos,项目名称:slackotron,代码行数:20,代码来源:slackotron.py

示例6: post

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import get [as 别名]
  def post(self, messageid):
    # Retrieve the message, make sure it exists
    message = Message.get(messageid)
    if message is None:
       logging.debug("Message %s does not exist, returning 200" % (messageid, ))
       self.response.set_status(200)
       return

    # Assume all deliveries are successful (i.e. this task is done)
    deliveriessucceeded = True

    # For this message, process those deliveries that have not yet been
    # delivered (status will be None)
    for delivery in Delivery.all().filter('message =', message).filter('status =', None):
      logging.debug("Processing delivery %s" % (delivery.key(), ))

      # Make the delivery with a POST to the recipient's resource
      # sending the published body, with the published body's content-type
      status = 999
      try:
        result = urlfetch.fetch(
          url = delivery.recipient.resource,
          payload = message.body,
          method = urlfetch.POST,
          headers = { 'Content-Type': message.contenttype },
          follow_redirects = False,
        )
        status = result.status_code
      except: 
        logging.error("urlfetch encountered an EXCEPTION")

      # If we've had a successful status then consider this 
      # particular delivery done. Otherwise, mark the delivery
      # as failed.
      if status < 400:
        delivery.status = STATUS_DELIVERED
        delivery.put()
      else:
        deliveriessucceeded = False

    # If there are failed deliveries, mark this task as failed
    # so that the task queue mechanism will retry.
    if not deliveriessucceeded:
      self.response.set_status(500)
开发者ID:qmacro,项目名称:coffeeshop,代码行数:46,代码来源:coffeeshop.py

示例7: get

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import get [as 别名]
  def get(self, channelid, messageid):
    message = Message.get(messageid)
    if message is None:
      self.response.out.write("Message %s not found" % (messageid, ))
      self.response.set_status(404)
      return

    deliveries = Delivery.all().filter('message =', message)

    channelurl = "%s://%s/channel/%d/" % (self.request.scheme, self.request.host, message.channel.key().id())

    # Poor conneg
    if (self.request.headers.has_key('Accept')
      and self.request.headers['Accept'] == CT_JSON):
      logging.info("JSON requested")
      deliveryinfo = []
      for d in deliveries:
        deliveryinfo.append({
          'recipient': "%ssubscriber/%d/" % (channelurl, d.recipient.key().id()),
          'status': d.status,
          'timestamp': d.updated.strftime("%Y-%m-%dT%H:%M:%SZ"),
      })
      info = {
        'message': {
          'resource': "%smessage/%s" % (channelurl, str(message.key())),
          'key': str(message.key()),
          'created': message.created.strftime("%Y-%m-%dT%H:%M:%SZ"),
          'channel': channelurl,
          'delivery': deliveryinfo,
        },
      }
      self.response.out.write(simplejson.dumps(info))
      self.response.headers['Content-Type'] = CT_JSON
      return

    template_values = {
      'message': message,
      #'deliveries': Delivery.all().filter('message =', message),
      'deliveries': deliveries,
    }
    path = os.path.join(os.path.dirname(__file__), 'messagedetail.html')
    self.response.out.write(template.render(path, template_values))
开发者ID:qmacro,项目名称:coffeeshop,代码行数:44,代码来源:coffeeshop.py

示例8: get

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import get [as 别名]
 def get(self, key):
     template_values = engine.globals
     template_values['message'] = Message.get(cgi.escape(key))
     template = engine.jinja_environment.get_template('messages/show.html')
     self.response.out.write(template.render(template_values))
开发者ID:e911miri,项目名称:unicorn,代码行数:7,代码来源:views.py

示例9: post

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import get [as 别名]
 def post(self):
     entry = Message.get(self.request.get("key"))
     entry.name = self.request.get("name")
     entry.content = self.request.get("content")
     entry.put()
     self.redirect("/")
开发者ID:wyattdanger,项目名称:crudify,代码行数:8,代码来源:main.py

示例10: get

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import get [as 别名]
 def get(self, key):
     path = os.path.join(os.path.dirname(__file__), "templates/edit.html")
     target = Message.get(key)
     self.response.out.write(template.render(path, {"message": target}))
开发者ID:wyattdanger,项目名称:crudify,代码行数:6,代码来源:main.py


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