I have a class called BlogHandler that has some basic functionality in it. I pass this class into another class called MainPage. I am trying to use a function from BlogHandler in my MainPage class, but it is saying it isn’t defined.
class BlogHandler:
def read_secure_cookie(self, name):
cookie_val = self.request.cookies.get(name)
return cookie_val and check_secure_val(cookie_val)
class MainPage(BlogHandler):
def post(self):
email = self.request.get('email')
product = self.request.get('product')
username = read_secure_cookie('content')
The ‘content’ of the cookie is 14|b670fedff24f182e52a1ceacf7790e02. How do I return just the ‘cookie_val’ and just the first part of the ‘cookie_val’ (the 14).
Thanks
For the first error, you need to use:
Any superclass methods must also be called with
self. (There are other ways, but this is best practice.)As for correcting your other problem (I’m assuming you want to return multiple values), just use a comma instead of
and:For your third problem, split as Chris said:
Putting it all together:
If I didn’t understand you correctly, please say so!