@identity_loaded.connect
def on_identity_loaded(sender, identity):
 user = User.query.filter((User.id == identity.id)).first()
 identity.provides.add(UserNeed(identity.id))
 if hasattr(user, u'roles'):
  for role in user.roles:
   identity.provides.add(RoleNeed(role.name))
 g.user = user

@ identity_loaded . connect def on_identity_loaded ( sender , identity ) : user = User . query . filter ( ( User . id == identity . id ) ) . first ( ) identity . provides . add ( UserNeed ( identity . id ) ) if hasattr ( user , u'roles' ) : for role in user . roles : identity . provides . add ( RoleNeed ( role . name ) ) g . user = user
sets the identity of a given option .