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


Python sqlhtml.SQLFORM类代码示例

本文整理汇总了Python中gluon.sqlhtml.SQLFORM的典型用法代码示例。如果您正苦于以下问题:Python SQLFORM类的具体用法?Python SQLFORM怎么用?Python SQLFORM使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: update

def update():
    (db, table) = get_table(request)
    keyed = hasattr(db[table],'_primarykey')
    record = None
    if keyed:
        key = [f for f in request.vars if f in db[table]._primarykey]
        if key:
            record = db(db[table][key[0]] == request.vars[key[0]]).select().first()
    else:
        record = db(db[table].id == request.args(2)).select().first()

    if not record:
        qry = query_by_table_type(table, db)
        session.flash = T('record does not exist')
        redirect(URL('select', args=request.args[:1],
                     vars=dict(query=qry)))

    if keyed:
        for k in db[table]._primarykey:
            db[table][k].writable=False

    form = SQLFORM(db[table], record, deletable=True, delete_label=T('Check to delete'),
                   ignore_rw=ignore_rw and not keyed,
                   linkto=URL('select',
                   args=request.args[:1]), upload=URL(r=request,
                   f='download', args=request.args[:1]))

    if form.accepts(request.vars, session):
        session.flash = T('done!')
        qry = query_by_table_type(table, db)
        redirect(URL('select', args=request.args[:1],
                 vars=dict(query=qry)))
    return dict(form=form,table=db[table])
开发者ID:nervatura,项目名称:nerva2py,代码行数:33,代码来源:appadmin.py

示例2: edit

def edit():
    
    table, row = validate(request.args(0), request.args(1))
    
    #row = db.patient(request.args(0)) or redirect(URL('index'))
        # specify custom labels
    labels ={'lname':'Last Name', 'mrn': 'MRN'}
    
    form = SQLFORM(db.patient,
                   record = row,
                   fields=['mrn','lname', 'ethnicity', 'date_of_birth'],
                   labels = labels,
                   #formstyle="divs",
                   showid=False,    
                   submit_button='Save')
    

    if form.accepts(request.vars, session):
        session.flash = '%s %s successfully updated.' % (singular(table), row['id'])
        redirect(URL('list_patient', args=table))
    elif form.errors:
        response.flash = 'Error. Please correct the issues marked in red below.'

    return dict(table=table,
                row=row,
                form=form)
开发者ID:BrenCam,项目名称:uodb,代码行数:26,代码来源:default.py

示例3: add_qc

def add_qc():
    if 'flash' in request.vars:
        response.flash= request.vars['flash']
    form = SQLFORM(db.episode, fields=['name', 'file', 'video_link', 'is_h', 'is_public', 'allow_qcteam'])
    if form.process().accepted:
       try:
           subs = ssa_parser.importSubsFromSSA(request.vars.file.value)
       except Exception, e:
           response.flash = "Errors importing the subs (%s)" % e.message
           db(db.episode.id == form.vars.id).delete()
       else:
           try:
               subsNb=0
               for s in subs:
                   if 'Text' in s and len(s['Text'])>0:
                       actor= None
                       if 'Actor' in s:
                           actor= s['Actor']
                       db.sub.insert(episode=form.vars.id
                           ,start_time= s['Start']
                           ,end_time= s['End']
                           ,style= s['Style']
                           ,text= s['Text']
                           ,actor= actor)
                       subsNb+=1
                   db(db.episode.id == form.vars.id).update(subs_nb=subsNb)
           except Exception, e:
               response.flash= "Errors inserting the subs in the database (%s)" % e.message
           else:
开发者ID:ThomasDalla,项目名称:FansubCheck_web2py,代码行数:29,代码来源:default.py

示例4: zznew

