Permalink
Browse files

Third version of Werkzeug interface, with more RESTful URLs

  • Loading branch information...
1 parent 98bf1c4 commit 9709fba9efa8e58fe9d9b793adf1f2c597873822 @jmafc committed Oct 14, 2011
Showing with 10 additions and 10 deletions.
  1. +1 −1 werkzeug/dbapp.py
  2. +6 −6 werkzeug/film.py
  3. +2 −2 werkzeug/templates/film/edit.html
  4. +1 −1 werkzeug/templates/home.html
View
@@ -21,7 +21,7 @@ def __init__(self, dbname):
self.film = FilmHandler(self.dbconn)
self.url_map = Map([
Rule('/', endpoint='index'),
- Rule('/film/', endpoint='film'),
+ Rule('/films', endpoint='film'),
Rule('/film/<path:parts>', endpoint='film')
])
View
@@ -32,12 +32,12 @@ class FilmHandler(object):
def __init__(self, dbconn):
self.db = dbconn
self.url_map = Map([
- Rule('/film/', endpoint='index'),
+ Rule('/films', endpoint='index'),
Rule('/film/new', endpoint='new'),
Rule('/film/create', endpoint='create'),
Rule('/film/<int:id>', endpoint='edit'),
- Rule('/film/save/<int:id>', endpoint='save'),
- Rule('/film/delete/<int:id>', endpoint='delete')
+ Rule('/film/<int:id>/save', endpoint='save'),
+ Rule('/film/<int:id>/delete', endpoint='delete')
])
def dispatch(self, request):
@@ -73,7 +73,7 @@ def create(self, request):
if errors:
return render('film/new.html', id=form.id, title=form.title,
release_year=form.release_year, errors=errors)
- return redirect('/film/')
+ return redirect('/films')
def index(self, request):
"Lists all films"
@@ -116,7 +116,7 @@ def save(self, request, id=None):
if errors:
return render('film/edit.html', id=film.id, title=film.title,
release_year=film.release_year, errors=errors)
- return redirect('/film/')
+ return redirect('/films')
def delete(self, request, id=None):
"Deletes an existing film by id"
@@ -139,4 +139,4 @@ def delete(self, request, id=None):
errors={None: self.db_error(exc)})
else:
self.db.commit()
- return redirect('/film/')
+ return redirect('/films')
@@ -8,12 +8,12 @@
<div class="errmsg">{{ errors[None] }}</div>
{% endif %}
{% endif %}
- <form class="mainform" name="chgfilm" action="/film/save/{{ id }}"
+ <form class="mainform" name="chgfilm" action="/film/{{ id }}/save"
method="post">
{%- set edit = true -%}
{% include "film/fields.html" %}
<div class="submit-btn">
- <p class="delbox"><a href="/film/delete/{{ id }}">Delete</a></p>
+ <p class="delbox"><a href="/film/{{ id }}/delete">Delete</a></p>
<input type="submit" name="save" value="Save" />
</div>
</form>
@@ -6,7 +6,7 @@
<caption>Movies</caption>
<tr>
<th scope="row">
- <a href="/film/">Films</a>
+ <a href="/films">Films</a>
</th>
<td><a href="/film/new" class="newlink">New</a></td>
</tr>

0 comments on commit 9709fba

Please sign in to comment.