Hi Everyone,
I am brand new to web2py and I am definitely still learning. I am trying to
build a simple application that allows me store, edit, and delete projects
and users. I have made some progress but when I cannot get the method
crud.update to function as expected. I have pasted my code below when I
call the method project_edit or user_edit a page pops up displaying "None"
eventhough there are users and projects stored. Any help would be greatly
appreciated.
Code located in default.py in controllers:
def index():
"""
example action using the internationalization operator T and flash
rendered by views/default/index.html or views/generic.html
if you need a simple wiki simple replace the two lines below with:
return auth.wiki()
"""
return locals()
def projects():
projects = db(db.projects).select(orderby=db.projects.description)
return locals()
def users():
project = db.projects(request.args(0))
users = db(db.users.project).select(orderby=db.projects.description)
return locals()
def project_create():
form = crud.create(db.projects, next = 'projects')
return locals()
def project_edit():
project = db.projects.request.args(0)
form = crud.update(db.projects, project , next='projects')
def user_create():
db.users.project.default = request.args(0)
form = crud.create(db.users, next = 'users')
return locals()
def user_edit():
user = db.users(request.args(0))
form = crud.update(db.users, user, next = 'users')
def user():
"""
exposes:
http://..../[app]/default/user/login
http://..../[app]/default/user/logout
http://..../[app]/default/user/register
http://..../[app]/default/user/profile
http://..../[app]/default/user/retrieve_password
http://..../[app]/default/user/change_password
http://..../[app]/default/user/manage_users (requires membership in
use @auth.requires_login()
@auth.requires_membership('group name')
@auth.requires_permission('read','table name',record_id)
to decorate functions that need access control
"""
return dict(form=auth())
@cache.action()
def download():
"""
allows downloading of uploaded files
http://..../[app]/default/download/[filename]
"""
return response.download(request, db)
def call():
"""
exposes services. for example:
http://..../[app]/default/call/jsonrpc
decorate with @services.jsonrpc the functions to expose
supports xml, json, xmlrpc, jsonrpc, amfrpc, rss, csv
"""
return service()
@auth.requires_signature()
def data():
"""
http://..../[app]/default/data/tables
http://..../[app]/default/data/create/[table]
http://..../[app]/default/data/read/[table]/[id]
http://..../[app]/default/data/update/[table]/[id]
http://..../[app]/default/data/delete/[table]/[id]
http://..../[app]/default/data/select/[table]
http://..../[app]/default/data/search/[table]
but URLs must be signed, i.e. linked with
A('table',_href=URL('data/tables',user_signature=True))
or with the signed load operator
LOAD('default','data.load',args='tables',ajax=True,user_signature=True)
"""
return dict(form=crud())
--
---
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.