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


Python Topic.put方法代码示例

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


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

示例1: post

# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import put [as 别名]
    def post(self):
        creator = users.get_current_user()
        title = self.request.get('title')
        descrip = self.request.get('descrip')

        start = util.convert_htmldatetime(self.request.get('start'))
        end = util.convert_htmldatetime(self.request.get('end'))
        slot_minutes = int(self.request.get('slot_minutes'))

        topic = Topic(
            creator=creator,
            title=title,
            descrip=descrip,
            start=start,
            end=end,
            slot_minutes=slot_minutes)
        topic.put()

        # Now create slots
        current_slot = start
        while (current_slot < end):
            slot = TopicSlot(start=current_slot, topic=topic)
            slot.put()
            current_slot += datetime.timedelta(minutes=slot_minutes)
        self.redirect(topic.full_link)
开发者ID:djensenius,项目名称:hangout-scheduler,代码行数:27,代码来源:pages.py

示例2: post

# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import put [as 别名]
 def post(self):
     topic = self.request.get('topic')
     description = self.request.get('description')
     if topic:
         user = self.user_info
         new_topic = Topic(topic=topic, description=description, createdBy=user['user_id'], modifiedBy=user['user_id'])
         new_topic.put()
         self.redirect(self.uri_for('home'))
     else:
         params = {
             'error': True,
             'topic': {
                 'topic': topic,
                 'description': description
             }
         }
         self.render_template('topiceditor.html', params)
开发者ID:anabarasan,项目名称:moderator2,代码行数:19,代码来源:Topics.py

示例3: create_topic

# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import put [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


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