[Twisted-Python] Standalone IRC server, or Passport/Words/Something sucks
Kevin Turner
acapnotic at twistedmatrix.com
Mon Dec 3 13:47:48 EST 2001
On Mon, Dec 03, 2001 at 03:12:22PM +0200, Itamar Shtull-Trauring wrote:
> Issues:
> 2. The automatic user creation is horribly verbose, hard to understand, and
> hacky (getPerspectiveNamed, specifically.)
{{{ # In response to Itamar's code:
from twisted.words import service, ircservice
class SimpleService(service.Service):
# If this is a standalone service, why does it inherit from
# words.service? You override all its methods save the dictionary
# accessor 'getGroup' anyhow.
def createParticipant(self, name):
if not self.participants.has_key(name):
log.msg("Created New Participant: %s" % name)
# Huh? createParticipant creates a log entry, but *not* a Participant?
def getPerspectiveNamed(self, name):
if self.participants.has_key(name):
raise service.WordsError, "user exists"
# Woah. getPerspectiveNamed is *supposed* to return existing
# perspectives. This error might be appropriate in createParticipant,
# but not here.
else:
p = service.Participant(name)
p.setService(self)
# Don't bitch about this method being "horribly verbose" when you
# explicitly duplicate code that's defined in your subclass. The above
# is done in passport.Service.createPerspective, which you deliberately
# clobbered.
ident = passport.Identity(name, self.application)
ident.setPassword("ugly hack")
# If you want to do this, please factor the strict authorization
# requirements out of words.ircservice.IRCChatter.irc_NICK (or factor
# words.ircservice.IRCChatter out of words.*) instead of doing an
# "ugly hack".
self.application.authorizer.addIdentity(ident)
p.setIdentity(ident)
ident.addKeyForPerspective(p)
# If you're using 'anonymous' logins with transient user identites,
# why are you using Identities at all? None of this is necessary if
# you're not planning on making use of a passport.DefaultAuthorizer
# anyway. See for example words.tendril._newParticipant, no identities
# are created and bound either here or in words.service methods.
self.participants[name] = p
return p
}}}
Overall, yes, words.ircservice is absolutely horrible for use as a
"normal" IRC server. But then, it's not intended to be one, that's why
it's in the twisted.words package. It's also true that it's a fairly
shoddy Words interface as well, but aren't they all? ;)
- AcapNotIRC
--
The moon is waning gibbous, 92.1% illuminated, 17.4 days old.
More information about the Twisted-Python
mailing list