def _tokenFactory(authenticated):
if not authenticated:<EOL><INDENT>weAreGood = False<EOL>authenticated = { '<STR_LIT:data>': None, '<STR_LIT>': None }<EOL><DEDENT>else:<EOL><INDENT>weAreGood = True<EOL><DEDENT>class Token(object):<EOL><INDENT>def __dir__(self):<EOL><INDENT>'''<STR_LIT>'''<EOL>return ['<STR_LIT>'] + authenticated.keys()<EOL><DEDENT>def __getattribute__(self, name):<EOL><INDENT>'''<STR_LIT>'''<EOL>if name == '<STR_LIT>':<EOL><INDENT>if weAreGood:<EOL><INDENT>return datetime.now() <= authenticated['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>if name in authenticated:<EOL><INDENT>return authenticated[name]<EOL><DEDENT>else:<EOL><INDENT>raise AttributeError('<STR_LIT>' % name)<EOL><DEDENT><DEDENT>def __setattr__(self, value, name):<EOL><INDENT>'''<STR_LIT>'''<EOL>raise AttributeError('<STR_LIT>')<EOL><DEDENT><DEDENT>return Token()<EOL>
Build a Token class, based upon the function arguments in the closure,
and return an instantiation of it. This allows us return an object
with truly read-only properties :) These 'hoops' suggest that this is
probably 'unpythonic', but what can you do?!

n.b., This shouldn't be invoked directly.