Looks like a bug with SQLFORM, investigating...
On Aug 8, 4:58 pm, Andrew <awillima...@gmail.com> wrote: > thanks again Denes, > I'm running MS SQL 2005 and Web2py 1.98.2. > Note that from the shell interface, the following works: > db.web2pytest_leg.insert(LoadID=2, LoadName='DirectInsert') > db.commit() > > Here's my table (Note: the original table did not have a LoadID, I > added it to test an int PK): > CREATE TABLE [dbo].[web2pytest_leg]( > [LoadID] [int] NOT NULL, > [LoadName] [varchar](50) COLLATE Latin1_General_CI_AS NOT NULL, > [DestinationName] [varchar](50) COLLATE Latin1_General_CI_AS NULL, > [Description] [varchar](50) COLLATE Latin1_General_CI_AS NULL, > CONSTRAINT [PK_web2pytest_leg] PRIMARY KEY CLUSTERED > ( > [LoadID] ASC > )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] > ) ON [PRIMARY] > > db.py (connect details have been changed): > db = DAL('mssql://username:password@server/database') > > db.define_table('web2pytest_leg', > Field('LoadID', 'integer'), > Field('LoadName', 'string'), > Field('DestinationName', 'string'), > Field('Description', 'string'), > primarykey=['LoadID'], > migrate=False > ) > > Controller: > Controller: > # coding: utf8 > # try something like > > response.menu = [['Register Legacy Item', False, URL(r=request, > f='web2pytest_leg')]] > > def web2pytest_leg(): > ''' > This is a test of a Legacy Table in SQL Server > > simple data entry form with validation and database.insert() > also lists all records currently in the table > ''' > > # ## create an insert form from the table > form = SQLFORM(db.web2pytest_leg) > > # ## if form correct perform the insert > > if form.accepts(request.vars, session): > response.flash = 'new record inserted' > elif form.errors: > response.flash= 'form is invalid' > else: > response.flash = 'please fill in the form' + > str(request.vars) > > # ## and get a list of all users > > records = > SQLTABLE(db().select(db.web2pytest_leg.ALL),headers='fieldname:capitalize') > return dict(form=form, records=records) > > View: > > {{extend 'layout.html'}} > <h1>This is the MaxLoad Web2PyTest_leg.html template</h1> > > {{=form}} > > <h2>Submitted variables</h2> > {{=BEAUTIFY(request.vars)}} > <h2>Accepted variables</h2> > {{=BEAUTIFY(form.vars)}} > <h2>Errors in form</h2> > {{=BEAUTIFY(form.errors)}} > > <h2>Current Rows</h2> > <p> List of rows in web2pytest </p> > > {{=records}} > > Many Thanks > Andrew > > On Aug 9, 1:20 am, DenesL <denes1...@yahoo.ca> wrote: > > > > > > > > > Hi Andrew, > > > could you post your model and controller?. > > MSSQL is indeed supported (I use it every day) and from your > > description it sounds like it should work but without the code it is > > impossible to say where the problem might be. > > Also, which version of web2py are you using?. > > > Denes. > > > On Aug 8, 12:33 am, Andrew <awillima...@gmail.com> wrote: > > > > Hello, I'm doing the most simple form to test out Keyed Table > > > Functionality. I've followed some examples from the examples app and > > > some code from the web2py book. My DBMS is MS SQL. > > > > When I enter some data on my basic entry form and press submit, > > > nothing happens. In order to debug I added the following from the > > > book to my view: > > > > <h2>Submitted variables</h2> > > > {{=BEAUTIFY(request.vars)}} > > > <h2>Accepted variables</h2> > > > {{=BEAUTIFY(form.vars)}} > > > <h2>Errors in form</h2> > > > {{=BEAUTIFY(form.errors)}} > > > > The request.vars has the values I've entered, but the keyed column in > > > form.vars is "None". Nothing in form.errors. > > > From Ch7, I understand that the form.accepts in the controller filters > > > the request.vars (by validators) and populates form.vars. So why is > > > my key columnnotvalidating ? My table definition doesn't have any > > > validators except for: > > > primarykey=['LoadID'], > > > migrate=False > > > > I've tried an integer Key, a string Key but no difference. > > > > Am I missing something ? Thanks.- Hide quoted text - > > > - Show quoted text -