Re:The Modern Java Ecosystem (for the Sinatra or web.py lover)
by masklinn on Saturday December 03, 2011 @05:24AM
(#3307450)
An other note: the @path decorator would probably use named groups instead of some sort of DSL, so
r'(?P<uid>[0-9]+)'
(the `r` prefix is for `r`awstring, so the developer does not have to string-escape each backslash used in the regex among other things)
Although in Django you'd really use the `get_object_or_404` shortcut for ORM objects:
And you wouldn't bother with the return since a 200 result would mean the deletion was correctly executed.[0] Used Python's MutableMapping API here, it works slightly differently than Java's equivalent Map interface: `.keys()` returns a sequence of the mapping's keys and `.pop()` asks for a default value to return in case nothing was found there, otherwise it raises `KeyError` if the key was not found)