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


Python Blog.categorie方法代码示例

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


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

示例1: newPost

# 需要导入模块: from blog.models import Blog [as 别名]
# 或者: from blog.models.Blog import categorie [as 别名]
    def newPost(self, blogid, username, password, struct, publish):
        self.__isUser(username, password)
        # print(("blogid:", blogid))
        # print(("struct:", struct))

        title = struct['title']
        content = struct['description']
        categorie = struct['categories'][0]

        #生成静态HTML文件
        id = None
        try:
            path = r'{0}/templates'.format(os.path.dirname(__file__))
            id = len(sum([i[2] for i in os.walk(path)], []))
            # print("博客ID:", id)
            static(id, content, categorie, title)

            blog = Blog()
            blog.blog_id = id
            blog.title = title
            blog.categorie = categorie
            blog.content = content
            blog.summary = get_summary(content, 150, u'...')
            blog.post_time = datetime.datetime.today()
            blog.save()

        except Exception as e:
            error_log.error("生成静态文件失败:{0}".format(e))

        return id
开发者ID:mazhenpy,项目名称:pylabsite,代码行数:32,代码来源:views.py

示例2: to_mysql

# 需要导入模块: from blog.models import Blog [as 别名]
# 或者: from blog.models.Blog import categorie [as 别名]
def to_mysql(req):
    path = r'{0}/templates'.format(os.path.dirname(__file__))
    num = len(sum([i[2] for i in os.walk(path)], [])) - 1
    id = 1
    for i in range(num):
        url = "{0}/templates/{1}.html".format(os.path.dirname(__file__), id)
        #url = "blog/templates/1.html"
        try:
            soup = BeautifulSoup(open(url, encoding="UTF-8"))
            if len(soup):
                categorie = soup.find(id='categorie').string
                blog_id = id
                title = soup.find(id='blog_title').string
                post_time = str(soup.find(id='blog_post_time'))[35:45]

                blog = Blog()
                blog.blog_id = blog_id
                blog.title = title
                blog.post_time = post_time
                blog.categorie = categorie
                blog.save()
            else:
                break
        except Exception as e:
            error_log.error(e)
        finally:
            id += 1
    return HttpResponse("<div style='text-align:center;'>{0} - To-Mysql-Done</div>".format(id))
开发者ID:mazhenpy,项目名称:pylabsite,代码行数:30,代码来源:views.py


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