GNOME Bugzilla – Bug 321196
application wrappers need updating to new action API
Last modified: 2005-12-01 16:20:40 UTC
2005-11-08 Zack Cerza <zcerza@redhat.com> * dogtail/tree.py: Remove "various wrapper/helper search methods": Node.{child, menu, menuItem, textentry, button, childLabelled, childNamed, tab}(). Node.menu() conflicted with the other Node.menu(), which is needed to execute the AccessibleAction's 'menu' action. Unfortunately, these methods are heavily used in both the apps/wrappers files and in the example files. examples/evolution-test-composing-html.py now fails: Detecting distribution: Red Hat/Fedora/derived distribution Warning: Dogtail could not import the Python bindings for libwnck. Window-manager manipulation will not be available. Evolution version 2.4.1 evolution-data-server version 1.4.1.1 gtkhtml3 version 3.8.1 Traceback (most recent call last):
+ Trace 64001
composer = evo.composeEmail()
self.menu("File").child("Mail Message").click()
actions = self.actions
for i in xrange (self.__action.getNActions ()):
else: raise AttributeError, attr
examples/evolution-test-configuring-exchange.py Detecting distribution: Red Hat/Fedora/derived distribution Warning: Dogtail could not import the Python bindings for libwnck. Window-manager manipulation will not be available. Evolution version 2.4.1 evolution-data-server version 1.4.1.1 gtkhtml3 version 3.8.1 Traceback (most recent call last): File "./evolution-test-configuring-exchange.py", line 19, in ? evo.createAccount(account, "test Exchange account") File "/home/david/coding/dogtail/dogtail/apps/wrappers/evolution.py", line 236, in createAccount self.getConfigMenuItem().click() File "/home/david/coding/dogtail/dogtail/apps/wrappers/evolution.py", line 64, in getConfigMenuItem return self.menu("Edit").menuItem("Preferences") File "/home/david/coding/dogtail/dogtail/tree.py", line 457, in __getattr__ actions = self.actions File "/home/david/coding/dogtail/dogtail/tree.py", line 449, in __getattr__ for i in xrange (self.__action.getNActions ()): File "/home/david/coding/dogtail/dogtail/tree.py", line 493, in __getattr__ else: raise AttributeError, attr AttributeError: _Node__action examples/evolution-test-configuring-imap-smtp.py Detecting distribution: Red Hat/Fedora/derived distribution Warning: Dogtail could not import the Python bindings for libwnck. Window-manager manipulation will not be available. Evolution version 2.4.1 evolution-data-server version 1.4.1.1 gtkhtml3 version 3.8.1 Traceback (most recent call last): File "examples/evolution-test-configuring-imap-smtp.py", line 21, in ? evo.createAccount(account, "test IMAP/SMTP account") File "/home/david/coding/dogtail/dogtail/apps/wrappers/evolution.py", line 236, in createAccount self.getConfigMenuItem().click() File "/home/david/coding/dogtail/dogtail/apps/wrappers/evolution.py", line 64, in getConfigMenuItem return self.menu("Edit").menuItem("Preferences") File "/home/david/coding/dogtail/dogtail/tree.py", line 457, in __getattr__ actions = self.actions File "/home/david/coding/dogtail/dogtail/tree.py", line 449, in __getattr__ for i in xrange (self.__action.getNActions ()): File "/home/david/coding/dogtail/dogtail/tree.py", line 493, in __getattr__ else: raise AttributeError, attr AttributeError: _Node__action examples/evolution-test-sending-email.py Detecting distribution: Red Hat/Fedora/derived distribution Warning: Dogtail could not import the Python bindings for libwnck. Window-manager manipulation will not be available. Evolution version 2.4.1 evolution-data-server version 1.4.1.1 gtkhtml3 version 3.8.1 Traceback (most recent call last): File "examples/evolution-test-sending-email.py", line 18, in ? composer = evo.composeEmail() File "/home/david/coding/dogtail/dogtail/apps/wrappers/evolution.py", line 284, in composeEmail self.menu("File").child("Mail Message").click() File "/home/david/coding/dogtail/dogtail/tree.py", line 457, in __getattr__ actions = self.actions File "/home/david/coding/dogtail/dogtail/tree.py", line 449, in __getattr__ for i in xrange (self.__action.getNActions ()): File "/home/david/coding/dogtail/dogtail/tree.py", line 493, in __getattr__ else: raise AttributeError, attr AttributeError: _Node__action examples/evolution-test-first-time-wizard.py Detecting distribution: Red Hat/Fedora/derived distribution Warning: Dogtail could not import the Python bindings for libwnck. Window-manager manipulation will not be available. Bonobo accessibility support initialized GTK Accessibility Module initialized Shutting down evolution (Evolution Shell) Shutting down evolution-alarm-notify (Evolution Calendar alarm notification service) Bonobo accessibility support initialized GTK Accessibility Module initialized adding hook target 'source' Setting up initial mail tree addressbook_migrate (0.0.0) (evolution:21608): Gtk-CRITICAL **: gtk_widget_hide: assertion `GTK_IS_WIDGET (widget)' failed Evolution version 2.4.1 evolution-data-server version 1.4.1.1 gtkhtml3 version 3.8.1 Traceback (most recent call last): File "examples/evolution-test-first-time-wizard.py", line 21, in ? evo = doFirstTimeWizard(account, "test IMAP/SMTP account", "America/New_York") File "/home/david/coding/dogtail/dogtail/apps/wrappers/evolution.py", line 589, in doFirstTimeWizard evo.doFirstTimeWizard(account, accountName, timezoneName) File "/home/david/coding/dogtail/dogtail/apps/wrappers/evolution.py", line 261, in doFirstTimeWizard setupWiz = Wizard(self.window('Evolution Setup Assistant')) File "/home/david/coding/dogtail/dogtail/tree.py", line 958, in __init__ logger.log("%s is on '%s' page"%(self, self.getPageTitle())) File "/home/david/coding/dogtail/dogtail/tree.py", line 981, in getPageTitle currentPage = self.currentPage() File "/home/david/coding/dogtail/dogtail/tree.py", line 966, in currentPage pageHolder = self.child(roleName='panel') File "/home/david/coding/dogtail/dogtail/tree.py", line 493, in __getattr__ else: raise AttributeError, attr AttributeError: child examples/evolution-test-survives-email-CAN-2005-0806.py Detecting distribution: Red Hat/Fedora/derived distribution Warning: Dogtail could not import the Python bindings for libwnck. Window-manager manipulation will not be available. Evolution version 2.4.1 evolution-data-server version 1.4.1.1 gtkhtml3 version 3.8.1 Traceback (most recent call last): File "examples/evolution-test-survives-email-CAN-2005-0806.py", line 17, in ? evo.importSingleEmail(path.abspath("data/CAN-2005-0806.mbox")) File "/home/david/coding/dogtail/dogtail/apps/wrappers/evolution.py", line 139, in importSingleEmail importAssistant = self.__doImportFromSingleFile(filename, filetype) File "/home/david/coding/dogtail/dogtail/apps/wrappers/evolution.py", line 112, in __doImportFromSingleFile importAssistant = self.__doImportFirstPage() File "/home/david/coding/dogtail/dogtail/apps/wrappers/evolution.py", line 100, in __doImportFirstPage self.menu("File").menuItem("Import...").click() File "/home/david/coding/dogtail/dogtail/tree.py", line 457, in __getattr__ actions = self.actions File "/home/david/coding/dogtail/dogtail/tree.py", line 449, in __getattr__ for i in xrange (self.__action.getNActions ()): File "/home/david/coding/dogtail/dogtail/tree.py", line 493, in __getattr__ else: raise AttributeError, attr AttributeError: _Node__action examples/evolution-test-switching-components.py Detecting distribution: Red Hat/Fedora/derived distribution Warning: Dogtail could not import the Python bindings for libwnck. Window-manager manipulation will not be available. Traceback (most recent call last): File "examples/evolution-test-switching-components.py", line 20, in ? evo.menu('View').menu('Window').menuItem(compName).click() File "/home/david/coding/dogtail/dogtail/tree.py", line 457, in __getattr__ actions = self.actions File "/home/david/coding/dogtail/dogtail/tree.py", line 449, in __getattr__ for i in xrange (self.__action.getNActions ()): File "/home/david/coding/dogtail/dogtail/tree.py", line 493, in __getattr__ else: raise AttributeError, attr AttributeError: _Node__action ./examples/gcalctool-test-fibonacci.py Detecting distribution: Red Hat/Fedora/derived distribution Warning: Dogtail could not import the Python bindings for libwnck. Window-manager manipulation will not be available. Bonobo accessibility support initialized GTK Accessibility Module initialized (gcalctool:21663): Gdk-CRITICAL **: gdk_window_invalidate_rect: assertion `window != NULL' failed (gcalctool:21663): Gdk-CRITICAL **: gdk_window_invalidate_rect: assertion `window != NULL' failed Traceback (most recent call last): File "./examples/gcalctool-test-fibonacci.py", line 18, in ? gcalctool.clearEntry() File "/home/david/coding/dogtail/dogtail/apps/wrappers/gcalctool.py", line 20, in clearEntry self.button('Clear entry').click() File "/home/david/coding/dogtail/dogtail/tree.py", line 493, in __getattr__ else: raise AttributeError, attr AttributeError: button
We'll work this out very soon... hopefully today.
Created attachment 54926 [details] [review] patch Here's a patch that fixes the problem by re-adding the methods and changing the Action API. The application wrappers, and possibly the scripts using them, will need to be updated, as this just breaks them in a different way. We're not going to avoid some level of breakage. The patch updates the procedural interface, so scripts written to that should work as before. It was a one-liner.
As discussed on IRC, I think you should commit this but leave the bug open: the patch is a big improvement, and gets the scripts closer to working, and restores most of the usability of the OO API; however the script removes the synthesized "action" wiring (which most of the OO wrappers and OO example scripts rely on), hence they still won't work, I think. The use of a dict rather than a list is cool. IMHO we should retain the synthesized action methods in spite of the ambiguity over the "menu" method, but we should mark them clearly in the documentation as a shortcut to calling: node.action['name-of-action'].do() and be clear in the documentation about where this breaks down. I'm thinking about this from an ease-of-use POV for people using the OO API. (I think we badly need unit tests, there's a separate bug open about this)
I'm definitely opposed to having some shortcut methods that work, and special-casing the rest. I don't want to worry about breaking an API in more places than I absolutely have to. Another solution would be to simply rename the convenience methods that were removed, and leave the Action API the way it was. I think we talked about this before, though, and you didn't want to do that. Do you still feel that way?
Created attachment 55293 [details] [review] new patch Here's the latest version of the patch. API is 'node.doAction(actionName)'. I'm committing now as an executive decision, but discussion isn't closed, mostly because this doesn't fix the wrappers - that remains to be done.
Committed the patch, but leaving the bug open as the application wrappers are still using the old API. The patch as attached differs form the patch as committed in that I removed the "Closes: #321196" note. :)
I think there are good grounds for implementing a single special case here: the "click" action. It's the only one that got used throughout the bulk of the examples and wrappers, and I think any script using the OO api without wrappers is going to do a click in at least one place; usually several. Grepping for "click" in the wrapper code confirms this: grep click dogtail/apps/wrappers/*.py | wc -l 56 ...and in the examples: grep click examples/*.py | wc -l 30 I'm about to attach a proposed patch...
Created attachment 55358 [details] [review] Patch to add a Node.click method and improve error handling This patch adds adds the special-case Node.click() method, and an ActionNotSupported exception to give better error handling (more readable than a KeyError inside doAction). With this patch all the examples listed in the original bug report work as they did before.
Created attachment 55482 [details] [review] modified version of the above patch I made some changes to your patch, as we discussed yesterday. I fixed up click()'s docstring, and optimized it a tiny bit.
Committed. Closing this bug and ending the pain.