On Thursday, June 16, 2011 2:05:34 PM UTC-4, JayShaffstall wrote: 
>
> I have a situation where I need to adjust an SQLFORM field to be
> non-editable.  I can do that with .writable = False, but that seems to
> also prevents database I/O for that field.  What I'm trying to do is
> set a default that cannot be changed.

 
How are you setting the default? If you specify the 'default' argument for 
the Field object, it should enter that default even if you set 
writable=False (at least it does for me, though I haven't tested it 
specifically on the auth_user table). Can you show some of your code?
 

> For reference, I'm doing this with a field in the form returned by
> auth.register, so I cannot insert code between the form creation and
> the accepts call.  I believe I'm restricted to working with the model
> before calling auth.register, or by using custom forms.
>
 
Depending on what you need to do, I think you should be able to alter the 
auth form before it gets passed on to the view. In your user() function, do 
something like this:
 
def user():
    form=auth()  # This creates the appropriate auth form, depending on 
request.args.
    if request.args and request.args(0)=='register':
        # code to alter the registration form
    return dict(form=form)
 
 
Note, if you want to do something after registration form validation but 
before the form is accepted, you can also specify 
auth.settings.register_onvalidation (see 
http://web2py.com/book/default/chapter/08#Settings-and-Messages).
 
Anthony

Reply via email to