本文整理汇总了Python中models.Message.objects方法的典型用法代码示例。如果您正苦于以下问题:Python Message.objects方法的具体用法?Python Message.objects怎么用?Python Message.objects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Message
的用法示例。
在下文中一共展示了Message.objects方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: obj_get_list
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import objects [as 别名]
def obj_get_list(self, bundle, **kwargs):
user = bundle.request.GET.get('user_id') #extracts user_id from URL params
if bundle.request.GET.get('received'):
received = False if bundle.request.GET.get('received') == "false" else True
return Message.objects(user_id=user, received=received)
else:
return Message.objects(user_id=user)
示例2: show_messages_from
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import objects [as 别名]
def show_messages_from(author_name):
"""
"""
messages = Message.objects(author=author_name).all()
for message in messages:
print message.to_json()
示例3: show_messages
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import objects [as 别名]
def show_messages():
"""
show all messages
note the exclude , dont show _id of messages
"""
messages = Message.objects().exclude('id')
for message in messages:
print message.to_json()
示例4: pixel
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import objects [as 别名]
def pixel(request, message_id):
message = Message.objects(id=str(message_id)).first()
if message and message.campaign:
c = message.campaign
c.inc_open()
try:
with open(path.join(path.dirname(__file__), 'static', 'pixel.jpg'), "rb") as f:
return HttpResponse(f.read(), content_type="image/jpeg")
except IOError:
#red = Image.new('RGBA', (1, 1), (255,0,0,0))
response = HttpResponse(content_type="image/jpeg")
#red.save(response, "JPEG")
return response
示例5: list_msg
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import objects [as 别名]
def list_msg():
page = request.args.get("page")
searchValue = request.args.get("searchValue")
if searchValue:
paginator =Message.objects(content__contains=searchValue).order_by('-time').paginate(page=int(page), per_page=5)
else:
paginator =Message.objects.order_by('-time').paginate(page=int(page), per_page=5)
pager = {
'page': paginator.page,
'pages': paginator.pages,
'messages': [m.to_json() for m in paginator.items]
}
return jsonify(status="success", pager=pager)
示例6: unsubscribe
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import objects [as 别名]
def unsubscribe(request, message_id):
message = Message.objects(id=str(message_id)).first()
if message and message.campaign:
message.campaign.inc_optout()
subscriber = Subscriber.objects(email=message.email_to).first()
if subscriber:
subscriber.active = False
subscriber.deactivate_reason = 'Unsubscribed from message #{}'.format(message.id)
subscriber.save()
unsub = Unsubscribe.objects().first()
if unsub and unsub.redirect_url:
return redirect(unsub.redirect_url)
return redirect(UNSUBSCRIBE_URL)
示例7: pyforum_message_view
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import objects [as 别名]
def pyforum_message_view(self):
id_topic = self.request.matchdict['id_topic']
topic_title = self.request.matchdict['topic_title']
topics = Message.objects().filter(topic__icontains=id_topic)
form = Form(self.request,schema=MessageSchema())
if form.validate():
context = {'name' : form.data['name'],
'description': form.data['description'],
'topic': id_topic}
Message.add(context)
return HTTPFound(location='/message_list/{0}/{1}'.format(id_topic,topic_title))
return {'title': 'List View PyForum',
'topics':topics,
'id_topic':id_topic,
'topic_title':topic_title,
'form' : FormRenderer(form)
}
示例8: click
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import objects [as 别名]
def click(request, message_id):
redirect_to = request.GET.get('url')
if not redirect_to:
return HttpResponse()
message = Message.objects(id=str(message_id)).first()
if message and message.campaign:
c = message.campaign
c.inc_click()
if REDIRECT_FOLLOW:
try:
res = requests.head(redirect_to, allow_redirects=True, timeout=100.0)
redirect_to = res.url
except Exception, e:
log.warning(u'Unable to follow url {}, error {}'.format(redirect_to, e))
redirect_to = add_utm(redirect_to,
c.get_utm_campaign(),
c.get_utm_source(),
'email',
c.get_utm_content())
示例9: display_froms
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import objects [as 别名]
def display_froms():
email_authors = Message.objects().distinct(field="from_str")
for x in email_authors[:25]:
print x
print "%s unique email authors" % (len(email_authors))
示例10: display_from
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import objects [as 别名]
def display_from(email_addr):
emails = Message.objects(from_str=email_addr).all()
count = emails.count()
print "%s emails found authored by '%s'" % (count, email_addr)
g = graph.generate_graph(emails)
graph.display_graph(g)
示例11: OptionParser
# 需要导入模块: from models import Message [as 别名]
# 或者: from models.Message import objects [as 别名]
base.init()
#
# Get Command Line Options
#
parser = OptionParser(description="Generate a graph from email data")
parser.add_option("--limit", action="store", help="Limit number of messages to parse", default=0)
parser.add_option("--display", action="store_true", help="Display a png graph, only useful for small number of messages")
parser.add_option("--dump", action="store_true", help="Dump a textual listing of each edge ('message') to console")
parser.add_option("--name", action="store", help="Output filename for graph in gexf format",
default="enron_email_graph.gexf")
(opts, args) = parser.parse_args()
#
# Fetch messages
#
start = time.time()
msgs = Message.objects()
limit = int(opts.limit)
if limit > 1:
msgs = msgs.limit(limit)
graph = generate_graph(msgs)
b_time = time.time()
print "Finished generating graph for %s messages in %s seconds" % (len(msgs), b_time-start)
if opts.display and limit < 500:
display_graph(graph)
if opts.dump:
print_graph(graph)
c_time = time.time()
write_graph(graph, opts.name)
end = time.time()