Created
April 23, 2010 01:01
-
-
Save pims/376038 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pseudo code | |
#option 1 | |
class User: | |
screen_name = '' | |
email = '' | |
class UserManager: | |
def validate(user): | |
if user.screen_name == '': | |
raise CustomException(100,'Screen name can not be empty') | |
#in the GUI | |
user(screen_name='',email='') | |
try: | |
user_manager.insert(user) | |
except CustomException,e: | |
display_error_message(e.code) | |
#option 2 | |
class User: | |
screen_name = StringProperty(required=True,allow_empty=False) | |
email = EmailProperty() | |
#in GUI | |
try: | |
user(screen_name='',email='you@example') | |
except TypeException,e: | |
display_error_message(e.message) #string can not be empty |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment