Some more slight tweaks to the MetaFirewall implementation and stuff.

This commit is contained in:
Jeremy Fincher 2005-05-15 17:08:02 +00:00
parent 2861b5a334
commit 1d357dd470
3 changed files with 7 additions and 9 deletions

View File

@ -72,7 +72,6 @@ class IrcCallback(IrcCommandDispatcher):
__firewalled__ = {'die': None, __firewalled__ = {'die': None,
'reset': None, 'reset': None,
'__call__': None, '__call__': None,
'__lt__': lambda self: 0,
'inFilter': lambda self, irc, msg: msg, 'inFilter': lambda self, irc, msg: msg,
'outFilter': lambda self, irc, msg: msg, 'outFilter': lambda self, irc, msg: msg,
'name': lambda self: self.__class__.__name__, 'name': lambda self: self.__class__.__name__,

View File

@ -330,15 +330,13 @@ def firewall(f, errorHandler=None):
class MetaFirewall(type): class MetaFirewall(type):
def __new__(cls, name, bases, dict): def __new__(cls, name, bases, dict):
firewalled = {}
if '__firewalled__' in dict: if '__firewalled__' in dict:
firewalled.update(dict['__firewalled__']) for attr in dict['__firewalled__']:
for attr in firewalled: try:
try: errorHandler = firewalled[attr]
errorHandler = firewalled[attr] except: # This is raw here so people can still use tuples.
except: errorHandler = None
errorHandler = None dict[attr] = firewall(dict[attr], errorHandler)
dict[attr] = firewall(dict[attr], errorHandler)
return super(MetaFirewall, cls).__new__(cls, name, bases, dict) return super(MetaFirewall, cls).__new__(cls, name, bases, dict)
#return type.__new__(cls, name, bases, dict) #return type.__new__(cls, name, bases, dict)

View File

@ -31,6 +31,7 @@ class Object(object):
def __ne__(self, other): def __ne__(self, other):
return not self == other return not self == other
class TupleSubclass(type): class TupleSubclass(type):
def __new__(cls, name, bases, dict): def __new__(cls, name, bases, dict):
assert tuple in bases assert tuple in bases