Guest User

Untitled

a guest
Aug 7th, 2012
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. class ItemValidator(object):
  2.  
  3. def __init__(self, items):
  4. self.items = items
  5.  
  6. def validate(self):
  7. if Item("Green") in items:
  8. raise MyGreenValidationError
  9. return True
  10.  
  11. >>> f = Foo()
  12. >>> item = Item("Green")
  13. >>> f.items.add(item)
  14. >>> i = ItemValidator(items)
  15. >>> if i.validate():
  16. >>> f.items.save() # or something
Advertisement
Add Comment
Please, Sign In to add comment