From 3340398cd7728c6e115d08d5ff26b5eac2e23357 Mon Sep 17 00:00:00 2001 From: mdipierro Date: Mon, 17 Sep 2012 09:12:13 -0500 Subject: [PATCH] fixed imap dal __contains__ issue 1013, thanks Alan --- VERSION | 2 +- gluon/dal.py | 22 ++++++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/VERSION b/VERSION index 6ebfe39a..89699d8c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.0.9 (2012-09-17 08:57:56) stable +Version 2.0.9 (2012-09-17 09:12:09) stable diff --git a/gluon/dal.py b/gluon/dal.py index 54ec7ef2..95683268 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -5509,8 +5509,8 @@ class IMAPAdapter(NoSQLAdapter): # mapped names (which native # mailbox has what table name) - db.mailboxes # tablename, server native name - db.mailbox_names # server native name, tablename + db.mailboxes # DAL instance mailbox tablenames + db.mailbox_names # tablename, server native name pairs """ @@ -5813,8 +5813,10 @@ class IMAPAdapter(NoSQLAdapter): Field("email", "string", writable=False, readable=False), Field("attachments", "list:string", writable=False, readable=False), ) - - return self.connection.mailbox_names + # Set the db instance mailbox collections + self.db.mailbox_names = self.connection.mailbox_names + self.db.mailboxes = self.connection.mailbox_names.keys() + return self.db.mailbox_names def create_table(self, *args, **kwargs): # not implemented @@ -6227,7 +6229,11 @@ class IMAPAdapter(NoSQLAdapter): raise Exception("Operation not supported") return result - def NE(self, first, second): + def NE(self, first, second=None): + if (second is None) and isinstance(first, Field): + # All records special table query + if first.type == "id": + return self.GE(first, 1) result = self.NOT(self.EQ(first, second)) result = result.replace("NOT NOT", "").strip() return result @@ -7150,7 +7156,11 @@ def index(): return table def __contains__(self, tablename): - return tablename in self.tables + try: + return tablename in self.tables + except AttributeError: + # The instance has no .tables attribute yet + return False def get(self,key,default): return self.__dict__.get(key,default)