Community: Framework mailing list archives

Re: v8.0 - Cannot create computed field - Field is accessed before being computed.

Maxim Litnitskiy
- 10/16/2014 09:25:46
Sorry for spamming :-)
Also I have to set self.datas = False on IOError when cannot read file otherwise Field is accessed before being computed is raised.
Here is it:
    def get_full_path(self):
        sound_dir = os.path.join(tools.config.filestore(, 'sounds')
        filename = os.path.join(sound_dir, self.datas_fname)
        return filename

    def _data_get(self):
        if not  self.datas_fname:
            self.datas = False
        filename = self.get_full_path()[0]
            r = open(filename, 'rb').read().encode('base64')
            self.datas = r
        except IOError:
            self.datas = False
            _logger.exception('_data_get reading: %s' % filename)