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


Python Crud.create方法代码示例

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


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

示例1: add_log

# 需要导入模块: from gluon.tools import Crud [as 别名]
# 或者: from gluon.tools.Crud import create [as 别名]
def add_log():
	import re
	from datetime import datetime
	from gluon.tools import Crud
	pattern = re.compile(r"""
			\[(?P<time>.*?)\]
			\s(?P<mac>[0-9A-F]{2}[:][0-9A-F]{2}[:][0-9A-F]{2}[:][0-9A-F]{2}[:][0-9A-F]{2}[:][0-9A-F]{2})
			\s(?P<more>.*)
			\s*"""
			, re.VERBOSE)
	crud = Crud(db)
	form = crud.create(db.log)
	if form.process(dbio=False).accepted:
		form.vars.log_id = db.log.insert(**dict(form.vars))
		request.vars.log_file.file.seek(0)
		count=0
		for line in request.vars.log_file.file:
			#print 'l', line
			match = pattern.findall(line)	
			if match:
				d = datetime.strptime(match[0][0], '%m/%d/%y %H:%M:%S')
				db.record.insert(log_id=form.vars.log_id, 
						station_id=form.vars.station_id,
						mac=match[0][1], 
						gathered_on=d)			
				count += 1
		session.flash = 'Inserted %s record' % count
		redirect(URL(f='index', vars={'id':form.vars.station_id}))
	return response.render('default/index.html', dict(form=form))
开发者ID:BantouTelecom,项目名称:vtraffic,代码行数:31,代码来源:default.py

示例2: create

# 需要导入模块: from gluon.tools import Crud [as 别名]
# 或者: from gluon.tools.Crud import create [as 别名]
def create():
	from gluon.tools import Crud

	#Hide the fields that should not be accessable by the user
	hideFields (db.game, ['host_id', 'game_status', 'password'])

	#Run the form
	#form = SQLFORM(db.game)
	#form.add_class('assassins-form')
	#form.vars.host_id=auth.user.id

	#Create the form
	crud = Crud(db)
	crud.messages.submit_button = 'Create Game'
	form = crud.create(db.game)
	form.add_class('assassins-form')
	form.vars.host_id=auth.user.id

	#When the form is submitted, add the creator as a player and go to new game
	if form.process().accepted:
		addPlayer(form.vars.id, auth.user)
		resizeImage(db.game, form.vars.id)
		redirect(URL('game', 'detail', args=form.vars.id))

	return dict(form=form)
开发者ID:bejbej,项目名称:assassins,代码行数:27,代码来源:default.py

示例3: accessory_crud

# 需要导入模块: from gluon.tools import Crud [as 别名]
# 或者: from gluon.tools.Crud import create [as 别名]
def accessory_crud():
    """ Create a simple form using the CRUD function of web2py. """

    from gluon.tools import Crud
    crud = Crud(db)
    accessory_crud = crud.create(db.accessory)
    return locals()
开发者ID:JulianaTec,项目名称:TesteRepositorio3,代码行数:9,代码来源:forms.py

示例4: admin

# 需要导入模块: from gluon.tools import Crud [as 别名]
# 或者: from gluon.tools.Crud import create [as 别名]
def admin():

    args = request.args

    title = 'administration'

    if not args:
        link = UL(*[LI(A(tab,_href=URL(args=tab))) for tab in db.tables])
        return dict(items=link,title=title)

    if not args(1):
        i = 0
    else:
        i =1

    for tab in db.tables:
        if tab==args(i):
            tb = db[tab]

    crud = Crud(db)

    if args(0)=='edit':
        form = crud.update(tb, args(2),next=URL(f='admin',args=args(1)))
        items = None
        title = 'Edit %s ' % args(i)
    else:
        form = crud.create(tb)
        rows = db().select(tb.ALL)
        items = SQLTABLE(rows,linkto='edit')
        title = 'Insert %s ' % args(i)


    return dict(form=form,items=items,title=title)
开发者ID:JulianaTec,项目名称:TesteRepositorio3,代码行数:35,代码来源:veiculo.py

示例5: add_station

# 需要导入模块: from gluon.tools import Crud [as 别名]
# 或者: from gluon.tools.Crud import create [as 别名]
def add_station():
	from gluon.tools import Crud
	crud = Crud(db)
	form = crud.create(db.station)
	if form.process(dbio=True).accepted:
		session.flash = 'Station added correctly'
		redirect(URL(f='index'))
	return response.render('default/index.html', dict(form=form))
开发者ID:BantouTelecom,项目名称:vtraffic,代码行数:10,代码来源:default.py

示例6: autocomplet

