Raymond Wan <r...@kuicr.kyoto-u.ac.jp> writes: >> if (not $success) { >> return $m->comp('/BAR', %ARGS); >> } > > I didn't ask the original question, but your answer intrigued me. How > does "return" differ from a "redirect" and which is preferred between the > two and why?
"return" as shown here does nothing to the output that was already sent by the components called before this one (for example your preamble/headings), and does nothing to prevent the component who called this one from sending more output (for example your template's postamble/footings). in fact if the component from within which you call "return" as shown above has sent output before this return, that output will be part of the resulting page. http://www.masonhq.com/docs/manual/Request.html#apache_or_cgionly_methods on the other hand describes $m->redirect() as: redirect ($url, [$status]) Given a url, this generates a proper HTTP redirect for that URL. It uses $m->clear_and_abort to clear out any previous output, and abort the request. By default, the status code used is 302, but this can be overridden by the user. therefore no output sent by any component in the current call chain will be part of the web page unless you've called $m->flush_buffer() for some reason. -- Paul Vixie ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ Mason-users mailing list Mason-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mason-users