SHARE
TWEET

Untitled

a guest May 31st, 2017 99 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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'mr@voipeople.it')
  34.         >>> dummy = store.add(faxline)
  35.         >>> email = SenderEmail(email=u'marco@voipeople.it', 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.         u'marco@voipeople.it'
  48.  
  49.     Clean up the testing database:
  50.  
  51.         >>> zstorm.remove(store)
  52.  
  53.     """
  54.  
  55.     implements(ISenderEmail, IVoipeopleSecurity)
  56.  
  57.     __storm_table__ = 'sender_emails'
  58.     __storm_items__ = ()
  59.  
  60.     def __get_name(self):
  61.         return unicode(self.id)
  62.     def __set_name(self, value):
  63.         pass
  64.     __name__ = property(__get_name, __set_name)
  65.  
  66.     def __get_parent(self):
  67.         return self.faxline['senderemails']
  68.     def __set_parent(self, value):
  69.         pass
  70.     __parent__ = property(__get_parent, __set_parent)
  71.  
  72.     id = SQL.Int(primary=True)
  73.  
  74.     email = SQL.Unicode()
  75.  
  76.     active = SQL.Bool()
  77.    
  78.     fax_line_id = SQL.Int()
  79.     faxline = SQL.Reference(fax_line_id, 'FaxLine.id')  
  80.    
  81.     @staticmethod
  82.     def get_info():
  83.         info = {
  84.             'search_field': FaxLine.email,
  85.             'interface': IFaxLine,
  86.             'fields': ('email', 'active')
  87.         }
  88.         return info
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top