<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.dabo.leafe.com/index.php?action=history&amp;feed=atom&amp;title=Hook_Methods</id>
	<title>Hook Methods - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.dabo.leafe.com/index.php?action=history&amp;feed=atom&amp;title=Hook_Methods"/>
	<link rel="alternate" type="text/html" href="https://wiki.dabo.leafe.com/index.php?title=Hook_Methods&amp;action=history"/>
	<updated>2026-11-21T13:57:24Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.12</generator>
	<entry>
		<id>https://wiki.dabo.leafe.com/index.php?title=Hook_Methods&amp;diff=4168&amp;oldid=prev</id>
		<title>Ed: Created page with &quot;This is a generic term for methods of the framework that are empty by default so that developers can add their code to them without fear of overriding any important framework...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.dabo.leafe.com/index.php?title=Hook_Methods&amp;diff=4168&amp;oldid=prev"/>
		<updated>2020-05-15T17:37:50Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;This is a generic term for methods of the framework that are empty by default so that developers can add their code to them without fear of overriding any important framework...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This is a generic term for methods of the framework that are empty by default so that developers can add their code to them without fear of overriding any important framework code. They are placed at critical parts of framework processes in anticipation of developers needing to influence those processes at those points.&lt;br /&gt;
&lt;br /&gt;
The most common example are &amp;#039;&amp;#039;&amp;#039;beforeXX()&amp;#039;&amp;#039;&amp;#039; and &amp;#039;&amp;#039;&amp;#039;afterXX()&amp;#039;&amp;#039;&amp;#039; methods. Let&amp;#039;s say that there is an important method called &amp;quot;&amp;#039;&amp;#039;&amp;#039;XX()&amp;#039;&amp;#039;&amp;#039;&amp;quot;. As a developer, when you want to modify &amp;#039;&amp;#039;&amp;#039;XX&amp;#039;&amp;#039;&amp;#039; for your own needs, the most common need is to execute code either right before or right after the method, so your code would look like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
class MySubClass(FrameworkClass):&lt;br /&gt;
    def XX(self):&lt;br /&gt;
        #do your pre-code...&lt;br /&gt;
        super(MySubClass, self).XX()&lt;br /&gt;
        #do your post-code...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One of the most common mistakes is to forget the &amp;lt;code&amp;gt;super()&amp;lt;/code&amp;gt; call, which can introduce some extremely hard-to-find bugs into your code. So instead of following this pattern, Dabo adds hook methods that never need to call their superclass versions. Here&amp;#039;s how the &amp;lt;code&amp;gt;XX()&amp;lt;/code&amp;gt; method would be written in Dabo:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
def XX(self):&lt;br /&gt;
    if self.beforeXX() is False:&lt;br /&gt;
        return&lt;br /&gt;
    # Main body of the XX method...&lt;br /&gt;
    self.afterXX()&lt;br /&gt;
&lt;br /&gt;
def beforeXX(self):&lt;br /&gt;
    pass&lt;br /&gt;
&lt;br /&gt;
def afterXX(self):&lt;br /&gt;
    pass&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you are free to override one or the other hook methods, or neither, or both, without ever having to call &amp;lt;code&amp;gt;super()&amp;lt;/code&amp;gt;. What&amp;#039;s more, you also have the chance to abort the &amp;lt;code&amp;gt;XX()&amp;lt;/code&amp;gt; method by returning &amp;lt;code&amp;gt;False&amp;lt;/code&amp;gt; from the &amp;lt;code&amp;gt;beforeXX()&amp;lt;/code&amp;gt; method.&lt;br /&gt;
&lt;br /&gt;
Hook methods are used throughout Dabo; be sure to check the docs or ask on the lists before overriding framework methods.&lt;/div&gt;</summary>
		<author><name>Ed</name></author>
	</entry>
</feed>