def zznew():
    '''
    patient registration form creation - ??use custom sql form??
    '''
    print '>>> process ptreg form <<<'
    #form = SQLFORM(db.patient)
    
    labels ={'lname':'Last Name', 'mrn': 'MRN'}
    
    form = SQLFORM(db.patient,
                   0,
                   fields=['mrn','lname', 'ethnicity', 'date_of_birth'],
                   labels = labels,
                   #formstyle="divs",
                   showid=False,    
                   submit_button='Add New')    
    
    #if form.process(session=None, formname='patient_reg').accepted:
    if form.process(session=None, formname=None).accepted:
        response.flash = 'form accepted'
        # redirect after entry
        redirect(URL('status'))
    elif form.errors:
        response.flash = ' form has errors'
    else:
        response.flash = 'please enter form data'
    
    return dict(form = form)
开发者ID:BrenCam,项目名称:uodb,代码行数:28,代码来源:default.py

示例5: test_represent_SQLFORM

 def test_represent_SQLFORM(self):
     self.db.t0.tt.represent = lambda value: value.capitalize()
     self.db.t0.tt.writable = False
     self.db.t0.tt.readable = True
     form = SQLFORM(self.db.t0)
     self.assertTrue(b'Web2py' in form.xml())
     self.db.t0.tt.represent = lambda value, row: value.capitalize()
     form = SQLFORM(self.db.t0)
     self.assertTrue(b'Web2py' in form.xml())
开发者ID:jastr945,项目名称:web2py_xperiment,代码行数:9,代码来源:test_sqlhtml.py

示例6: contact

def contact():
    from models.contact import Contact

    db = application.db(models=[Contact])
    form = SQLFORM(db.Contact, _action=URL('experiments', 'default', 'contact'))

    if form.process(session=application.session).accepted:
        redirect(URL())

    return {'form': form}
开发者ID:pmcilwaine,项目名称:web2py_unit_test,代码行数:10,代码来源:default.py

示例7: update_project

def update_project():
    response.view = 'company/details_project.html'
    
    projectid = request.args(1, cast = int)
    form = SQLFORM(db.co_project, projectid, showid = False)
    
    if form.process().accepted:
        response.flash = 'Project updated'
    elif form.errors:
        response.flash = 'Errors occurs!'
    
    return locals()
开发者ID:JFB1984,项目名称:Manager,代码行数:12,代码来源:company.py

示例8: create_project

def create_project():
    response.view = 'company/details_project.html'
    
    form = SQLFORM(db.co_project)
    
    if form.process().accepted:
        session.flash = 'Project created'
        redirect(URL('list_project'))
    elif form.errors:
        response.flash = 'Errors occurs!'
    
    return locals()
开发者ID:JFB1984,项目名称:Manager,代码行数:12,代码来源:company.py

示例9: view_task

def view_task():
    taskid = request.args(1, cast = int)
    projectid = db(db.co_task.id == taskid).select(db.co_task.project).first().project
    task = SQLFORM(db.co_task, taskid, showid = False, readonly = True)
    posts = db(db.co_taskpost.task == taskid).select(orderby = db.co_taskpost.created_on)
    db.co_taskpost.task.default = taskid
    post = SQLFORM(db.co_taskpost)
    if post.process().accepted:
        session.flash = 'Post added'
        redirect(URL('view_task', args = ('view', taskid)))
    elif post.errors:
        response.flash = 'Errors occurs!'
    
    return locals()
开发者ID:JFB1984,项目名称:Manager,代码行数:14,代码来源:company.py

示例10: update_task

def update_task():
    response.view = 'company/details_task.html'
    
    taskid = request.args(1, cast = int)
    projectid = db(db.co_task.id == taskid).select(db.co_task.project).first().project
    projectname = db.co_project(projectid).name
    form = SQLFORM(db.co_task, taskid, showid = False)
    
    if form.process().accepted:
        response.flash = 'Task updated'
    elif form.errors:
        response.flash = 'Errors occurs!'
    
    return locals()
开发者ID:JFB1984,项目名称:Manager,代码行数:14,代码来源:company.py

示例11: create_task

