| Revision 543,
1.2 KB
checked in by jdalbey, 6 years ago
(diff) |
|
Add branch for web2py example application: Highways
|
| Line | |
|---|
| 1 | def index(): |
|---|
| 2 | return dict() |
|---|
| 3 | def list(): |
|---|
| 4 | highways = db().select(db.highways.ALL, orderby=db.highways.lognum) |
|---|
| 5 | return dict(highways = highways) |
|---|
| 6 | def show(): |
|---|
| 7 | # Retrieve the requested log entry from the database |
|---|
| 8 | #hwy = db.highways(request.args(0, cast=int)) or redirect(URL('index')) |
|---|
| 9 | hwy = db(db.highways.lognum == request.args(0)).select().first() |
|---|
| 10 | return dict(hwy=hwy) |
|---|
| 11 | def search(): |
|---|
| 12 | #if request.vars.log_number: |
|---|
| 13 | # session.log_number = request.vars.log_number |
|---|
| 14 | # redirect(URL('results')) |
|---|
| 15 | #return dict() |
|---|
| 16 | form = FORM(INPUT(_name='log_number', requires=IS_NOT_EMPTY()), |
|---|
| 17 | INPUT(_type='submit')) |
|---|
| 18 | if form.process().accepted: |
|---|
| 19 | session.log_number = form.vars.log_number |
|---|
| 20 | redirect(URL('results')) |
|---|
| 21 | return dict(form=form) |
|---|
| 22 | def results(): |
|---|
| 23 | hwy = db(db.highways.lognum == session.log_number).select().first() |
|---|
| 24 | #hwy = session.log_number |
|---|
| 25 | return dict(hwy=hwy) |
|---|
| 26 | def submit(): |
|---|
| 27 | # Don't name this function 'request' because it creates a name conflict with http.request |
|---|
| 28 | form = SQLFORM(db.highways) |
|---|
| 29 | if form.process().accepted: |
|---|
| 30 | response.flash = 'your submission is accepted' |
|---|
| 31 | redirect(URL('list')) |
|---|
| 32 | return dict(form=form) |
|---|
Note: See
TracBrowser
for help on using the repository browser.