Assuming you have 

auth.settings.extra_fields=[Field('age','integer'),Field('country')]
auth.define_tables(username=True)

you define

def userinfo()
     user = db.auth_user(username=request.args(0)) or redirect(URL('error'))
     return dict(user=user)

with a view

{{extend 'layout.html'}}
<html>
<body>
Some Social Website
<h1>User Name: {{=user.username}}</h1>
<h2>Age: {{=user.age}}</h2>
<h3>Country: {{=user.country}}</h3> 
</body>
</html>

Than you would have to make urls into 
http://hostname/app/default/userinfo/jsmith

Using a Twitter like syntax you can try create a web2py/routes.py file:

# begin
routes_in = [
   ('/~/$anything','/app/default/userinfo/$anything'),
]
#end
routes_out = [
   ('/app/default/userinfo/$anything','/~/$anything'),
]

and use http://hostname/~jsmith

The ~ will help you avoid confusion between a username and a web2py 
app-name.

On Tuesday, July 31, 2012 2:11:47 PM UTC-5, Rob_McC wrote:
>
> Haven't been able to find a solution to this on Groups - I'm NEW to 
> web2py, but enjoying it a great deal.
>
> Note: I learned how to make custom fields in User's table, that was easy.
>
> *Assumptions*:
> *User: jsmith
> Custom fields:  Country, Age
>    Country=Canada
>    Age=34*
>
> I want to make a few of the user's profile public - no login is required 
> to view SOME of the fields
>
> I know if jsmith is logged in,  he can access only his profile at:
> *http://somesocialwebsite/default/user/profile*
>
> *Question/problem:*
>
> *How do I make a public url like:
> **
> http://somesocialwebsite/jsmith*
>
> *return
> *
> *<html>
> <body>*
> *Some Social Website
> <h1>User Name: jsmith</h1>
> <h2>Age: 34</h2>
> <h3>Country: Canada</h3>* 
> *</body>
> </html>*
>
> Any help, or pointing me in the right direction would be appreciated, 
> thanks,
>
> Rob
>
> Reference: Adding custom fields
>
> https://groups.google.com/forum/?fromgroups#!searchin/web2py/db.auth_user$20adding$20fields/web2py/H0g7WUV7ubg/7AxpjU_tFL8J
>
>
>
>
>
>
>

-- 



Reply via email to