def create_task():
    response.view = 'company/details_task.html'
    
    projectid = request.args(1, cast = int)
    projectname = db.co_project(projectid).name
    db.co_task.project.default = projectid
    form = SQLFORM(db.co_task)
    
    if form.process().accepted:
        session.flash = 'Task created'
        redirect(URL('list_task', args = (projectid)))
    elif form.errors:
        response.flash = 'Errors occurs!'
    return locals()
开发者ID:JFB1984,项目名称:Manager,代码行数:14,代码来源:company.py

示例12: do_form_update

    def do_form_update(self, record_id):
        response = current.response
        T = current.T
        table = self.table
        action = 'update'
        self.nav = self.navegate(action)

        record = None
        if isinstance(record_id, str):
            record_id = int(record_id)

        record = table[ record_id ]
        if not record: raise HTTP(404, 'Record ID invalid!')

        if isinstance(table._format,str):
            record_label = table._format % record
        else:
            record_label = table._format(record)

        response.title = T(table._plural)
        response.subtitle = T('Editing')+': '+record_label
        response.breadcrumbs = record_label

        buttons = self.get_form_buttons(action, record_id)

        attr = dict(
            onsuccess=self.customize.on_form_success)
        hidden = self.get_hidden_fields(action, record.id)
        if hidden.get('_next'):
            attr['next'] = hidden['_next']

        self.customize.on_before_init(self, action)
        form = SQLFORM(
            table,
            record=record,
            buttons=buttons,
            deletable=False,
            formstyle=formstyle_onx,
            fields=self.customize.on_fields_list(self, action),
            hidden=hidden
            )
        if self.save_and_add_enabled:
            form[0].append(self.js_submit_and_add())
        self.customize.on_after_init(self, form, action)

        if form.process(**attr).accepted:
            response.flash = T('Record Updated')
        elif form.errors:
            response.flash = form.errors
        return dict(content=form)
开发者ID:francielsilvestrini,项目名称:soupport,代码行数:50,代码来源:_2_views.py

示例13: checkForm

    def checkForm(self, table):
        formnamemodal = "formmodal_%s" % self.key
        form = SQLFORM(table, formname=formnamemodal, _class="form-horizontal", formstyle='bootstrap-modal', fields=self.fields, kwargs=self.kwargs)
        if self.script:
            form.append(SCRIPT(self.script))
        if form.process().accepted:
            command = "jQuery('#%s').modal('hide');" % (self.modal_id)
            command += self.cmd
            self.response.flash = self.flash
            self.response.js = command
        elif form.errors:
            self.response.flash = self.errormsg

        return form
开发者ID:shpedoikal,项目名称:Kvasir,代码行数:14,代码来源:01_form_modal.py

示例14: create_employee

def create_employee():
    response.view = 'company/details_employee.html'
    
    form = SQLFORM(db.co_employee)
    
    if form.process().accepted:
        newuserid = db.auth_user.insert(first_name = form.vars.firstname, last_name = form.vars.lastname, email = form.vars.email, password = db.auth_user.password.validate('Pa$$w0rd')[0])
        employee = db(db.co_employee.id == form.vars.id).select().first()
        employee.update_record(authuser = newuserid)
        session.flash = 'Employee created'
        redirect(URL('list_employee'))
    elif form.errors:
        response.flash = 'Errors occurs!'
    
    return locals()
开发者ID:JFB1984,项目名称:Manager,代码行数:15,代码来源:company.py

示例15: update_vacation

def update_vacation():
    response.view = 'company/details_vacation.html'
    
    vacationid = request.args(1, cast = int)
    db.co_vacation.status.writable = False
    db.co_vacation.employee.readable = False
    db.co_vacation.employee.writable = False
    form = SQLFORM(db.co_vacation, vacationid, showid = False)
    
    if form.process().accepted:
        response.flash = 'Employee updated'
    elif form.errors:
        response.flash = 'Errors occurs!'
    
    return locals()
开发者ID:JFB1984,项目名称:Manager,代码行数:15,代码来源:company.py


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