From 12fcd1be2f1a891b7fe099ad0044e68c45280907 Mon Sep 17 00:00:00 2001 From: "uco (OpenERP)" Date: Fri, 19 Nov 2010 19:18:01 +0530 Subject: [IMP] : Added context=None on methods used for _constraints and replaced context={} with context=None. bzr revid: uco@tinyerp.com-20101119134801-974ev29j4tu46pq2 --- addons/fetchmail/fetchmail.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'addons/fetchmail/fetchmail.py') diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index 77748adf017..295f8813047 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -72,7 +72,7 @@ class email_server(osv.osv): 'user_id': lambda self, cr, uid, ctx: uid, } - def check_duplicate(self, cr, uid, ids): + def check_duplicate(self, cr, uid, ids, context=None): # RFC *-* Why this limitation? why not in SQL constraint? vals = self.read(cr, uid, ids, ['user', 'password'])[0] cr.execute("select count(id) from email_server where user=%s and password=%s", (vals['user'], vals['password'])) @@ -95,12 +95,14 @@ class email_server(osv.osv): return {'value':{'port':port}} - def set_draft(self, cr, uid, ids, context={}): + def set_draft(self, cr, uid, ids, context=None): self.write(cr, uid, ids , {'state':'draft'}) return True - def button_confirm_login(self, cr, uid, ids, context={}): - for server in self.browse(cr, uid, ids, context): + def button_confirm_login(self, cr, uid, ids, context=None): + if not context: + context = {} + for server in self.browse(cr, uid, ids, context=context): logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail start checking for new emails on %s' % (server.name)) context.update({'server_id': server.id, 'server_type': server.type}) count = 0 @@ -135,20 +137,22 @@ class email_server(osv.osv): logger.notifyChannel(server.type, netsvc.LOG_WARNING, '%s' % (e)) return True - def button_fetch_mail(self, cr, uid, ids, context={}): + def button_fetch_mail(self, cr, uid, ids, context=None): self.fetch_mail(cr, uid, ids, context=context) return True - def _fetch_mails(self, cr, uid, ids=False, context={}): + def _fetch_mails(self, cr, uid, ids=False, context=None): if not ids: ids = self.search(cr, uid, []) return self.fetch_mail(cr, uid, ids, context=context) - def fetch_mail(self, cr, uid, ids, context={}): + def fetch_mail(self, cr, uid, ids, context=None): + if not context: + context = {} email_tool = self.pool.get('email.server.tools') action_pool = self.pool.get('ir.actions.server') context.update({'get_server': True}) - for server in self.browse(cr, uid, ids, context): + for server in self.browse(cr, uid, ids, context=context): count = 0 try: if server.type == 'imap': -- cgit v1.2.3 From 6dd290e8245f4ea91ce87b0f3b5f29bafeaf12e9 Mon Sep 17 00:00:00 2001 From: "uco (OpenERP)" Date: Tue, 23 Nov 2010 12:35:05 +0530 Subject: [REF]: Replace the condition 'if not context' with 'if context is None'. bzr revid: uco@tinyerp.com-20101123070505-9i2lrqhgxzaii3zn --- addons/fetchmail/fetchmail.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'addons/fetchmail/fetchmail.py') diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index 295f8813047..05363819e15 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -100,7 +100,7 @@ class email_server(osv.osv): return True def button_confirm_login(self, cr, uid, ids, context=None): - if not context: + if context is None: context = {} for server in self.browse(cr, uid, ids, context=context): logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail start checking for new emails on %s' % (server.name)) @@ -147,7 +147,7 @@ class email_server(osv.osv): return self.fetch_mail(cr, uid, ids, context=context) def fetch_mail(self, cr, uid, ids, context=None): - if not context: + if context is None: context = {} email_tool = self.pool.get('email.server.tools') action_pool = self.pool.get('ir.actions.server') @@ -209,7 +209,7 @@ class mailgate_message(osv.osv): _order = 'id desc' def create(self, cr, uid, values, context=None): - if not context: + if context is None: context={} server_id = context.get('server_id',False) server_type = context.get('server_type',False) @@ -221,7 +221,7 @@ class mailgate_message(osv.osv): return res def write(self, cr, uid, ids, values, context=None): - if not context: + if context is None: context={} server_id = context.get('server_id',False) server_type = context.get('server_type',False) -- cgit v1.2.3