[PATCH 4/9] Re: Inherit LocalStatusSQLFolder from LocalStatusFolder

Nicolas Sebrecht nicolas.s-dev at laposte.net
Wed Apr 27 18:27:42 BST 2011


On Tue, Apr 26, 2011 at 12:31:35PM +0200, Sebastian Spaeth wrote:
> 
> - Inherit LocalStatusSQLFolder from LocalStatusFolder
> 
> - This lets us remove all functions that are available via our ancestors
>   classes and are not needed.
> 
> - Don't fail if pysql import fails. Fail rather at runtime when needed.
> 
> - When creating the db file, create a metadata table which contains the
>   format version info, so we can upgrade nicely to other formats.

<...>

> -    def getfullname(self):
> -        return self.filename
> +        # testing the existence of the db file won't work. It is created
> +        # as soon as this class instance was intitiated. So say it is a
> +        # new folder when there are no messages at all recorded in it.
> +        return self.getmessagecount() > 0

I'm surprised. Is getfullname() used for _testing_ the existence? Is the
name of this method so fucked up?

> +    def create_db(self):
> +        """Create a new db file"""
> +        self.ui.warn('Creating new Local Status db for %s:%s' \
> +                         % (self.repository.getname(), self.getname()))
> +        self.connection = sqlite.connect(self.filename)
> +        self.cursor = self.connection.cursor()
> +        self.cursor.execute('CREATE TABLE metadata (key VARCHAR(50) PRIMARY KEY, value VARCHAR(128))')
> +        self.cursor.execute("INSERT INTO metadata VALUES('db_version', '1')")
> +        self.cursor.execute('CREATE TABLE status (id INTEGER PRIMARY KEY, flags VARCHAR(50))')
> +        self.autosave() #commit if needed

Oh, yeah! It's a much better migration plan but we still need more
advanced.  :-)

-- 
Nicolas Sebrecht




More information about the OfflineIMAP-project mailing list