Guest User

Untitled

a guest
May 31st, 2017
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. class SenderEmail(Storm):
  2. """Address object
  3.  
  4. Verify if the class implements the interfaces:
  5.  
  6. >>> from zope.interface.verify import verifyClass
  7. >>> verifyClass(ISenderEmail, SenderEmail)
  8. True
  9.  
  10. Create a testing database:
  11.  
  12. >>> import transaction
  13. >>> from voipeople.zsqlobject import create_testingdb
  14. >>> zstorm, store = create_testingdb('voipeople')
  15.  
  16. >>> from voipeople.content import Account, Address, Department, FaxLine, List
  17. >>> account = Account(legal_name=u'Kynetix S.r.l.', vat_rate = 20, billing_type_id =1)
  18. >>> dummy = store.add(account)
  19. >>> transaction.get().commit()
  20. >>> address = Address(line1=u'DUMMY', city=u'DUMMY', state=u'DUMMY',
  21. ... zip_code=u'00000', country=u'DUMMY', account=account)
  22. >>> dummy = store.add(address)
  23. >>> transaction.get().commit()
  24. >>> list = List(description=u'Voipeople Gold')
  25. >>> dummy = store.add(list)
  26. >>> transaction.get().commit()
  27. >>> department = Department(description=u'DUMMY',
  28. ... account=account, address=address)
  29. >>> dummy = store.add(department)
  30. >>> transaction.get().commit()
  31. >>> faxline = FaxLine(username=u'marco', password=u'granata',
  32. ... fax_number_id=2,department=department,
  33. ... salelist=list, account=account,delivery_email=u'[email protected]')
  34. >>> dummy = store.add(faxline)
  35. >>> email = SenderEmail(email=u'[email protected]', faxline=faxline )
  36. >>> dummy = store.add(email)
  37. >>> transaction.get().commit()
  38. >>> from zope.interface.verify import verifyObject
  39. >>> verifyObject(ISenderEmail, email)
  40. True
  41.  
  42. Verify data and relations:
  43.  
  44. >>> email.faxline.username
  45. u'marco'
  46. >>> email.email
  47.  
  48. Clean up the testing database:
  49.  
  50. >>> zstorm.remove(store)
  51.  
  52. """
  53.  
  54. implements(ISenderEmail, IVoipeopleSecurity)
  55.  
  56. __storm_table__ = 'sender_emails'
  57. __storm_items__ = ()
  58.  
  59. def __get_name(self):
  60. return unicode(self.id)
  61. def __set_name(self, value):
  62. pass
  63. __name__ = property(__get_name, __set_name)
  64.  
  65. def __get_parent(self):
  66. return self.faxline['senderemails']
  67. def __set_parent(self, value):
  68. pass
  69. __parent__ = property(__get_parent, __set_parent)
  70.  
  71. id = SQL.Int(primary=True)
  72.  
  73. email = SQL.Unicode()
  74.  
  75. active = SQL.Bool()
  76.  
  77. fax_line_id = SQL.Int()
  78. faxline = SQL.Reference(fax_line_id, 'FaxLine.id')
  79.  
  80. @staticmethod
  81. def get_info():
  82. info = {
  83. 'search_field': FaxLine.email,
  84. 'interface': IFaxLine,
  85. 'fields': ('email', 'active')
  86. }
  87. return info
Advertisement
Add Comment
Please, Sign In to add comment