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


Python Message.put方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import put [as 别名]
 def post(self):
     "We receive post data from IMified"
     userkey = self.request.get('userkey')
     network = self.request.get('network')
     # remove any markup from messages
     msg = HTML_ELEMENTS.sub('', self.request.get('msg'))
     step = self.request.get('step')
     try:
         # we try and create the message
         message = Message(
             userkey = userkey,
             network = network,
             msg = msg,
             step = int(step)
         )   
         message.put()
         # send an email with the message on
         mail.send_mail(sender="[email protected]",
                       to="Gareth Rushgrove <[email protected]>",
                       subject="New message posted on IMified demo",
                       body=msg)
         # we just added a message so we need to clear our cache
         memcache.delete("index")
         # simple logging
         logging.info("Saved new message")
         # the response is send as an IM message to the sender
         self.response.out.write('Message saved')
     except:
         # we'll log the error if it occurs
         # and report we couldn't save the message to the sender
         logging.error("Error occured creating new message")
         self.response.out.write('An error ocured, message not saved')
开发者ID:frankk00,项目名称:appengine-imified,代码行数:34,代码来源:main.py

示例2: post

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import put [as 别名]
    def post(self, *args, **kwargs):
        groupname = kwargs['groupname']
        query = Group.query(Group.name == groupname)
        groups = query.fetch()
        if len(groups) == 1:
            thisGroup = groups[0]
        else:
            thisGroup = None


        user = self.user

        print(user)
        if user:
            memberships = GroupMembership.query(GroupMembership.userKey == user.key,
                                                GroupMembership.groupKey == thisGroup.key).fetch()
            if len(memberships) == 1:
                membership = memberships[0]
                print(membership)
            else:
                self.display_message('You can only post if you\'re a member')

                return

        if user:
            print(self.request.get('message'))
            newMessage = Message(parent=thisGroup.key, userKey=user.key, text=self.request.get('message'))
            newMessage.put()

        self.redirect('/{groupname}/show'.format(groupname = groupname))
开发者ID:fi4sk0,项目名称:supertinygroupware,代码行数:32,代码来源:main.py

示例3: put

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import put [as 别名]
 def put():
     key = ndb.Key('Message', pk)
     msg = key.get()
     if msg:
         msg = Message(key=key, **form.data)
         msg.put()
     return msg
开发者ID:tarvitz,项目名称:test-work,代码行数:9,代码来源:views.py

示例4: post

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import put [as 别名]
 def post(self):
   text = cgi.escape(self.request.get('text'))
   sender = cgi.escape(self.request.get('sender'))
   recipient = cgi.escape(self.request.get('recipient'))
   subject = cgi.escape(self.request.get('subject'))
   parent_message = cgi.escape(self.request.get('parent'))
   q = User.query(User.username == recipient)
   user = q.get()
   if(user):
     if len(parent_message) > 0:
       message_key = ndb.Key(urlsafe=parent_message)
       message = Message(parent = message_key)
     else:
       message = Message()
     message.subject = subject
     message.text = text
     message.sender = sender
     message.recipient = recipient
     message.time = datetime.datetime.now() - datetime.timedelta(hours=7) #For PST
     message.put()
     #Increment message count for navbar
     q = User.query(User.username == recipient)
     user = q.get()
     user.message_count += 1
     user.put()
     self.redirect('/messages')
   else:
     self.redirect('/compose')
开发者ID:tungply7,项目名称:Tutoring-Service,代码行数:30,代码来源:Messages.py

示例5: contact

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import put [as 别名]
def contact():
    form = ContactForm()
    if form.validate_on_submit():
        message = Message(content = form.content.data)
        message.put()
        flash('Thanks, your message has been submitted')
        return redirect(url_for('contact'))
    return render_template('contact.html', form=form)
开发者ID:yhyap,项目名称:lipsum,代码行数:10,代码来源:views.py

示例6: post

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import put [as 别名]
    def post(self):
        sender = self.request.get("sender")
        recipient = self.request.get("recipient")
        subject = self.request.get("subject")
        message = self.request.get("message")

        composed_message = Message(sender=sender, recipient=recipient, subject=subject, message=message)
        composed_message.put()
        return self.render_template("success.html")
开发者ID:laurabolcina,项目名称:GAE,代码行数:11,代码来源:main.py

示例7: post

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import put [as 别名]
    def post(self):
        input_message = self.request.get("input_message")

        message = Message(text_entered=input_message)
        message.put()

        #return self.write("You've entered: " + input_message)

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

示例8: post

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

        errors = list()
        post = self.request.POST

        if "namespace" in post:
            namespace_name = post["namespace"].lower()
            query = db.GqlQuery("SELECT * FROM Namespace WHERE name = :1", namespace_name)
            namespace = query.get()
            if not namespace:
                errors.append("Namespace: not found")
            else:
                namespace_owner = namespace.owner
            if "auth_key" in post:
                auth_key = post["auth_key"]
                if namespace:
                    if auth_key != namespace.auth_key:
                        errors.append("AuthKey: not authorised")
            else:
                errors.append("AuthKey: not specified")
        else:
            errors.append("Namespace: not specified")

        if "name" in post:
            name = str(post["name"].lower())
            name = name[:100]
            if len(name) < 4:
                errors.append("Name: too short")
        else:
            errors.append("Name: not specified")

        if "level" in post:
            level = post["level"]
            if level not in ["debug", "info", "warn", "error", "fatal"]:
                level = "info"
            level_int = level_string_to_number(level)
        else:
            errors.append("Level: not specified")

        if "body" in post:
            body = str(post["body"])
            if len(body) < 1:
                errors.append("Body: too short")
        else:
            errors.append("Body: not specified")

        success = (len(errors) == 0)
        message_key = None
        
        if success:
            message = Message(namespace=namespace, namespace_owner=namespace_owner, name=name, level=level_int, auth_key=auth_key, body=body)
            message.put()
            message_key = str(message.key())
            memcache.set("message_latest_%s" % (namespace_owner), {"key": message_key, "namespace": namespace.name, "name": message.name, "level": message.level_string().upper(), "body": message.body, "created": message.created.strftime("%Y-%m-%d %H:%M:%S")})

        self.generate("rest/message_create.xml", {"success": success, "errors": errors, "key": message_key}) 
开发者ID:jinglemansweep,项目名称:log4gae,代码行数:58,代码来源:message.py

示例9: post

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import put [as 别名]
    def post(self):
    	message, recipient = self.get_params(['message','recipient'])
    	sender = self.request.cookies.get('username')
    	message = scrub_HTML(message)

    	m_db = Message(sender=sender, recipient=recipient, message=message)
    	m_db.put()

    	date = datetime.now()
    	self.render('message_val.html', {'recipient':recipient, 'message':message, 'date':date})
开发者ID:kennysong,项目名称:udacityplus,代码行数:12,代码来源:messages.py

示例10: post

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import put [as 别名]
 def post(self):
     recipient = self.request.get("recipient")
     body = self.request.get("body")
     title = self.request.get("title")
     msg = Message(sender=str(engine.globals['user']), recipient=recipient, title=title, body=body)
     msg.put()
     template_values = engine.globals
     template_values['message'] = msg
     template = engine.jinja_environment.get_template('messages/confirm.html')
     self.response.out.write(template.render(template_values))
开发者ID:e911miri,项目名称:unicorn,代码行数:12,代码来源:views.py

示例11: get

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import put [as 别名]
 def get(self):
     user = MyUser.get_by_auth_id('[email protected]')
     # self.response.write(user)
     m = Message(
         sent_by=user.key,
         sent_to=user.key,
         subject='Message Subject',
         message='Message Body'
     )
     m.put()
开发者ID:s2krish,项目名称:opchallenge,代码行数:12,代码来源:handlers.py

示例12: post

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import put [as 别名]
    def post(self):
        name = self.request.get("ime")
        email = self.request.get("mail")
        message = self.request.get("sporocilo")

        whole_message = Message(ime=name,mail=email,sporocilo=message)
        whole_message.put()

        params = {"name":name, "email":email,"message":message}
        self.render_template("izpis.html",params=params)
开发者ID:matejagustin,项目名称:base_jinja,代码行数:12,代码来源:main.py

示例13: post

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import put [as 别名]
 def post(self):
     text = self.request.get('text')
     if text:
         conver_url = utils.unescape(self.request.get('url'))
         conver = Conver.get_for_url(conver_url)
         message = Message(author=PermaUser.get_current_permauser(), text=text, conver=conver)
         message.put()
         self.distribute_message(message)
         
     else:
         logging.error("No message '%S'saved for %s", text, conver_url)
开发者ID:lehrblogger,项目名称:Teatime_PageChat,代码行数:13,代码来源:handlers.py

示例14: post

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

        if not conversation or self.user.key not in conversation.visibleto_user_keys:
            return self.abort(404)

        message = Message(conversation_key=conversation.key, sender_key=self.user.key, body=self.request.body)
        message.put()

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

示例15: post

# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import put [as 别名]
	def post(self):
		# Set up the message instance
		message = Message()
		
		message.author = users.get_current_user()
		
		if self.request.get('content') != '':
			message.content = self.request.get('content')
			message.put()
	  
		self.redirect('/')
开发者ID:engleek,项目名称:pintme,代码行数:13,代码来源:main.py


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