[Twisted-Python] cred realm with __init__ methods under twistd
Hello everyone, I'm working on a twisted application that uses cred and pb. I'm having a bit of trouble getting my realm working as I want. In my .tac file, I have this: p = portal.Portal(CNDRealm()) c = checkers.InMemoryUsernamePasswordDatabaseDontUse(user="passwd") p.registerChecker(c) application = service.Application("receiver") service = service.IServiceCollection(application) factory = pb.PBServerFactory(p) internet.TCPServer(8800, factory).setServiceParent(service) My realm, CNDRealm, looks like this: from globals import devs, queues, conditions, devices class CNDRealm(object): implements(portal.IRealm) def __init__(self): for i in devs: queues[i] = list() conditions[i] = threading.Condition() devices[i] = CNDDevice(i[0], socket.gethostbyname(i[0]), i[1], queues[i], conditions[i]) log.msg("Initialized devices: " % devices) def requestAvatar(self, aid, min, *interfaces): log.msg("Avatar requested: %s" % aid) if pb.IPerspective not in interfaces: raise NotImplementedError return pb.IPerspective, CNDSubmitter(aid), lambda: None However, I never get the log message from the __init__ method. I know that it's not being run because those dictionaries are never populated with the data my app needs to be in there. 1) What's going on? I'm pretty surprised to find that an object's __init__ doesn't seem to be getting called! 2) Is there some better place in a twistd app to put general start-up initialization kinds of things? -- Ross Vandegrift ross@kallisti.us "The good Christian should beware of mathematicians, and all those who make empty prophecies. The danger already exists that the mathematicians have made a covenant with the devil to darken the spirit and to confine man in the bonds of Hell." --St. Augustine, De Genesi ad Litteram, Book II, xviii, 37
On Tuesday 08 July 2008, Ross Vandegrift wrote:
log.msg("Initialized devices: " % devices)
There is no placeholder (like "%s") in the message string. This will raise a TypeError. Probably something is swallowing this error or an earlier error instead of displaying it. Bye, Maarten
On Tue, Jul 08, 2008 at 01:25:46AM +0200, Maarten ter Huurne wrote:
On Tuesday 08 July 2008, Ross Vandegrift wrote:
log.msg("Initialized devices: " % devices)
There is no placeholder (like "%s") in the message string. This will raise a TypeError. Probably something is swallowing this error or an earlier error instead of displaying it.
Aha - not only that but there was another typo in there throwing an exception in the first iteration of my setup loop. Good catch :) Ross
participants (2)
-
Maarten ter Huurne
-
Ross Vandegrift