# 需要导入模块: from gluon.tools import Crud [as 别名]
# 或者: from gluon.tools.Crud import create [as 别名]
def autocomplet():

    from gluon.tools import Crud
    crud = Crud(db)

    form = crud.create(db.product2, next=URL('autocomplet'),message=T("record created"))
    persons = crud.select(db.product2, fields=['category'],headers={'product2.category': 'Tipo'})

    return dict(form=form, persons=persons)
开发者ID:JulianaTec,项目名称:TesteRepositorio3,代码行数:11,代码来源:NovaManual.py

示例7: people

# 需要导入模块: from gluon.tools import Crud [as 别名]
# 或者: from gluon.tools.Crud import create [as 别名]
def people():

    from gluon.tools import Crud
    crud = Crud(db)

    form = crud.create(db.client, next=URL('people'),message=T("record created"))
    persons = crud.select(db.client, fields=['name'],headers={'client.name': 'Name'})

    return dict(form=form, persons=persons)
开发者ID:JulianaTec,项目名称:TesteRepositorio3,代码行数:11,代码来源:NovaManual.py

示例8: index

# 需要导入模块: from gluon.tools import Crud [as 别名]
# 或者: from gluon.tools.Crud import create [as 别名]
def index():
    """
    example action using the internationalization operator T and flash
    rendered by views/default/index.html or views/generic.html
    """
    from gluon.tools import Crud

    crud = Crud(db)

    form = crud.create(db.userskill)
    return dict(form=form)
开发者ID:csschwarz,项目名称:pyJigsawSkills,代码行数:13,代码来源:default.py

示例9: zuoye

# 需要导入模块: from gluon.tools import Crud [as 别名]
# 或者: from gluon.tools.Crud import create [as 别名]
def zuoye():
    zuozhe=auth.user_id
    keshi_id=request.args[0]
    crud=Crud(db)
    if db.zuoye((db.zuoye.zuozhe==zuozhe)&(db.zuoye.keshi==keshi_id)):
        db.zuoye.defen.writable=False
        zuoye_id=db.zuoye((db.zuoye.zuozhe==zuozhe)&(db.zuoye.keshi==keshi_id)).id
        form=crud.update(db.zuoye,zuoye_id,deletable=False,next=request.url)
        db.zuoye.defen.writable=True
    else:
        db.zuoye.zuozhe.default=zuozhe
        db.zuoye.keshi.default=keshi_id
        db.zuoye.defen.writable=False
        form=crud.create(db.zuoye,next=request.url)
      #  db.zuoye.zuozhe.default=None
        db.zuoye.keshi.default=None
        db.zuoye.defen.writable=True
    return dict(form=form)
开发者ID:chugle,项目名称:myapp,代码行数:20,代码来源:default.py

示例10: crud

# 需要导入模块: from gluon.tools import Crud [as 别名]
# 或者: from gluon.tools.Crud import create [as 别名]
def crud():
    tablename = request.args(0)
    action = request.args(1)
    record_id = request.get_vars['id']
    
    crud_ = Crud(shotdb)
    crud_.settings.controller  = 'config'
    crud_.settings.create_next = URL('config_event')
    crud_.settings.update_next = URL('config_event')
    crud_.settings.update_deletable = False
    crud_.settings.showid = True  
    
    if(action == 'add'):            
        crud_response = crud_.create(tablename)
    elif(action == 'edit' and record_id != None):
        crud_response = crud_.update(tablename, record_id)
    else:
        crud_response = 'Nothing selected!'
    
    return dict(crud_response = crud_response)
开发者ID:MichaelBechmann,项目名称:shot,代码行数:22,代码来源:config.py

示例11: crudeGeral

# 需要导入模块: from gluon.tools import Crud [as 别名]
# 或者: from gluon.tools.Crud import create [as 别名]
def crudeGeral():

    from gluon.tools import Crud
    crud = Crud(db)

    form = crud.create(db.client)

    id=1

    form2 = crud.read(db.client, id)

    form3 = crud.update(db.client, id)

    form4 = crud.search(db.client)

    #form5 = SQLFORM(db.client, myrecord).process(onsuccess=auth.archive)

    #form5 = crud.update(db.mytable, myrecord, onaccept=auth.archive)

    return dict(form=form,form2=form2,form3=form3,form4=form4)
开发者ID:JulianaTec,项目名称:TesteRepositorio3,代码行数:22,代码来源:NovaManual.py

示例12: createpost

# 需要导入模块: from gluon.tools import Crud [as 别名]
# 或者: from gluon.tools.Crud import create [as 别名]
def createpost():
    from gluon.tools import Crud
    crud = Crud(db)
    form = crud.create(db.blogpost) if auth.user else None
    return dict(form=form)
开发者ID:kmcdon10,项目名称:blogging_platform,代码行数:7,代码来源:default.py


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