Skip to content

Instantly share code, notes, and snippets.

@pims
Created April 23, 2010 01:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pims/376038 to your computer and use it in GitHub Desktop.
Save pims/376038 to your computer and use it in GitHub Desktop.
#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