-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 <for Gavin> Gavin, what I'm trying to promote is better practices and constructive criticism. If you get them as "bombastic" and "trolling", you can always set an ignore filter on my name/address and don't bother. My recommendation for you is to read Merlyn's /boilerplate/ at: http://www.perlmonks.org/index.pl?node_id=205373 </for Gavin>
I agree my brevity may fail to make some us understand what I meant, mostly because of my tendency of avoiding duplication (ergo newer people on the list may have missed past discussions). Luckily, there are always good fellows around providing more helpful explanations (as Dave did with his follow-up). As Gavin missed my point completely, I suppose there could be others too in the same position, so I'll reiterate (hopefully with less brevity). Ken Woodruff wrote: > In the autohandler: > [...] <& SELF:css &> [...] > <%method css></%method> Gavin Carr wrote: > I do something similar to this but using attributes instead of methods in > the autohandler: > % if (my $css = $m->request_comp->attr_if_exists('css')) { > <link rel="stylesheet" type="text/css" href="/css/<% $css %>" /> > % } Gavin's approach is less flexible than Ken's because it doesn't allow inheritance to do its magic. The trade-off it's speed, Gavin's being (arguably _much_) faster. Both approaches are well described in TheBook (http://www.masonbook.com/). Let's take the classic "page title" example, using this hypothetic tree: /autohandler /products/autohandler /products/index.html %### /autohandler: ... <%attr> title => 'MySite' </%attr> <%method title>MySite:</%method> <title><& SELF:title &></title> <meta name="attr title" content="<% $m->request_comp->attr_if_exists('title') |h %>" /> ... %### /products/autohandler ... <%attr> title => 'Products' </%attr> <%method title><% PARENT:title %> Products:</%method> ... %### /products/index.html: ... <%attr> title => 'Index' </%attr> <%method title><% PARENT:title %> Index</%method> ... Rendering /products/index.html we'll get: ... <title>MySite: Products: Index</title> <meta name="attr title" content="Index" /> ... As we're all about Perl after all, TMTOWTDI ;-) As a third choice, there are also solutions based on $m->notes, which (again arguably) could be even faster than the two above, without losing flexibility neither speed, but increasing complexity :) (IIRC people here already described this approach in past discussions, but if necessary I could elaborate in some future message). Back to caching... Gavin wrote: > The output is static, the input is not. So he just confirms my /misunderstood/ observation: >> We settled it's not a static file, so using source_file's mtime is >> wrong, as you don't use the resultant mtime composed from _all_ the >> resources involved in generating the response. Let's take an example, maybe it will better explain what I was talking about: Scenario: We have to generate dynamic CSS rules for our users. Background: User settings are stored in a database table "user_settings" keyed by userID, having fields like "body_color", "h1_color", etc and a "last_updated" field. Approach: We generate that CSS rules page properly using the values from those user_settings fields. Now we're to set the "Last-Modified" header: <%perl> my @mtimes = ( $user->settings->last_updated->epoch, ( stat $m->current_comp->source_file )[9], # ... mtime of other data involved in generating the output ... ); $r->set_last_modified( max @mtimes ); </%perl> cheers. - -- Marius Feraru -----BEGIN PGP SIGNATURE----- iD8DBQFE1ewstZHp/AYZiNkRAotYAJ4vtpJj9fUcmHciM8F2x0E2mWsYhQCeNDmf rW51MHShhURWG7KEQfenrw8= =kRC1 -----END PGP SIGNATURE----- ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Mason-users mailing list Mason-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mason-users