Let's hope this doesn't break anything too serious.

This commit is contained in:
Jeremy Fincher 2004-08-21 09:14:59 +00:00
parent 62ff576aaa
commit 6ecf2ae6ea
2 changed files with 15 additions and 4 deletions

View File

@ -35,6 +35,7 @@ import supybot.fix as fix
import os
import sys
import time
import socket
import string
@ -90,11 +91,13 @@ def registerGroup(Group, name, group=None):
def registerGlobalValue(group, name, value):
value.channelValue = False
#value._lastModified = time.time() # So reloads don't change the value.
return group.register(name, value)
def registerChannelValue(group, name, value):
value._supplyDefault = True
value.channelValue = True
#value._lastModified = time.time() # So reloads don't change the value.
return group.register(name, value)
def registerPlugin(name, currentValue=None, public=True):

View File

@ -153,12 +153,15 @@ class Group(object):
class X(OriginalClass):
"""This class exists to differentiate those values that have
been changed from their default from those that haven't."""
def set(self, *args):
self.__class__ = OriginalClass
self.set(*args)
def setValue(self, *args):
comeBack = self._lastModified == 0
if not comeBack:
print '***', 'Changing %s to its OriginalClass.'%self._name
print '******', utils.stackTrace(compact=True)
self.__class__ = OriginalClass
self.setValue(*args)
if comeBack:
self.__class__ = X
self.X = X
def __call__(self):
@ -172,7 +175,7 @@ class Group(object):
v = self.__class__(self._default, self.help)
v.set(s)
v.__class__ = self.X
#v._supplyDefault = False
v._lastModified = time.time()
v.help = '' # Clear this so it doesn't print a bazillion times.
self.register(attr, v)
return v
@ -217,11 +220,13 @@ class Group(object):
if name in self._children:
# It's already here, let's copy some stuff over.
oldNode = self._children[name]
node._name = oldNode._name
node._added = oldNode._added
node._children = oldNode._children
for v in node._children.values():
if v.__class__ is oldNode.X:
v.__class__ = node.X
node._lastModified = oldNode._lastModified
self._children[name] = node
if name not in self._added:
self._added.append(name)
@ -280,9 +285,12 @@ class Value(Group):
raise InvalidRegistryValue, utils.normalizeWhitespace(s)
def setName(self, *args):
# If we're getting our name for the first time, we should definitely
# look in the _cache for our value.
if self._name == 'unset':
self._lastModified = 0
Group.setName(self, *args)
# Now we can feel safe setting our _lastModified to now.
self._lastModified = time.time()
def set(self, s):