db.Table1.X is just a field object and doesn't refer to any record in the database. To retrieve a record, you must create a query. In most databases, you can just take the record with the largest ID:
db(db.Table1).select(orderby=~db.Table1.id, limitby=(0, 1)) That sorts in reverse order based on ID and takes the first record. Alternatively, you could include a record creation timestamp and sort based on that. Anthony On Wednesday, April 29, 2015 at 9:31:50 AM UTC-4, Aydin S wrote: > > Thank you, you are right, right now I have: > def index(): > form = SQLFORM(db.X).process() > return dict(form=form) > > and I see the database getting updated with new records. > One last question, I use db.Table1.X to refer to the last entered record. > However, this does not work. How can I make it use the last entered row? > > On Wednesday, 29 April 2015 08:27:22 UTC-4, Anthony wrote: >> >> See answer on SO: http://stackoverflow.com/a/29932995/440323 >> >> On Tuesday, April 28, 2015 at 9:35:31 PM UTC-4, Aydin S wrote: >>> >>> It looks like the scheduler which is a model file does not see variable >>> X in the database! >>> >>> On Tuesday, 28 April 2015 21:19:14 UTC-4, Aydin S wrote: >>>> >>>> No, the value of the form gets processed every time the scheduler runs. >>>> >>>> On Tuesday, 28 April 2015 21:07:42 UTC-4, Dave S wrote: >>>>> >>>>> >>>>> >>>>> On Tuesday, April 28, 2015 at 6:01:04 PM UTC-7, Aydin S wrote: >>>>>> >>>>>> This is probably very simple, sorry in advance! >>>>>> I have a form defined in a model file: >>>>>> db.define_table('table1', >>>>>> Field('X', 'integer')) >>>>>> I have a controller that is also defined as: >>>>>> def index(): >>>>>> form = SQLFORM(db.X) >>>>>> return dict(form=form) >>>>>> >>>>>> >>>>> In my index view file I have: >>>>>> >>>>>> <h2>Input form</h2> >>>>>> {{=form}} >>>>>> >>>>>> I want to use value X in a scheduler defined as a model like: >>>>>> >>>>>> A = X+2 >>>>>> >>>>>> The form shows up as expected. I enter a value in it and submit it. >>>>>> The scheduler is running as expected. However it looks like the value X >>>>>> never gets set to what I enter. >>>>>> Any idea? >>>>>> >>>>>> >>>>> Do you process the form once the user has entered the input? >>>>> >>>>> /dps >>>>> >>>>> >>>> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

