On Jan 2, 2013, at 2:27 PM, David Golden <[email protected]> wrote:

> On Wed, Jan 2, 2013 at 5:16 PM, Rick Bragg <[email protected]> wrote:
>> hooks and routes are called once in the application flow.  Do I really have 
>> to
>> program around this taking into consideration the number of times the before 
>> hook
>> is called on each page?
> 
> HTTP is stateless.  The client can make as many requests as it likes
> and your Dancer app will see them as separate requests.
> 
> The 'before' hook fires for every request.  If you want to limit a
> hook to particular routes, you have to write that logic yourself in
> the hook subroutine or else wrap the route handlers instead of using a
> before hook.

While the above explanation makes sense, and understanding it can lead to 
designing applications better, my gut feeling is with Rick. If I create a 
'before' hook, I want it normally to fire once everything the human user makes 
a request even though under the scene the browser is making multiple requests. 
In other words, the current behavior seems to be against the DWIM nature that I 
would expect. 

Dancer being the new, easy way of developing apps, should perhaps have two 
kinds of hooks -- one that behaves the current way, and another that fires the 
way Rick, myself, and I suspect many other Dancer users expect it to behave, 
that is, once per human user request.


--
Puneet Kishor
_______________________________________________
dancer-users mailing list
[email protected]
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users

Reply via email to