Re: [Twisted-web] How to insert an Athena event handler using Stan?
On 07:56 pm, exarkun@divmod.com wrote:
On Tue, 31 Oct 2006 11:57:05 -0500, Phil Christensen <phil@bubblehouse.org> wrote:
T.div(render=T.directive('liveElement'))[ T.input(type='text', size=80)[athena.handler(event='onkeypress', handler='parse')]]) ]
fails without generating any error. I guess I'm okay with the first version for my particular use-case, but I'd be interested to know if there's something obvious I'm missing, or other information I can supply.
How does it fail? Can you throw together a minimal self-contained example? I use this in a lot of places and it works and as far as I understand there is no reason it shouldn't.
Not only does it work, but we are trying to move towards that being the suggested style, as it generally has superior error-handling characteristics. It would be really nice to get issues with it fixed, and even if this isn't a real problem, document it as a possible "gotcha" so people do not feel uneasy about taking this approach. So.. got a unit test? :)
On Oct 31, 2006, at 3:49 PM, glyph@divmod.com wrote:
On 07:56 pm, exarkun@divmod.com wrote:
How does it fail? Can you throw together a minimal self-contained example? I use this in a lot of places and it works and as far as I understand there is no reason it shouldn't.
Not only does it work, but we are trying to move towards that being the suggested style, as it generally has superior error-handling characteristics. It would be really nice to get issues with it fixed, and even if this isn't a real problem, document it as a possible "gotcha" so people do not feel uneasy about taking this approach.
So.. got a unit test? :)
I'm not entirely sure how to write a formal unit test that includes the javascript side testing, but I've attached a minimal test case to a ticket at: http://divmod.org/trac/ticket/1704 Basically, it appears that this might be particularly related to key events. My example code compares my nonstandard approach to the officially sanctioned version, for both text fields and buttons. It appears that buttons work properly, but not the text field. -phil
On Wednesday 01 November 2006 10:41, Phil Christensen wrote:
I'm not entirely sure how to write a formal unit test that includes the javascript side testing, but I've attached a minimal test case to a ticket at:
But it's so easy! (Oww, I pulled my sarcastic muscle.) Here is a tutorial: http://blackjml.livejournal.com/21602.html I mention only for posterity. Mike.
On Nov 1, 2006, at 10:50 AM, Mike Pelletier wrote:
On Wednesday 01 November 2006 10:41, Phil Christensen wrote:
I'm not entirely sure how to write a formal unit test that includes the javascript side testing, but I've attached a minimal test case to a ticket at:
But it's so easy! (Oww, I pulled my sarcastic muscle.)
Here is a tutorial: http://blackjml.livejournal.com/21602.html I mention only for posterity.
Thanks for the link; I had encountered that in my research, but I don't understand how this could be used to test an issue with an event handler. This may be just be due to my extremely poor unit testing discipline, but any clues would be appreciated! -phil
On Wed, 1 Nov 2006 11:00:24 -0500, Phil Christensen <phil@bubblehouse.org> wrote:
On Nov 1, 2006, at 10:50 AM, Mike Pelletier wrote:
On Wednesday 01 November 2006 10:41, Phil Christensen wrote:
I'm not entirely sure how to write a formal unit test that includes the javascript side testing, but I've attached a minimal test case to a ticket at:
But it's so easy! (Oww, I pulled my sarcastic muscle.)
Here is a tutorial: http://blackjml.livejournal.com/21602.html I mention only for posterity.
Thanks for the link; I had encountered that in my research, but I don't understand how this could be used to test an issue with an event handler. This may be just be due to my extremely poor unit testing discipline, but any clues would be appreciated!
Testing anything related to events is tricky, due to security controls imposed on page JavaScript. There's probably a way to deal with it, but it hasn't been documented or codified in Athena yet. The issue with the handler you showed me is most likely that the handler thinks its first argument is an event, but it is actually a node. There is no way to access the event object right now, but I have been considering just passing it as the next argument. Jean-Paul
On Wednesday 01 November 2006 18:15, Jean-Paul Calderone wrote:
The issue with the handler you showed me is most likely that the handler thinks its first argument is an event, but it is actually a node. There is no way to access the event object right now, but I have been considering just passing it as the next argument.
Darn, I only just now saw that there were more emails in this thread since I started to compose my example. That's probably the cause of the problem. So, is: function doFoo ( self, node ) currently the canonical prototype for all athena event handlers, without exception? Regards, Ricky
On Wed, 1 Nov 2006 19:05:38 +0200, kgi <iacovou@gmail.com> wrote:
On Wednesday 01 November 2006 18:15, Jean-Paul Calderone wrote:
The issue with the handler you showed me is most likely that the handler thinks its first argument is an event, but it is actually a node. There is no way to access the event object right now, but I have been considering just passing it as the next argument.
Darn, I only just now saw that there were more emails in this thread since I started to compose my example. That's probably the cause of the problem.
So, is:
function doFoo ( self, node )
currently the canonical prototype for all athena event handlers, without exception?
Yes, though this may shortly change to function doFoo(self, node, event) (which is completely backwards compatible, of course, due to the magic of javascript sucking so much). Jean-Paul
participants (5)
-
glyph@divmod.com
-
Jean-Paul Calderone
-
kgi
-
Mike Pelletier
-
Phil Christensen