Skip to content

Instantly share code, notes, and snippets.

@t0ster
Created March 5, 2013 15:12
Show Gist options
  • Save t0ster/5090969 to your computer and use it in GitHub Desktop.
Save t0ster/5090969 to your computer and use it in GitHub Desktop.
def user_validator(obj):
return True
class BaseHandler(object):
validator = None
def post(self, data):
if self.validator(data):
return 'ok'
else:
return 'error'
class UserHandler(BaseHandler):
validator = user_validator
def main():
user_handler = UserHandler()
print user_handler.post('somedata')
if __name__ == '__main__':
main()
Traceback (most recent call last):
File "/Users/t0ster/Desktop/test.py", line 24, in <module>
main()
File "/Users/t0ster/Desktop/test.py", line 20, in main
print user_handler.post('somedata')
File "/Users/t0ster/Desktop/test.py", line 8, in post
if self.validator(data):
TypeError: user_validator() takes exactly 1 argument (2 given)
[Finished in 0.1s with exit code 1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment