本文整理汇总了Python中models.Message.date方法的典型用法代码示例。如果您正苦于以下问题:Python Message.date方法的具体用法?Python Message.date怎么用?Python Message.date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Message
的用法示例。
在下文中一共展示了Message.date方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_messages
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import date [as 别名]
def process_messages(limit):
count = 0
date_parser = dateutil.parser.parser()
omsgs = OriginalMessage.objects()
if limit:
omsgs = omsgs.limit(limit)
for raw_count, om in enumerate(omsgs):
m = Message()
m.body = om.body
m.subFolder = om.subFolder
m.filename = om.filename
m.headers = om.headers
m.subject = om.get_subject()
m.date = date_parser.parse(om.get_date())
m.to = [x for x in om.get_to() if "enron.com" in x]
if not m.to:
# Skip if none of the "To's" are to enron employees
continue
m.from_str = om.get_from()
if "enron.com" not in m.from_str:
# Skip if this email was not from an enron employee
continue
try:
m.save()
except Exception, e:
print "Error trying to save: %s" % (m)
print e
count+=1
if count % 5000 == 0:
print "Processing %s raw messages, filtered to %s" % (raw_count, count)
示例2: send
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import date [as 别名]
def send(request):
if request.method == 'POST':
if len(request.POST[u'message_to_random_user']):
message = Message()
message.from_user = request.user
message.to_user = get_random_user(request.user)
message.message = request.POST[u'message_to_random_user']
message.date = datetime.now()
message.save()
return render(request, 'send.html', {'rand_user': get_random_user(request.user)})
示例3: convertItem
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import date [as 别名]
def convertItem(self, item, minDate):
date = parser.parse(item.pubDate.string)
# Check if needs to parse
if minDate and minDate >= date:
return
message = self.cleanTag(item.title.string)
author = item.find(name='creator', text=False).string
url = item.link.string
text = u'<b>%s:</b> %s \n\n<a href="%s">%s</a>' \
% (author, message, url, url)
message = Message()
message.text = text
message.date = date
return message