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


Python Blog.insert方法代码示例

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


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

示例1: api_create_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import insert [as 别名]
def api_create_blog():
    check_admin()
    i = ctx.request.input(name='', content='')
    name = i.name.strip()
    content = i.content.strip()
    if not name:
        raise APIValueError('name', 'name cannot be empty.')
    if not content:
        raise APIValueError('content', 'content cannot be empty.')
    user = ctx.request.user
    blog = Blog(name=name, content=content)
    blog.insert()
    return blog
开发者ID:fengyuqi,项目名称:ymtx,代码行数:15,代码来源:urls.py

示例2: api_create_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import insert [as 别名]
def api_create_blog():
    i = ctx.request.input(name="", summary="", content="")
    name = i.name.strip()
    summary = i.summary.strip()
    content = i.content.strip()
    if not name:
        raise APIValueError("name", "name cannot be empty.")
    if not summary:
        raise APIValueError("summary", "summary cannot be empty.")
    if not content:
        raise APIValueError("content", "content cannot be empty.")
    user = ctx.request.user
    blog = Blog(user_id=user.id, user_name=user.name, name=name, summary=summary, content=content)
    blog.insert()
    return blog
开发者ID:skyoskiyqq,项目名称:JnswWebApp,代码行数:17,代码来源:urls.py

示例3: api_create_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import insert [as 别名]
def api_create_blog():
    i = ctx.request.input(name='',summary='',content='')
    name = i.name.strip()
    summary = i.summary.strip()
    content = i.content.strip()
    if not name:
        raise APIValueError('name','name cannot be empty.')
    if not summary:
        raise APIValueError('summary','summary cannot be empty.')
    if not content:
        raise APIValueError('content','content cannot be empty.')
    user = ctx.request.user
    blog = Blog(user_id=user.id,user_name=user.name,name=name,summary=summary,content=content)
    blog.insert()
    return blog
开发者ID:wenhuwang,项目名称:awesome-webapp,代码行数:17,代码来源:urls.py

示例4: api_create_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import insert [as 别名]
def api_create_blog():
    check_admin()
    i = ctx.request.input(name='', summary='', content='')
    name = i.name.strip()
    summary = i.summary.strip()
    content = i.content.strip()
    if not name:
        raise APIValueError('name', 'name cannot be empty.')
    if not summary:
        raise APIValueError('summary', 'summary cannot be empty.')
    if not content:
        raise APIValueError('content', 'content cannot be empty.')
    user = ctx.request.user
    blog = Blog(user_image='http://7mnmgy.com1.z0.glb.clouddn.com/boy.jpeg',user_id=user.id, user_name=user.name, name=name, summary=summary, content=content)
    blog.insert()
    return blog
开发者ID:akicqi,项目名称:python_mini_blog,代码行数:18,代码来源:urls.py

示例5: api_create_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import insert [as 别名]
def api_create_blog():
	check_admin()
	i = ctx.request.input(name='', summary='', content='')
	name = i.name.strip()
	summary = i.summary.strip()
	content = i.content.strip()

	if not name:
		raise APIValueError('name', 'name cannot be empty!')
	if not summary:
		raise APIValueError('summary', 'summary cannot be empty!')
	if not content:
		raise APIValueError('content', 'content cannot be empty!')
	# more valite rule here ....
	user = ctx.request.user
	blog = Blog(user_id=user.id, user_name=user.name, name=name, summary=summary, content=content)
	blog.insert()
	logging.info('New blog :%s ...' % name)
	return blog
开发者ID:Csdypg,项目名称:first-python-webapp,代码行数:21,代码来源:urls.py

示例6: api_create_blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import insert [as 别名]
def api_create_blog():
    check_admin()
    i = ctx.request.input(title='', content='')
    logging.info(i)
    title = i.title.strip()
    content = i.content.strip()
    image = i.image
    tags = i.tags.strip()
    if image:
        logging.info("upload image name:%s,type:%s" % (image.filename,type(image.filename)))
    if not title:
        raise APIValueError('name', 'name cannot be empty.')
    #if not summary:
        #raise APIValueError('summary', 'summary cannot be empty.')
    if not content:
        raise APIValueError('content', 'content cannot be empty.')
    if not image:
        raise APIValueError('image', 'image cannot be empty.')
    filename = upload(image)
    user = ctx.request.user
    blog = Blog(user_id=user.id,  title=title,  content=content,image=filename)
    blog.insert()
    add_tags(blog.id,tags.split(' '))
    raise seeother('/blog/%s' % blog.id)
