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


Python Message.objects方法代码示例

本文整理汇总了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)
开发者ID:danboey,项目名称:LocationBasedMessaging,代码行数:9,代码来源:api.py

示例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()
开发者ID:cocoon-project,项目名称:restful-workshop,代码行数:9,代码来源:mdb_stage2.py

示例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()
开发者ID:cocoon-project,项目名称:restful-workshop,代码行数:10,代码来源:mdb_stage2.py

示例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
开发者ID:harabchuk,项目名称:wisemessage,代码行数:15,代码来源:views.py

示例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)
开发者ID:MwzkQmuUZkFLbXm,项目名称:message-board,代码行数:16,代码来源:views.py

示例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)
开发者ID:harabchuk,项目名称:wisemessage,代码行数:18,代码来源:views.py

示例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)
            }
开发者ID:tgonzales,项目名称:pyramid-forum,代码行数:20,代码来源:views.py

示例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())
开发者ID:harabchuk,项目名称:wisemessage,代码行数:21,代码来源:views.py

示例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))
开发者ID:jwmatthews,项目名称:BumptUp,代码行数:8,代码来源:explore.py

示例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)
开发者ID:jwmatthews,项目名称:BumptUp,代码行数:8,代码来源:explore.py

示例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()
开发者ID:jwmatthews,项目名称:BumptUp,代码行数:33,代码来源:graph.py


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