Coverage for control/typ/cust/user.py : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from control.html import HtmlElements as H
2from control.typ.value import Value
5class User(Value):
6 """Type class for users.
8 !!! note
9 This is an example of a type class that needs
10 `control.auth.Auth` (which it gets through
11 `control.context.Context`) in order
12 to display titles for users cautiously.
14 !!! caution
15 Do not reveal too many details to unauthenticated users.
16 """
18 needsContext = True
20 def __init__(self, context):
21 super().__init__(context)
23 def titleStr(self, record, markup=True, withRole=True, **kwargs):
24 context = self.context
25 auth = context.auth
27 valBare = auth.identity(record, markup=markup, withRole=withRole)
28 return valBare if markup is None else H.he(valBare)