1 Oct 2006 19:16
Using reporter observer pattern in a writer
Dave Kuhlman <dkuhlman <at> rexx.com>
2006-10-01 17:16:47 GMT
2006-10-01 17:16:47 GMT
While I was working on implementing a writer for Docutils ... The Writer/Translator design seems very powerful and has been very useful to me, especially as I learn and understand it better. So, I have a question (or two) ... The translator (in my case, a subclass of nodes.GenericNodeVisitor) has a document attribute, which has a reporter attribute. The reporter supports 'a modified form of the "Observer" pattern'. When I attach an observer (a method), I find that it receives as its argument an instance of class nodes.system_message. How do I use this system_message object? - One thing that I want to be able to use in my observer method is the current node. I can't find it. Is it in the system_message object someplace? - The system_message object has a tagname attribute. But, that seems to always return "system_message". I was hoping for the name of the current node. - How would I write an observer method that prints out just the name of the current node? Ditto for the name of the current visit_/depart_ method. The system_message object has a string representation that contains this information, and I suppose I could parse that. But, I suspect that is not the way this object was intended to be used. This observer and system_message thing seems very ingenious. It(Continue reading)
RSS Feed