Hello,
I am new to web2py. I just started a new app to become more familiar
with the technology. So far I have the following.
# controller
def index():
form, rows = crud.select(db.domains,
query=(db.domains.created_by==auth.user_id))
return dict(rows=rows)
# view
{{extend 'layout.html'}}
<h1>Manage your domain names</h1>
[ {{=A('search', _href=URL('search'))}} ]<br />
{{response.write(rows)}}
<ul>{{for name in rows:}}
{{=LI(A(name[1], _href=URL('domain_show', args=name[4])))}}
{{pass}}</ul>
[ {{=A('create domain', _href=URL('domain_add'))}} ]
The problem is that it dynamically generates the args=name[4] as <td>
name[4] </td>. in the browser.
I've been so far unable to find any tidy was so that I can only show
the domains for the particular user and pass those variables around to
show, edit, delete etc.
As an example here is what I have in my domain_show controller
@auth.requires_login()
def domain_show():
"shows a domain name"
domain_name = db.domains(request.args(0),created_by=auth.user_id)
or redirect(URL('index'))
db.domains.id.default = domain_name.id
form = crud.create(db.domains) if auth.user else None
return dict(domain_name=domain_name, form=form)
and the view
{{extend 'layout.html'}}
<h1>{{=domain_name.name}}</h1>
{{=form}}
I would love to know if there is a better way to do this stuff. Any
advice would be really appreciated.
Regards,
Jimmy.