def _from_dict(cls, data): """Instantiate a Book from a Subledger representation All data should be in the dictionary `data` This method will not query Subledger """ # Emulate Org object org = Dummy() org._id = data['org'] # Create instance self = cls(org, data['description'], data.get('reference')) self._id = data['id'] self._version = data['version'] self._set_type(data['type']) return self
def _from_dict(cls, data): """Instantiate an Account from a Subledger representation All data should be in the dictionary `data` This method will not query Subledger """ # Emulate Book object without http requests book = Dummy() book._id = data['book'] book._org_id = data['org'] # Create Account instance self = cls(book, data['description'], data['normal_balance'], data.get('reference')) self._id = data['id'] self._version = data['version'] self._set_type(data['type']) return self
if __name__ == "__main__": import logging logging.basicConfig(level=logging.INFO) (id_, secret) = file('subledger.secret').read().strip().split() Organization.authenticate(id_, secret) org_id = 'ivMaXfSHBQ9hBq5igz5nU1' #o = Organization.from_id(org_id) #print o # Test if we can skip loading the Org first from base import Dummy o = Dummy() o._id = org_id #b = Book(a._id, 'XBT') #b.save() #b = Book.from_id(u'nFCZ2CIDfIkaY1f6b7bBG4', a._id) tmp = set() for b in Book.all(o, state='archived'): print b.description print b.is_active for b in Book.all(o, state='active'): print b.description print b.is_active