~yohan-pannet/poweremail/modified_log_level

« back to all changes in this revision

Viewing changes to poweremail_core.py

  • Committer: Sharoon Thomas
  • Date: 2010-03-25 23:30:00 UTC
  • Revision ID: sharoonthomas@teagarden.in-20100325233000-ge0zt58dw29vdpz5
[IMP/FIX]Use of new style methods in poweremail

Show diffs side-by-side

added added

removed removed

Lines of Context:
156
156
         'rec_headers_den_mail':lambda * a:True,
157
157
         'dont_auto_down_attach':lambda * a:True,
158
158
         'send_pref':lambda * a: 'html',
159
 
         'smtptls':lambda *a:True,
 
159
         'smtptls':lambda * a:True,
160
160
     }
161
161
    
162
162
    _sql_constraints = [
224
224
        """
225
225
        #Type cast ids to integer
226
226
        if type(ids) == list:
227
 
            id = ids[0]
228
 
        this_object = self.browse(cursor, user, id, context)
 
227
            ids = ids[0]
 
228
        this_object = self.browse(cursor, user, ids, context)
229
229
        if this_object:
230
230
            if this_object.smtpserver and this_object.smtpport: 
231
231
                try:
324
324
        """        
325
325
        #Type cast ids to integer
326
326
        if type(ids) == list:
327
 
            id = ids[0]
328
 
        this_object = self.browse(cursor, user, id, context)
 
327
            ids = ids[0]
 
328
        this_object = self.browse(cursor, user, ids, context)
329
329
        if this_object:
330
330
            #First validate data
331
331
            if not this_object.iserver:
372
372
        self.write(cr, uid, ids, {'state':'approved'}, context=context)
373
373
#        wf_service = netsvc.LocalService("workflow")
374
374
 
375
 
    def smtp_connection(self, cr, uid, id, context=None):
 
375
    def smtp_connection(self, cursor, user, id, context=None):
 
376
        """
 
377
        This method should now wrap smtp_connection
 
378
        """
376
379
        #This function returns a SMTP server object
377
380
        logger = netsvc.Logger()
378
 
        core_obj = self.browse(cr, uid, id, context)
 
381
        core_obj = self.browse(cursor, user, id, context)
379
382
        if core_obj.smtpserver and core_obj.smtpport and core_obj.state == 'approved':
380
383
            try:
381
 
                serv = smtplib.SMTP(core_obj.smtpserver, core_obj.smtpport)
382
 
                if core_obj.smtpssl:
383
 
                    serv.ehlo()
384
 
                    serv.starttls()
385
 
                    serv.ehlo()
386
 
            except Exception, error:
387
 
                logger.notifyChannel(_("Power Email"), netsvc.LOG_ERROR, _("Mail from Account %s failed. Probable Reason:Could not connect to server\nError: %s") % (id, error))
388
 
                return False
389
 
            try:
390
 
                if core_obj.smtpuname and core_obj.smtppass:
391
 
                    serv.login(core_obj.smtpuname, core_obj.smtppass)
 
384
                serv = self._get_outgoing_server(cursor, user, id, context)
392
385
            except Exception, error:
393
386
                logger.notifyChannel(_("Power Email"), netsvc.LOG_ERROR, _("Mail from Account %s failed on login. Probable Reason:Could not login to server\nError: %s") % (id, error))
394
387
                return False