Hello Annet!

Your example helps a lot!  I'm not yet familiar enough with web2py/
python to realize that I could just extend the empty user() controller
(and I don't think I came across an example in the web2py book or the
online examples).

Since I already had my own my_profile() controller, what I did is,

def user():
    ...
    if request.args(0)=='profile'
        my_profile_dict = my_profile()
        return my_profile_dict
    ...

I don't know if that's proper usage/style for python/web2py,  but it
works fine!!

Thanks!!!

Luis.

On May 28, 11:22 pm, annet <annet.verm...@gmail.com> wrote:
> Hi Luis,
>
> I am not sure I understand your question correctly, but as far as I
> know default/user/profile is based on the auth_user table, to which
> you can add any field you want e.g.
>
> # Custom Auth table definition
> db.define_table(auth.settings.table_user_name,
>     Field('username', length=20, unique=True),
>     Field('first_name', length=128, default='', comment='required'),
>     Field('last_name', length=128, default='', comment='required'),
>     Field('email', length=128, default='', unique=True),
>     Field('hide_email', 'boolean', default=False),
>     Field('phone', length=64, default=''),
>     Field('homepage', requires=IS_EMPTY_OR(IS_URL())),
>     Field('facebook_access_token', writable=False, readable=False),
>     Field('flickr_user', label='Flickr Screenname'),
>     Field('flickr_id', writable=False),#, readable=False), # computed,
> see below
>     Field('twitter_user'),
>     Field('bio', 'text', default=''),
>     Field('ref_friends' , 'list:reference
> '+auth.settings.table_user_name,
>         writable=False, readable=False),
>     Field('password', 'password', length=64, readable=False,
> label='Password'),
>     Field('registration_key', length=512, writable=False,
> readable=False,
>         default=''),
>     Field('reset_password_key', length=512, writable=False,
> readable=False,
>         default=''),
>     Field('registration_id', length=512, writable=False,
> readable=False,
>         default=''),
>     Field('record_created', 'datetime', default=request.now,
> writable=False,
>         readable=False),
>     Field('record_updated', 'datetime', default=request.now,
>         update=request.now, writable=False, readable=False)
>     )
>
> Whether a field is editable in default/user/profile depends on
> writable and readable being True or False.
>
> In one of my apps I wanted the form to display differently, I solved
> this by adding the following lines of code to the default/user
> function:
>
>     form=auth()
>     if isinstance(form,FORM):
>         form[0][-1]
> [1].append(INPUT(_type="button",_value="Cancel",_onclick="window.location=' 
> %s';"%URL(r=request,c='usercms',f='index')))
>     if request.args(0)=='login':
>         form.element(_type='submit')['_value']='Login'
>     if request.args(0)=='profile':
>         response.view='default/profile.html'
>     return dict(form=form)
>
> I hope this point you in the right direction.
>
> Kind regards,
>
> Annet.

Reply via email to