From 787f6050d443ab3fd067029071da50868dbe1501 Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Sun, 8 Mar 2009 18:05:34 +0100 Subject: [PATCH] handle non-existing users correctly and don't use id for the list action addresses #21 --- pyalchemybiz/controllers/customer.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pyalchemybiz/controllers/customer.py b/pyalchemybiz/controllers/customer.py index bc6f059..5e779bf 100644 --- a/pyalchemybiz/controllers/customer.py +++ b/pyalchemybiz/controllers/customer.py @@ -24,8 +24,12 @@ class CustomerController(BaseController): """ Display a customer's details. """ + if id is None: + abort(404) cust_q = meta.Session.query(customer.Customer) c.customer = cust_q.get(int(id)) + if c.customer is None: + abort(404) return render('/derived/customer/view.mako') def new(self): @@ -52,7 +56,7 @@ class CustomerController(BaseController): meta.Session.delete(cust) meta.Session.commit() - redirect_to(action='list') + redirect_to(action='list', id=None) def create(self): """ @@ -67,7 +71,7 @@ class CustomerController(BaseController): meta.Session.add(cust.person) meta.Session.commit() - redirect_to(action='list') + redirect_to(action='list', id=None) def save(self, id): """ @@ -81,4 +85,4 @@ class CustomerController(BaseController): meta.Session.add(cust.person) meta.Session.commit() - redirect_to(action='list') + redirect_to(action='list', id=None)