Ah, so it doesn't actually effect the table definition in the database, just the rendering. This is what I was wondering, and what I wanted. Since that is the case, then I no longer have any more concerns. Thanks for feedback and explanations.
On Sep 17, 9:08 pm, Iceberg <iceb...@21cn.com> wrote: > I also had a hard time on this when I just began learning web2py. Then > I came up with some understanding. > > The bottom line is that, redefining a field's default value, (even > changing its default widget, changing its represent-ing), can be > considered as changing appearance, but NOT redefining a table. That's > kind of the "View" thing of MVC. You can do it without bad effect. > > And yes, all those definitions are recalculated in every request. This > sounds scared (I know some people criticise web2py for this). But the > overhead is not as significant as they thought. Web2py still has good > enough benchmark result. > > Hope they help you too. > > Regards, > Iceberg > > On Sep18, 1:22am, Alastair Medford <alastairmedf...@gmail.com> wrote: > > > this method still leaves a bad taste in my mouth. > > Since every request is also sending a table redifinition, this seems > > like un-needed overhead. This also has the problem of what if the > > given database does not allow the tables to be redefined, and only > > allows submissions. This is a future possibilty I want to account for. > > Am I correct that this solution would no longer work? Is there any > > other possile method to make the field of an sqlform be unchangable > > (at least visibly) and also be pre-filled? > > > On Sep 17, 1:08 am, Iceberg <iceb...@21cn.com> wrote: > > > > When talking about the redefining, yes, it is an unusual way and > > > somewhat hard to be understood at the beginning, but it is how web2py > > > does things. Just be aware that your model definition are indeed > > > recalculated in each web request (yet still fast enough). Same applies > > > to your controller, so you can even have two different functions in > > > your controller, each defines different default value, different > > > readable or writable combinations, etc. When you get used to it, you > > > find a brand new world. :-) > > > > Iceberg > > > > On Sep17, 2:18pm,AlastairMedford <alastairmedf...@gmail.com> wrote: > > > > > if I changed the default value in the model, > > > > wouldn't this be redefining the table definition every time the form > > > > is brought up? If so, this doesn't seem like a desirable approach. > > > > Would this be the case? > > > > > On Sep 16, 11:33 pm, Iceberg <iceb...@21cn.com> wrote: > > > > > > Try: > > > > > > db.table.time.default=getCurrentTime() > > > > > db.table.time.writable=False > > > > > form = SQLFORM(db.table) > > > > > if form.accepts(...) > > > > > > On Sep17, 12:33pm,AlastairMedford <alastairmedf...@gmail.com> wrote: > > > > > > > What I'm trying to do is preset the value of a non writable field > > > > > > in a > > > > > > form, such as a time field. Something to the effect of: > > > > > > > form = SQLFORM(db.table) > > > > > > form.vars.time = getCurrentTime() #this field is set to writable > > > > > > false > > > > > > if form.accepts(...): > > > > > > ... > > > > > > > The desired rendering would be that the field cannot be edited, but > > > > > > displays the current time, and will be entered into the database > > > > > > once > > > > > > the form submits. But I've noticed that web2py ignores the .vars > > > > > > setting and instead puts in the database given default value. I'm > > > > > > not > > > > > > sure if this was always the case, as I seem to remember having this > > > > > > work as expected before. Is there any way to get my desired > > > > > > rendering? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---