Leonel,
Thanks. Will try this out. Wasn't aware of auth.settings.passfield; any documentation around this? Looked for this here: http://web2py.com/books/default/chapter/29/09/access-control#Settings-and-messages

Finally, any thoughts on "Also, factory seems to create a SQLFORM which does not work with the database(?). So, am not sure how to proceed on this one."

________________________________________
Kiran Subbaraman
http://subbaraman.wordpress.com/about/

On 11/8/2013 5:49 PM, Leonel Câmara wrote:
The models get reloaded every request so you can just set the writable and readable attributes for the fields before creating the form and it will only affect this form.

For instance you could add this before your call  to SQLFORM.factory

db.auth_user.email.writable = db.auth_user.email.readable = False
db.auth_user.username.writable = db.auth_user.username.readable = False
db.auth_user.password.writable = db.auth_user.password.readable = False

(might want to use auth.settings.passfield on the last one)

Quinta-feira, 7 de Novembro de 2013 9:46:52 UTC, [email protected] escreveu:

    Hello All,he
    I have these two tables
    db.auth_user - which is the default table created for Auth
    email, password, first name, last name

    db.b
    b0, b1, b2, b3

    db.b.b0 foreign-key linked to db.auth_user.id
    <http://db.auth_user.id>

    My requirement: Display only fields first name, last name, b2, b3.
    Updates can only happen to these fields, and no other. I do not
    want the password, or email fields to be displayed, because I want
    to use the default change password form to change passwords.

    I experimented with
    |
        form =SQLFORM.factory(db.auth_user,db.b)
    ifform.process().accepted:
            id
    =db.auth_user.insert(**db.auth_user._filter_fields(form.vars))#
    this needs to be corrected to accept only first and last names.
            form.vars.b =id
            id =db.b.insert(**db.b._filter_fields(form.vars))
    |


    Wasn't sure how to explicitly restrict writes to certain fields,
    only for this form. It is possible that these fields need to be
    updated from a different form.
    I had a look at this discussion on the forum, and it helped me
    understand this a bit better, but not sure it helps my case:
    https://groups.google.com/forum/#!topic/web2py/qd6blGfnVTA
    <https://groups.google.com/forum/#%21topic/web2py/qd6blGfnVTA>
    Also, factory seems to create a SQLFORM which does not work with
    the database(?). So, am not sure how to proceed on this one.

    ________________________________________
    Kiran Subbaraman
    http://subbaraman.wordpress.com/about/  
<http://subbaraman.wordpress.com/about/>



--
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/groups/opt_out.

--
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/groups/opt_out.

Reply via email to