Guest User

Untitled

a guest
May 20th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.24 KB | None | 0 0
  1. # Calling code
  2. inbox_settings = InboxSettings()
  3.  
  4. inbox_settings.load (HubSpotUserID)
  5.  
  6. print "\nPoint 1After load settings"
  7. print "\n", type(inbox_settings.twitter_settings)
  8. pprint.pprint (vars(inbox_settings))
  9.  
  10. print "\nTracked Accounts=", inbox_settings.twitter_settings.tracked_accounts
  11.  
  12. # Model code
  13.  
  14. class TwitterSettings(EmbeddedDocument):
  15.  
  16.     auto_pilot = BooleanField()
  17.  
  18.     tracked_accounts = ListField(StringField())
  19.  
  20. @diff_id_field(IntField, ['id'])
  21. class InboxSettings(Document):
  22.  
  23.     twitter_settings = EmbeddedDocumentField(TwitterSettings)
  24.  
  25.     def load (self, HubSpotUserID):
  26.  
  27.         print "\nLoading record for:", HubSpotUserID
  28.         Collection = self.getCollection()
  29.  
  30.         Record = Collection.find_one(pk=HubSpotUserID)
  31.  
  32.         if Record:
  33.             print "\nRecord="
  34.             pprint.pprint(Record)
  35.  
  36.             self = InboxSettings(**Record)
  37.  
  38.             super(InboxSettings, self).__init__(**Record)
  39.  
  40.             print "\nThis output works.  self Record="
  41.             pprint.pprint (vars(self))
  42.  
  43.             print "\nThis works too.  twitter_settings="
  44.             pprint.pprint (vars(self.twitter_settings))
  45.  
  46.             print "\nAnd this works.  Accounts=", self.twitter_settings.tracked_accounts
Add Comment
Please, Sign In to add comment