On 2011-6-2 19:20, Mike Orr wrote:
OK, but there's such a thing as view support methods, code that's
common to several views so it doesn't have to be repeated in all of
them. That's the only place where I'd use this.  For instance:

class MyHandler(object):
     def my_view(self):
         params = self.request.params
         self._process_id(params.get("id"))

     # Private methods
     def _process_id(self, id_str):
         if id_str is None or not id_str.isdigit():
             abort(400, "query param 'id' missing")
         id = str(id)
         self.record = model.Something.get(id)
         if self.record is None:
             abort(404, "that Something does not exist")

Personally I find that this coding style makes it hard to read code: you are basically rewriting a standard language feature (raising an exception) in a way that makes it look like a normal function call.

Wichert.

--
Wichert Akkerman <wich...@wiggy.net>   It is simple to make things.
http://www.wiggy.net/                  It is hard to make things simple.

--
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To post to this group, send email to pylons-devel@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-devel?hl=en.

Reply via email to