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,
'reset': None,
'__call__': None,
'__lt__': lambda self: 0,
'inFilter': lambda self, irc, msg: msg,
'outFilter': lambda self, irc, msg: msg,
'name': lambda self: self.__class__.__name__,

View File

@ -330,15 +330,13 @@ def firewall(f, errorHandler=None):
class MetaFirewall(type):
def __new__(cls, name, bases, dict):
firewalled = {}
if '__firewalled__' in dict:
firewalled.update(dict['__firewalled__'])
for attr in firewalled:
try:
errorHandler = firewalled[attr]
except:
errorHandler = None
dict[attr] = firewall(dict[attr], errorHandler)
for attr in dict['__firewalled__']:
try:
errorHandler = firewalled[attr]
except: # This is raw here so people can still use tuples.
errorHandler = None
dict[attr] = firewall(dict[attr], errorHandler)
return super(MetaFirewall, cls).__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):
return not self == other
class TupleSubclass(type):
def __new__(cls, name, bases, dict):
assert tuple in bases