from template.template import Template
class UsermenuTemplate(Template):
def wrap(self, answer):
user = answer.request.user
assert(user)
return '''
<div class="usermenu">
<form method="POST">
%(title)s <a href="%(profile)s">%(name)s (%(login)s)</a>
<input type="hidden" name="action" value="user.login" />
<input type="submit" value="%(logout)s" />
</form>
</div>
''' % {
'title' : answer.te('You logged in as:'),
'profile' : answer.request.get_urlpath_escaped(['user', str(user.login)]),
'login' : answer.e(user.login if user else ''),
'name' : answer.e(user.name if user else ''),
'logout' : answer.te('Logout'),
}