Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/supybotconfig.py
diff options
context:
space:
mode:
authorRichard Darst <rkd@zgib.net>2009-07-01 22:32:32 (GMT)
committer Richard Darst <rkd@zgib.net>2009-07-01 22:32:32 (GMT)
commite2d92d2486678005213332b5b9aa0fb869b51706 (patch)
tree5843fd90215d95016448781692df3c915d3df4c0 /supybotconfig.py
parent6f333be6204cf2f53046f00ac2aa0599d68fe57b (diff)
Re-bind methods when used through the supybot config proxy
- See comment in this patch to understand what I mean - This is needed to have bound methods in the config class be able to see variables set in supybot. darcs-hash:20090701223232-82ea9-c495b40e37a104533b56d70826c664bbab8bc71a.gz
Diffstat (limited to 'supybotconfig.py')
-rw-r--r--supybotconfig.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/supybotconfig.py b/supybotconfig.py
index 129559a..8282f0b 100644
--- a/supybotconfig.py
+++ b/supybotconfig.py
@@ -60,13 +60,24 @@ class SupybotConfigProxy(object):
channel=self.__C.M.channel)
if not isinstance(value, (str, unicode)):
return value
+ # '.' is used to mean "this is not set, use the default
+ # value from the python config class.
if value != '.':
value = value.replace('\\n', '\n')
return value
# We don't have this value in the registry. So, proxy it to
# the normal config object. This is also the path that all
# functions take.
- return getattr(self.__C, attrname)
+ value = getattr(self.__C, attrname)
+ # If the value is an instance method, we need to re-bind it to
+ # the new config class so that we will get the data values
+ # defined in supydot (otherwise attribute lookups in the
+ # method will bypass the supybot proxy and just use default
+ # values). This will slow things down a little bit, but
+ # that's just the cost of duing business.
+ if hasattr(value, 'im_func'):
+ return types.MethodType(value.im_func, self, value.im_class)
+ return value