I got problems using Twisted cred with Python2.2.0. My perspectives names are based on a url encoding. I have found that there is a problem when PerspectiveName is unicode. I also discovered that the error message is not explicative. The CVS does not have a solution for this problems. Both diminute problem are solved in the next patch. Twisted is a great tool. Thanks you for Twisted. RodrigoB. - Post patch for twisted.cred.perspective (Type -> Types, report error type): the cause: ---------- import types isinstance(u"/test1", types.StringType) =>0 The patch: ---------- class Perspective: """I am an Identity's view onto a service. I am the interface through which most 'external' code should interact with a service; I represent the actions a user may perform upon a service, and the state associated with that user for that service. """ _service_cached = 0 # Has my service cached me from a loaded store, or do I live in memory usually? def __init__(self, perspectiveName, identityName="Nobody"): """Create me. I require a name for myself and a reference to the service I participate in. (My identity name will be 'Nobody' by default, which will normally not resolve.) """ if not isinstance(perspectiveName, types.StringTypes): raise TypeError("Expected string, got '%s' (%s)."% (perspectiveName, type(perspectiveName))) if not isinstance(identityName, types.StringTypes): raise TypeError("Expected string, got '%s' (%s)."% (identityName, type(identityName))) self.perspectiveName = perspectiveName self.identityName = identityName The diff --------- $ diff perspective.py /usr/local/lib/python2.2/site-packages/twisted/cred/perspective.py 49,52c49,52 < if not isinstance(perspectiveName, types.StringType): < raise TypeError("Expected string, got %s."% perspectiveName) < if not isinstance(identityName, types.StringType): < raise TypeError("Expected string, got %s."% identityName) ---
if not isinstance(perspectiveName, types.StringTypes): raise TypeError("Expected string, got '%s' (%s)."% (perspectiveName, type(perspectiveName))) if not isinstance(identityName, types.StringTypes): raise TypeError("Expected string, got '%s' (%s)."% (identityName, type(identityName)))