开发者ID:lixiangbest,项目名称:jblog,代码行数:26,代码来源:urls.py

示例7: User

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import insert [as 别名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-

__author__ = 'zathing'

from models import User, Blog, Comment
from transwarp import db

db.create_engine(user='www-data', password='www-data', database='awesome')

# u = User(name='Admin', email='[email protected]', password='123456', image='about:blank')
# u.insert()
# print('new user id:', u.id)
# u1 = User.find_all()
# print('find user\'s name:', u1.name)
# u1.delete()
# u2 = User.find_first('where email=?', '[email protected]')
# print('find user:', u2)

b = Blog(user_id='001438829058093496ac7e066b740b8b8f14b20f5e8a035000', user_name='Admin', user_image='about:blank', name = '子牙说', summary='一个全新的开始!', content = 'test')
b.insert()
print('Done')
开发者ID:zathing,项目名称:awesome-python-webapp,代码行数:24,代码来源:test_db.py

示例8: Blog

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import insert [as 别名]
db.create_engine(user = 'root', password = '123456', database='awesome')

user = User.find_first('where email = ?', '[email protected]')

##blog = Blog(user_id = user.id, user_name = user.name, user_image = 'about:blank', 
##	name = u'第一篇博客', summary = u'虽然我们跑通了一个最简单的MVC,但是页面效果肯定不会让人满意。对于复杂的HTML前端页面来说,我们需要一套基础的CSS框架来完成页面布局和基本样式。另外,jQuery作为操作DOM的JavaScript库也必不可少。'
##	content = u"虽然我们跑通了一个最简单的MVC,但是页面效果肯定不会让人满意。对于复杂的HTML前端页面来说,我们需要一套基础的CSS框架来完成页面布局和基本样式。另外,jQuery作为操作DOM的JavaScript库也必不可少。"
##	)

blog2 = Blog(user_id = user.id, user_name = user.name, user_image = 'about:blank', 
	name = "第二篇博客", summary = "虽然我们跑通了一个最简单的MVC,但是页面效果肯定不会让人满意。对于复杂的HTML前端页面来说,我们需要一套基础的CSS框架来完成页面布局和基本样式。另外,jQuery作为操作DOM的JavaScript库也必不可少。",
	content = "虽然我们跑通了一个最简单的MVC,但是页面效果肯定不会让人满意。对于复杂的HTML前端页面来说,我们需要一套基础的CSS框架来完成页面布局和基本样式。另外,jQuery作为操作DOM的JavaScript库也必不可少。"
	)

##blog.insert()
blog2.insert()

#u = User(name='Test', email = '[email protected]', password = '123456', image='about:blank')

#u.insert()

#print 'new user.id', u.id

#uu = User(name = 'Test2', email = '[email protected]', password = '123', image = '')

#uu.insert()

#print 'new user.id', uu.id

##u1 = User.find_first('where email = ?', '[email protected]')
开发者ID:lnetmor,项目名称:awesome-python-webapp,代码行数:32,代码来源:test_db.py

示例9: User

# 需要导入模块: from models import Blog [as 别名]
# 或者: from models.Blog import insert [as 别名]
__author__ = 'fang'

from models import User, Blog, Comment

from transwarp import db

db.create_engine(user='root', password='password',database='awesome')

u = User(name='Administrato', email='[email protected]', password='1234567890', image='about:blank')

u.insert()
print 'new user:', u
u.delete()

b1 = Blog(user_id='0014347129972910bbdee0a188f412394d92e5e5a299939000', user_name='Administrator',
	name = 'FirstBlog', summary='Test', content = 'Test.')

b1.insert()
print 'new blog:', b1
b1.delete()



'''
u1 = User.find_first('where email=?', '[email protected]')
print 'find user\'s name:', u1.name

u2 = User.find_first('where email=?', '[email protected]')
print 'find user:', u2
'''
开发者ID:cnu4,项目名称:awesome-blog,代码行数:32,代码来源:test_db.py


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