def load(self): if not self.attrib: if self._loading is False: self._loading = True self.attrib = yield Attribute.load(self._table, self._where, self._multirow) # no other data to load for _f in self._futures: _f.set_result(True) self._loading = False self._futures = list() else: _f = Future() self._futures.append(_f) yield _f
def load(self, force=False, where=None, need_value=True): ''' Warning! Do not use force-load in multi-line-mode!!! ''' if not force and self.dict_attribs: #returnValue( self.value ) if need_value: returnValue( self.new_value() ) else: returnValue( [] ) if not where: if hasattr(self, 'where'): where = self.where else: raise AttribManagerException("[ %s ]load failed. you can set where property at first." % self.__class__ ) if self._table not in TABLEs_NO_DELETED: where['deleted'] = 0 try: res = yield Attribute.load(self._table, self._fields, where ) except Exception, e: raise AttribManagerException("[ {0} ]load failed. table: {1}, where: {2}, error: {3}.".format( self.__class__, self._table, where, e))