Going through the documentation of pylon project wiki2 tutorial found this codes and What I know is a class has a function definition defined with indentation after class declaration. Checked the python documentation too and is the same but the project documentation has something like a class definition with indentation and without indentation. Can anybody make me clear on this.
from pyramid.authentication import AuthTktAuthenticationPolicy
from pyramid.authorization import ACLAuthorizationPolicy
from pyramid.security import (
Authenticated,
Everyone,
)
from .models import User
class MyAuthenticationPolicy(AuthTktAuthenticationPolicy):
def authenticated_userid(self, request):
user = request.user
if user is not None:
return user.id
def effective_principals(self, request):
principals = [Everyone]
user = request.user
if user is not None:
principals.append(Authenticated)
principals.append(str(user.id))
principals.append('role:' + user.role)
return principals
def get_user(request):
user_id = request.unauthenticated_userid
if user_id is not None:
user = request.dbsession.query(User).get(user_id)
return user
I have pasted the few lines of codes from the documentation as we can see the first two function def are indented but the third function get_user is not. what is the purpose exactly.