def build_web2py_environment(self): "build a namespace suitable for editor autocompletion and calltips" # warning: this can alter current global variable, use with care! try: from gluon.globals import Request, Response, Session from gluon.compileapp import build_environment, DAL request = Request() response = Response() session = Session() # fake request values request.folder = "" request.application = "welcome" request.controller = "default" request.function = "index" ns = build_environment( request, response, session, ) # fake common model objects db = ns['db'] = DAL("sqlite:memory") from gluon.tools import Auth, Crud, Service ns['auth'] = Auth(db) ns['crud'] = Crud(db) ns['service'] = Service() except Exception, e: print e ns = {}
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 try: cache.memcache.flush_all() #memcache client except: cache.memcache.clear() #web2py ram client redirect(URL(c='plot', f='index', vars={'id':form.vars.station_id})) return response.render('default/index.html', dict(form=form))
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', 'winner_id', 'rules']) #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: joinGame(form.vars.id, auth.user) resizeImage(db.game, form.vars.id) redirect(URL('default', 'game', args=form.vars.id)) return dict(form=form)
def crud(): from gluon.tools import Crud crud = Crud(db) table = request.args(0) operation = request.args(1) record_id = request.args(2) request.vars._formname = table request.vars.id = record_id request.post_vars = request.vars """ For update/delete calls, validate user ownership of the records """ if operation == 'read': if table == 'candidate_rating': #TODO: dont use request vars directly data = db((db.candidate_rating.candidateId == request.vars.candidateId) & ( db.candidate_rating.ratingTagId == request.vars.ratingTagId)).select().first().as_dict() else: data = dict(**crud.read(table, record_id)) return data if operation == 'create': #temporary for testing form = SQLFORM(db[table], fields=form_fields(table, request)) if form.process(session=None, formname=table).accepted: result = {'errors': {}} else: result = {'errors': form.errors} if operation == 'update': if table == 'candidate_rating': #TODO: fix later record = db[table]((db.candidate_rating.candidateId == request.vars.candidateId) & ( db.candidate_rating.ratingTagId == request.vars.ratingTagId)) else: record = db[table](record_id) form = SQLFORM(db[table], record=record, fields=form_fields(table, request)) if form.process(session=None, formname=table).accepted: result = {'errors': {}} else: result = {'errors': form.errors} if operation == 'delete': record = db[table](record_id) deletable = table not in ("candidate", "candidate_rating") # candidate_rating is never deleted, only set to 0 if deletable and record: db(db[table].id == record.id).delete() result = {'errors': {}} else: result = {'errors': {'record': "Can't delete this record."}} return dict(**result)
def comments(): """ Function accessed by AJAX to handle Comments - for discuss(() & page() """ try: post_id = request.args[0] except: raise HTTP(400) table = s3db.cms_comment # Form to add a new Comment from gluon.tools import Crud crud = Crud() table.post_id.default = post_id table.post_id.writable = table.post_id.readable = False form = crud.create(table) # List of existing Comments comments = db(table.post_id == post_id).select(table.id, table.parent, table.body, table.created_by, table.created_on) output = UL(_id="comments") for comment in comments: if not comment.parent: # Show top-level threads at top-level thread = comment_parse(comment, comments, post_id=post_id) output.append(thread) # Also see the outer discuss() script = \ '''$('#comments').collapsible({xoffset:'-5',yoffset:'50',imagehide:img_path+'arrow-down.png',imageshow:img_path+'arrow-right.png',defaulthide:false}) $('#cms_comment_parent__row1').hide() $('#cms_comment_parent__row').hide() $('#cms_comment_body').ckeditor(ck_config) $('#submit_record__row input').click(function(){ $('#comment-form').hide() $('#cms_comment_body').ckeditorGet().destroy() return true })''' # No layout in this output! #s3.jquery_ready.append(script) output = DIV(output, DIV(H4(T("New Post"), _id = "comment-title"), form, _id = "comment-form", _class = "clear", ), SCRIPT(script)) return XML(output)
def _crud(self): """Create a Crud instance """ # for CRUD helpers using auth crud = Crud(self.environment, self.db) return crud
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))
def messages(): db = current.db auth = current.auth request = current.request crud = Crud(db) crud.settings.formstyle = 'table3cols' crud.settings.keepvalues = True crud.messages.submit_button = '送信' crud.messages.delete_label = '削除する' crud.messages.record_created = 'メッセージを作成しました' crud.messages.record_updated = 'メッセージを更新しました' crud.messages.record_deleted = '削除しました' crud.messages.create_log = 'Message Record %(id)s created' crud.messages.update_log = 'Message Record %(id)s updated' crud.settings.create_next = URL('messages') crud.settings.download_url = URL('download') crud.settings.create_onaccept = give_create_message_permission crud.settings.update_ondelete = remove_message_permission button = A(BUTTON('リストへ戻る'), _href=URL('messages')) db.messages.to_group.represent = show_to_group db.messages.to_group.requires = IS_IN_SET(get_to_group_list(), zero=None) db.messages.created_by.label = '作成者' db.messages.created_by.readable = True if (request.args(0) == 'read'): crud.settings.auth = auth if auth.has_permission('update', db.messages, request.args(1)): button += A(BUTTON('編集する'), _href=URL('messages/update', request.args(1))) return dict(form=crud.read(db.messages, request.args(1)), button=button) if (request.args(0) == 'new'): return dict(form=crud.create(db.messages), button=button) if (request.args(0) == 'update'): crud.settings.auth = auth db.messages.to_group.writable = False return dict(form=crud.update(db.messages, request.args(1), deletable=True), button=button) query = auth.accessible_query('read', db.messages, auth.user.id) db.messages.title.represent = lambda title, row: A( title, _href=URL(args=('read', row.id))) db.messages.id.represent = lambda id, row: '' form = crud.select(db.messages, query=query, fields=['title', 'created_by', 'modified_on', 'id'], orderby=~db.messages.modified_on, headers={ 'messages.title': '件名', 'messages.created_by': db.messages.created_by.label, 'messages.modified_on': '更新時刻', 'messages.id': '' }) return dict(form=form, button=A(BUTTON('新規作成'), _href=URL('messages/new')))
def init_crud(self): """ Init Crud """ db = self.db crud = Crud(db) crud.settings.auth = None # =auth to enforce authorization on crud self.crud = crud return crud
def list_users(): db = current.db tracks = db.auth_user crud = Crud(db) grid = webgrid.WebGrid(crud) grid.datasource = db.auth_user grid.pagesize = 10 grid.filter_query = lambda f, v: f == v return grid()
def edit_cong_ty(): id_folder = request.args(1) name = request.args(0) from plugin_ckeditor import CKEditor div = DIV(_class='col-md-12') div.append( H2(SPAN('Khởi tạo gian hàng', _class='title_name'), _class='title_page')) cong_ty = cms.define_table('cong_ty') cong_ty_id = db(cong_ty.folder == folder_id_gian_hang).select().first() from gluon.tools import Crud crud = Crud(cms.db) cong_ty.folder.default = id_folder cong_ty.folder.writable = False cong_ty.folder.readable = False cong_ty.start_time.writable = False cong_ty.start_time.readable = False cong_ty.danh_gia.writable = False cong_ty.danh_gia.readable = False cong_ty.is_maps.writable = False cong_ty.is_maps.readable = False form = crud.update(cong_ty, cong_ty_id) if form.process().accepted: from plugin_process import ProcessModel objects = ProcessModel().define_objects() objects_id = objects.insert(folder=id_folder, foldername=name, tablename='cong_ty', table_id=form.vars.id, auth_group=8, process=3) link = name.replace('đ', 'd') link = '%s.html' % IS_SLUG.urlify(link) dcontent = cms.define_dcontent() dcontent.insert(folder=id_folder, dtable='cong_ty', table_id=form.vars.id, link=link, name=form.vars.name, avatar=form.vars.avatar, description=form.vars.description, publish_on=request.now, expired_on=None) cms.db(cong_ty.id == form.vars.id).update(link=link) redirect(URL(c='portal', f='folder', args=[name])) pass div.append(form)
def hoi_dap(): forlder_id = cms.get_folder(request.args(0)) hoi_dap = cms.define_table(tablename ='hoi_dap',migrate=True) hoi_dap.folder.writable=False hoi_dap.folder.readable=False hoi_dap.folder.default=forlder_id hoi_dap.avatar.writable=False hoi_dap.avatar.readable=False hoi_dap.avatar.default=' ' hoi_dap.htmlcontent.writable=False hoi_dap.htmlcontent.readable=False from gluon.tools import Recaptcha public_key='6LdtT_YSAAAAALCH4vbHKl1yjqvhB80JZh1J21Lv' private_key='6LdtT_YSAAAAAI6XnBMNNWwSkJeSYtbP_-kW5HUH' ### provided by recaptcha.net from gluon.tools import Crud crud = Crud(cms.db) crud.settings.captcha = Recaptcha(request,public_key,private_key,options = "lang:'en', theme:'clean'") form=crud.create(hoi_dap) # form[0].insert(-1, TR('', Recaptcha(request,public_key,private_key,options = "lang:'en', theme:'clean'"))) if form.process().accepted: from plugin_process import ProcessModel process = ProcessModel() objects = process.define_objects(True) log = process.define_process_log(True) objects_id =objects.insert(folder=forlder_id ,tablename='hoi_dap',table_id=form.vars.id ,process=2) log.insert(objects=objects_id, process=2) response.flash=T('done!') # scr ='''<script type="text/javascript"> # setInterval("location.reload();",1000); # </script>''' # form.append(XML(scr)) # if form.errors: # response.flash=T('Loi nhap du lieu!') # scr ='''<script type="text/javascript"> # setInterval("location.reload();",1000); # </script>''' # form.append(XML(scr)) div = DIV(_id='hoi_dap') div.append(DIV(H2('Nhập câu hỏi',_class="title_box"),_class="tinlienquan")) div.append(form) response.view = 'layout/hoi_dap_13.html' return dict(content=div)
def naoFinalizadas(): from gluon.tools import Crud crud = Crud(db) avaliacaoes = crud.select(db.AVAL_ANEXO_1, db.AVAL_ANEXO_1.CIENTE_SERVIDOR == 'F', fields=[ db.AVAL_ANEXO_1.id, db.AVAL_ANEXO_1.ANO_EXERCICIO, db.AVAL_ANEXO_1.SIAPE_SERVIDOR, db.AVAL_ANEXO_1.SIAPE_CHEFIA ]) return dict(avaliacoes=avaliacaoes)
def create_dropdown(): table, field = request.args(0).split('.') refereed = db[table][field].type[10:] if db[table][ field].type[:9] == 'reference' else db[table][field].type[15:] db[table][field].requires = IS_IN_DB(db, refereed + '.id', '%(name)s') from gluon.tools import Crud crud = Crud(db) form = crud.create(db[refereed]) if form.vars.id: session['_plugin_dropbox:%s' % request.args(0)] = form.vars.id options = UL(*[ LI(v) for k, v in db[table][field].requires.options() if k == str(form.vars.id) ]) return dict(form=form, options=options)
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)
def form_y_kien_du_thao(): vb_du_thao=request.vars.vbdt div = DIV(_id='hoi_dap') div.append(DIV(H2('Gửi ý kiến đóng góp',_class="title_box"),_class="tinlienquan")) from gluon.tools import Recaptcha public_key='6LdtT_YSAAAAALCH4vbHKl1yjqvhB80JZh1J21Lv' private_key='6LdtT_YSAAAAAI6XnBMNNWwSkJeSYtbP_-kW5HUH' ### provided by recaptcha.net gop_y_du_thao = cms.define_table(tablename ='gop_y_du_thao',migrate=True) gop_y_du_thao.r_gop_y_du_thao.writable=False gop_y_du_thao.r_gop_y_du_thao.readable=False gop_y_du_thao.r_gop_y_du_thao.default=vb_du_thao from gluon.tools import Crud crud = Crud(cms.db) form=crud.create(gop_y_du_thao) form[0].insert(-1, TR('', Recaptcha(request,public_key,private_key,options = "lang:'en', theme:'clean'"))) div.append(form) return div
def lianxi(): zuozhe=auth.user_id keshi_id=request.args[0] crud=Crud(db) lianxi=db(db.lianxi.keshi==keshi_id).select(orderby=db.lianxi.bianhao) values=None form=FORM('练习:', keepvalues=True) form.append(BR()) for l in lianxi: form.append(XML(db.timu(l.timu).wenti)) form.append(INPUT(_name=l.id)) form.append(BR()) form.append(INPUT(_type='submit',_value='提交')) if form.process().accepted: for (lx,zd) in form.vars.items(): db.zuoti.update_or_insert((db.zuoti.lianxi==lx)&(db.zuoti.zuozhe==zuozhe), lianxi=lx,zuozhe=zuozhe,zuoda=zd) redirect(URL('study',args=keshi_id)) return dict(form=form)
def user_list(): crud = Crud(db) crud.settings.controller = 'ebiadmin' crud.settings.detect_record_change = True crud.settings.label_separator = ':' db.gameTable.convention_id.readable = False db.gameTable.created_by.readable = True db.gameTable.created_on.readable = True db.gameTable.modified_on.readable = True db.participant.convention.readable = False db.participant.created_by.readable = True db.participant.created_on.readable = True db.participant.modified_on.readable = True db.auth_user.last_name.readable = False count = None args = request.args if len(args) > 1: count = db(db[args[1]]).count() return dict(form=crud(), count=count)
# response.optimize_css = 'concat,minify,inline' # response.optimize_js = 'concat,minify,inline' ######################################################################### ## Here is sample code if you need for ## - email capabilities ## - authentication (registration, login, logout, ... ) ## - authorization (role based authorization) ## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss) ## - old style crud actions ## (more options discussed in gluon/tools.py) ######################################################################### from gluon.tools import Auth, Crud, Service, PluginManager, prettydate auth = Auth(db, hmac_key=Auth.get_or_create_key()) crud, service, plugins = Crud(db), Service(), PluginManager() ## create all tables needed by auth if not custom tables auth.define_tables() ## configure email mail=auth.settings.mailer mail.settings.server = 'logging' or 'smtp.gmail.com:587' mail.settings.sender = '*****@*****.**' mail.settings.login = '******' ## configure auth policy auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = False auth.settings.reset_password_requires_verification = True
# response.optimize_js = 'concat,minify,inline' ######################################################################### ## Here is sample code if you need for ## - email capabilities ## - authentication (registration, login, logout, ... ) ## - authorization (role based authorization) ## - services (xml, csv, json, xmlrpc, jsonrpc, amf, rss) ## - old style crud actions ## (more options discussed in gluon/tools.py) ######################################################################### from gluon.tools import Auth, Crud, Service, PluginManager, prettydate auth = Auth(db) crud, service, plugins = Crud(db), Service(), PluginManager() ## create all tables needed by auth if not custom tables auth.define_tables(username=True, signature=False) response.generic_patterns = ['*'] if request.is_local else [] response.generic_patterns = ['load'] #response.delimiters = ['<%','%>'] ## configure email mail = auth.settings.mailer mail.settings.server = 'logging' or 'mail.darwish-group.com:143' mail.settings.sender = '*****@*****.**' mail.settings.login = '******' ## configure auth policy auth.settings.registration_requires_verification = False
# -*- coding: utf-8 -*- # try something like import string import math from gluon.tools import Crud crud = Crud(db) POSTS_PER_PAGE = 10 """ def isEmpty(form): if form.vars.body is None: form.errors.body = 'cannot be empty' """ @auth.requires_login() def showProfile(): page = request.args(1,cast=int,default=0) start = page*POSTS_PER_PAGE stop = start+POSTS_PER_PAGE user = db.auth_user(request.args(0,cast=int)) or redirect(URL(request.vars['controller'], request.vars['function'], args=request.vars['args'])) if request.vars['fromMenu']=='True': fromMenu=True else: fromMenu=False if request.vars['edit']!='True' and request.vars['pageButton']!='True': session.controller=request.vars['controller'] session.function=request.vars['function'] session.args=request.vars['args'] numOfPage=int(math.ceil(db(db.profReview.user_id==user.id).count()/10.0)) reviews =db(db.profReview.user_id==user.id).select(db.profReview.ALL, orderby=~db.profReview.datetime, limitby=(start, stop))
def comments(): """ Function accessed by AJAX from discuss() to handle Comments """ try: resourcename = request.args[0] except: raise HTTP(400) try: id = request.args[1] except: raise HTTP(400) if resourcename == "problem": problem_id = id solution_id = None elif resourcename == "solution": stable = s3db.delphi_solution query = (stable.id == id) solution = db(query).select(stable.problem_id, limitby=(0, 1)).first() if solution: problem_id = solution.problem_id solution_id = id else: raise HTTP(400) else: raise HTTP(400) table = s3db.delphi_comment field = table.problem_id field.default = problem_id field.writable = field.readable = False sfield = table.solution_id if solution_id: sfield.default = solution_id sfield.writable = sfield.readable = False else: sfield.label = T("Related to Solution (optional)") sfield.requires = IS_EMPTY_OR( IS_ONE_OF(db, "delphi_solution.id", s3.delphi_solution_represent, filterby="problem_id", filter_opts=(problem_id, ))) # Form to add a new Comment from gluon.tools import Crud form = Crud(db).create(table, formname="delphi_%s/%s" % (resourcename, id)) # List of existing Comments if solution_id: comments = db(sfield == solution_id).select(table.id, table.parent, table.body, table.created_by, table.created_on) else: comments = db(field == problem_id).select(table.id, table.parent, table.solution_id, table.body, table.created_by, table.created_on) output = UL(_id="comments") for comment in comments: if not comment.parent: # Show top-level threads at top-level thread = comment_parse(comment, comments, solution_id=solution_id) output.append(thread) # Also see the outer discuss() script = \ '''$('#comments').collapsible({xoffset:'-5',yoffset:'50',imagehide:img_path+'arrow-down.png',imageshow:img_path+'arrow-right.png',defaulthide:false}) $('#delphi_comment_parent__row1').hide() $('#delphi_comment_parent__row').hide() $('#delphi_comment_body').ckeditor(ck_config) $('#submit_record__row input').click(function(){$('#comment-form').hide();$('#delphi_comment_body').ckeditorGet().destroy();return true;})''' # No layout in this output! #s3.jquery_ready.append(script) output = DIV( output, DIV(H4(T("New Post"), _id="comment-title"), form, _id="comment-form", _class="clear"), SCRIPT(script)) return XML(output)
try: db = DAL('sqlite://pesquisa.db') except: db=DAL('gae') session.connect(request,response,db=db) response.generic_patterns = ['*'] if request.is_local else [] from gluon.tools import Mail, Auth, Crud, Service, PluginManager, prettydate mail = Mail() # mailer auth = Auth(globals(), db) auth.define_tables(username=True) # authentication/authorization crud = Crud(globals(),db) # for CRUD helpers using auth service = Service() # for json, xml, jsonrpc, xmlrpc, amfrpc plugins = PluginManager() # for configuring plugins mail.settings.server = 'logging' or 'smtp.gmail.com:587' # your SMTP server mail.settings.sender = '*****@*****.**' # your email mail.settings.login = '******' # your credentials or None auth.settings.hmac_key = 'sha512:4b841008-250d-45e3-82ca-e2edf506c2ab' # before define_tables() auth.define_tables() # creates all needed tables auth.settings.mailer = mail # for user email verification auth.settings.registration_requires_verification = False auth.settings.registration_requires_approval = True auth.messages.verify_email = 'Click on the link http://'+request.env.http_host+URL('default','user',args=['verify_email'])+'/%(key)s to verify your email' auth.settings.reset_password_requires_verification = True auth.messages.reset_password = '******'+request.env.http_host+URL('default','user',args=['reset_password'])+'/%(key)s to reset your password' auth.define_tables(username=True)
######################################################################### import sys sys.path.append("/usr/share/SMDS") from gluon.tools import Mail, Auth, Crud, Service, PluginManager, prettydate import SMDS import SMDS.web2py import SMDS.web2py.extras from SMDS.web2py.extras.SMDS_auth import * from SMDS.mdapi import MDAPI mail = Mail() # mailer auth = SMDS_Auth(MDAPI()) auth.define_tables() crud = Crud(db) # for CRUD helpers using auth service = Service() # for json, xml, jsonrpc, xmlrpc, amfrpc plugins = PluginManager() # for configuring plugins mail.settings.server = 'logging' #or 'smtp.gmail.com:587' # your SMTP server mail.settings.sender = '*****@*****.**' # your email mail.settings.login = '******' # your credentials or None auth.settings.hmac_key = 'sha512:96b4dcd8-c27d-4b0e-8fbf-8a2ccc0e4db4' # before define_tables() auth.settings.mailer = mail # for user email verification ######################################################################### ## If you need to use OpenID, Facebook, MySpace, Twitter, Linkedin, etc. ## register with janrain.com, uncomment and customize following # from gluon.contrib.login_methods.rpx_account import RPXAccount # auth.settings.actions_disabled = \
用例管理 ''' casedb=DAL('sqlite://storage.sqlite') casedb.define_table('testCase',Field('id'),Field('caseName'),Field('elecementId')) ''' 图片管理 ''' from gluon.tools import Crud from gluon.tools import Auth bugdb=DAL('sqlite://storage.sqlite') auth=Auth(bugdb) auth.define_tables() curd=Crud(bugdb) bugdb.define_table('image',Field('title',unique=True),Field('file','upload'),format='%(title)s') bugdb.define_table('bugdetail',Field('image_id',bugdb.image),Field('author'),Field('email'),Field('body','text')) bugdb.image.title.requires=IS_NOT_IN_DB(bugdb,bugdb.image.title) bugdb.bugdetail.image_id.requires=IS_IN_DB(bugdb,bugdb.image.id,'%(title)s') bugdb.bugdetail.author.requires=IS_NOT_EMPTY() bugdb.bugdetail.body.requires=IS_NOT_EMPTY() bugdb.bugdetail.image_id.writable = bugdb.bugdetail.image_id.readable = False ''' 我的图片 '''
@cache.action() def download(): """ allows downloading of uploaded files http://..../[app]/default/download/[filename] """ return response.download(request, db) def call(): """ exposes services. for example: http://..../[app]/default/call/jsonrpc decorate with @services.jsonrpc the functions to expose supports xml, json, xmlrpc, jsonrpc, amfrpc, rss, csv """ return service() from gluon.tools import Crud crud = Crud(globals(), db) @auth.requires_login() def entry_post(): """returns a form where the can entry a post""" form = crud.create(db.post) return dict(form=form)
# (more options discussed in gluon/tools.py) # ------------------------------------------------------------------------- # host names must be a list of allowed host names (glob syntax allowed) AUTH = Auth(DB, host_names=MYCONF.get('host.names')) SERVICE = Service() PLUGINS = PluginManager() # ------------------------------------------------------------------------- # create all tables needed by AUTH if not custom tables # ------------------------------------------------------------------------- # Auth Table Creation code moved to db_wizard.py # because it contains references other tables CRUD = Crud(DB) CRUD.settings.auth = AUTH # ------------------------------------------------------------------------- # configure email # ------------------------------------------------------------------------- MAIL = AUTH.settings.mailer # if request.is_local: # MAIL.settings.server = 'logging' # else: # MAIL.settings.server = MYCONF.get('smtp.server') MAIL.settings.server = MYCONF.get('smtp.server') MAIL.settings.sender = MYCONF.get('smtp.sender')
def update_test(): from gluon.tools import Crud crud = Crud(db) return dict(form=crud.update(db.balise, request.args(0)))