I would disagree here(I believe we have talk about this before).

return cherrypy.HTTPRedirect.

It looks like two incompatible meaning in one. Do you want to return or
redirect ? return to me means back to caller and in this case, it could
very well be decorated. So do I know if some logic is there ? raise
exception is cleaner to me in this case.

Daniel wrote:
>
> Let's think about what the "dosomething" method is doing here--it's
> creating something to be processed, or short-circuiting to a redirect.
> IMHO that type of control flow leads to buggy apps because you're never
> quite sure what to expect when you call a method--the control flow is
> not explicit (very bad in a complex app). It would be more clear to do
> it this way:
>
> @turbogears.expose()
> def mypublicmethod(self, arg):
>     try:
>         someval = self.dosomething(arg)
>     except InconsistentStateError:
>        return cherrypy.HTTPRedirect(...)
>     return self.process(someval)
>
> def dosomething(self, arg):
>     # oops, something isn't in the right state...
>     raise InconsistentStateError()
>
> Again, I think it's important to keep application flow clear and
> explicit.

Reply via email to